From 3f0da4ba7920104d8d605728f886f9236526796e Mon Sep 17 00:00:00 2001 From: Piotr Kus Date: Tue, 1 Apr 2025 20:49:31 +0200 Subject: [PATCH] * Added MaterialTransaction entity, dto and service --- .../Dtos/MaterialTransactionDto.cs | 41 ++++ .../Entities/MaterialTransaction.cs | 41 ++++ SytelineSaAppEfDataModel/MappingProfile.cs | 6 +- .../Services/IMaterialTransactionService.cs | 10 + .../Services/MaterialTransactionService.cs | 26 +++ .../SytelineSaAppDbContext.cs | 180 ++++++++++++++++++ 6 files changed, 299 insertions(+), 5 deletions(-) create mode 100644 SytelineSaAppEfDataModel/Dtos/MaterialTransactionDto.cs create mode 100644 SytelineSaAppEfDataModel/Entities/MaterialTransaction.cs create mode 100644 SytelineSaAppEfDataModel/Services/IMaterialTransactionService.cs create mode 100644 SytelineSaAppEfDataModel/Services/MaterialTransactionService.cs diff --git a/SytelineSaAppEfDataModel/Dtos/MaterialTransactionDto.cs b/SytelineSaAppEfDataModel/Dtos/MaterialTransactionDto.cs new file mode 100644 index 0000000..f9290cb --- /dev/null +++ b/SytelineSaAppEfDataModel/Dtos/MaterialTransactionDto.cs @@ -0,0 +1,41 @@ +namespace SytelineSaAppEfDataModel.Dtos; + +public class MaterialTransactionDto +{ + public string MTGroup { get; set; } + public string MTGroupNum { get; set; } + public long TransNum { get; set; } + public string Item { get; set; } + public DateTime? TransDate { get; set; } + public decimal? Qty { get; set; } + public decimal? Cost { get; set; } + public string Whse { get; set; } + public string Loc { get; set; } + public string RefNum { get; set; } + public short? RefLineSuf { get; set; } + public short? RefRelease { get; set; } + public string ReasonCode { get; set; } + public string TransType { get; set; } + public string RefType { get; set; } + public string MTReasonType { get; set; } + public string PrefixId { get; set; } + public string SequenceId { get; set; } + public string WhseSequenceId { get; set; } + public bool WhseSplit { get; set; } + public Guid? VariableId { get; set; } + public string FormName { get; set; } + public bool InWorkflow { get; set; } + public bool NoteExistsFlag { get; set; } + public DateTime RecordDate { get; set; } + public Guid RowPointer { get; set; } + public string CreatedBy { get; set; } + public string UpdatedBy { get; set; } + public DateTime CreateDate { get; set; } + public string CustNum { get; set; } + public string VendNum { get; set; } + public int? RecipNum { get; set; } + public string Uf_FKR_internal_num_matltran_zn { get; set; } + public Guid? Session_Id { get; set; } + public string Uf_MobileAppUser { get; set; } + public string NR_KARTY_KONTROLNEJ { get; set; } +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/Entities/MaterialTransaction.cs b/SytelineSaAppEfDataModel/Entities/MaterialTransaction.cs new file mode 100644 index 0000000..cf7dd43 --- /dev/null +++ b/SytelineSaAppEfDataModel/Entities/MaterialTransaction.cs @@ -0,0 +1,41 @@ +namespace SytelineSaAppEfDataModel.Entities; + +public class MaterialTransaction +{ + public string MTGroup { get; set; } + public string MTGroupNum { get; set; } + public long TransNum { get; set; } + public string Item { get; set; } + public DateTime? TransDate { get; set; } + public decimal? Qty { get; set; } + public decimal? Cost { get; set; } + public string Whse { get; set; } + public string Loc { get; set; } + public string RefNum { get; set; } + public short? RefLineSuf { get; set; } + public short? RefRelease { get; set; } + public string ReasonCode { get; set; } + public string TransType { get; set; } + public string RefType { get; set; } + public string MTReasonType { get; set; } + public string PrefixId { get; set; } + public string SequenceId { get; set; } + public string WhseSequenceId { get; set; } + public bool WhseSplit { get; set; } + public Guid? VariableId { get; set; } + public string FormName { get; set; } + public bool InWorkflow { get; set; } + public bool NoteExistsFlag { get; set; } + public DateTime RecordDate { get; set; } + public Guid RowPointer { get; set; } + public string CreatedBy { get; set; } + public string UpdatedBy { get; set; } + public DateTime CreateDate { get; set; } + public string CustNum { get; set; } + public string VendNum { get; set; } + public int? RecipNum { get; set; } + public string Uf_FKR_internal_num_matltran_zn { get; set; } + public Guid? Session_Id { get; set; } + public string Uf_MobileAppUser { get; set; } + public string NR_KARTY_KONTROLNEJ { get; set; } +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/MappingProfile.cs b/SytelineSaAppEfDataModel/MappingProfile.cs index 872a09d..d8d3847 100644 --- a/SytelineSaAppEfDataModel/MappingProfile.cs +++ b/SytelineSaAppEfDataModel/MappingProfile.cs @@ -1,9 +1,4 @@ using AutoMapper; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using SytelineSaAppEfDataModel.Dtos; using SytelineSaAppEfDataModel.Entities; @@ -24,6 +19,7 @@ namespace SytelineSaAppEfDataModel CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); + CreateMap().ReverseMap(); } } } diff --git a/SytelineSaAppEfDataModel/Services/IMaterialTransactionService.cs b/SytelineSaAppEfDataModel/Services/IMaterialTransactionService.cs new file mode 100644 index 0000000..86ef880 --- /dev/null +++ b/SytelineSaAppEfDataModel/Services/IMaterialTransactionService.cs @@ -0,0 +1,10 @@ +using SytelineSaAppEfDataModel.Dtos; + +namespace SytelineSaAppEfDataModel.Services; + +public interface IMaterialTransactionService +{ + Task> GetAll(); + Task GetByWzNumber(string wzNumber); + Task> GetByOrderNumber(string orderNumber); +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/Services/MaterialTransactionService.cs b/SytelineSaAppEfDataModel/Services/MaterialTransactionService.cs new file mode 100644 index 0000000..edb47ab --- /dev/null +++ b/SytelineSaAppEfDataModel/Services/MaterialTransactionService.cs @@ -0,0 +1,26 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using SytelineSaAppEfDataModel.Dtos; + +namespace SytelineSaAppEfDataModel.Services; + +public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper mapper) : IMaterialTransactionService +{ + public async Task> GetAll() + { + return await context.MaterialTransactions.Select(x => mapper.Map(x)).ToListAsync(); + } + + public async Task GetByWzNumber(string wzNumber) + { + return await context.MaterialTransactions + .Where(x => x.MTGroupNum == wzNumber) + .Select(x => mapper.Map(x)).FirstOrDefaultAsync(); + } + + public async Task> GetByOrderNumber(string orderNumber) + { + return await context.MaterialTransactions.Where(x => x.RefNum == orderNumber) + .Select(x => mapper.Map(x)).ToListAsync(); + } +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs b/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs index 536841b..7a386c9 100644 --- a/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs +++ b/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs @@ -18,6 +18,8 @@ namespace SytelineSaAppEfDataModel public DbSet CustomerOrderLineItems { get; set; } public DbSet UserNames { get; set; } public DbSet EdiUsers { get; set; } + + public DbSet MaterialTransactions { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { @@ -694,6 +696,184 @@ namespace SytelineSaAppEfDataModel entity.HasIndex(e => e.Login).IsUnique(); }); + + modelBuilder.Entity(entity => + { + entity.ToTable("ZPL_InternalNum_Matltran"); + + entity.HasKey(e => e.TransNum); + + entity.Property(e => e.MTGroup) + .HasColumnName("MTGroup") + .HasMaxLength(10) + .IsRequired(false); + + entity.Property(e => e.MTGroupNum) + .HasColumnName("MTGroupNum") + .IsRequired(); + + entity.Property(e => e.TransNum) + .HasColumnName("trans_num") + .HasColumnType("bigint"); + + entity.Property(e => e.Item) + .HasColumnName("item") + .HasMaxLength(60) + .IsRequired(false); + + entity.Property(e => e.TransDate) + .HasColumnName("trans_date") + .IsRequired(false); + + entity.Property(e => e.Qty) + .HasColumnName("qty") + .IsRequired(false); + + entity.Property(e => e.Cost) + .HasColumnName("cost") + .IsRequired(false); + + entity.Property(e => e.Whse) + .HasColumnName("whse") + .HasMaxLength(8) + .IsRequired(false); + + entity.Property(e => e.Loc) + .HasColumnName("loc") + .HasMaxLength(20) + .IsRequired(false); + + entity.Property(e => e.RefNum) + .HasColumnName("ref_num") + .HasMaxLength(20) + .IsRequired(false); + + entity.Property(e => e.RefLineSuf) + .HasColumnName("ref_line_suf") + .HasColumnType("smallint") + .IsRequired(false); + + entity.Property(e => e.RefRelease) + .HasColumnName("ref_release") + .HasColumnType("smallint") + .IsRequired(false); + + entity.Property(e => e.ReasonCode) + .HasColumnName("reason_code") + .HasMaxLength(6) + .IsRequired(false); + + entity.Property(e => e.TransType) + .HasColumnName("trans_type") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.RefType) + .HasColumnName("ref_type") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.MTReasonType) + .HasColumnName("MTReasonType") + .HasMaxLength(10) + .IsRequired(false); + + entity.Property(e => e.PrefixId) + .HasColumnName("PrefixId") + .HasMaxLength(20) + .IsRequired(false); + + entity.Property(e => e.SequenceId) + .HasColumnName("SequenceId") + .HasMaxLength(20) + .IsRequired(false); + + entity.Property(e => e.WhseSequenceId) + .HasColumnName("WhseSequenceId") + .HasMaxLength(20) + .IsRequired(false); + + entity.Property(e => e.WhseSplit) + .HasColumnName("WhseSplit") + .HasColumnType("tinyint"); + + entity.Property(e => e.VariableId) + .HasColumnName("VariableId") + .HasColumnType("uniqueidentifier") + .IsRequired(false); + + entity.Property(e => e.FormName) + .HasColumnName("FormName") + .HasMaxLength(100) + .IsRequired(false); + + entity.Property(e => e.InWorkflow) + .HasColumnName("InWorkflow") + .HasColumnType("tinyint") + .HasDefaultValueSql("0"); + + entity.Property(e => e.NoteExistsFlag) + .HasColumnName("NoteExistsFlag") + .HasColumnType("tinyint") + .HasDefaultValueSql("0"); + + entity.Property(e => e.RecordDate) + .HasColumnName("RecordDate") + .HasDefaultValueSql("getdate()"); + + entity.Property(e => e.RowPointer) + .HasColumnName("RowPointer") + .HasColumnType("uniqueidentifier") + .HasDefaultValueSql("newid()"); + + entity.Property(e => e.CreatedBy) + .HasColumnName("CreatedBy") + .HasMaxLength(60) + .HasDefaultValueSql("suser_sname()"); + + entity.Property(e => e.UpdatedBy) + .HasColumnName("UpdatedBy") + .HasMaxLength(60) + .HasDefaultValueSql("suser_sname()"); + + entity.Property(e => e.CreateDate) + .HasColumnName("CreateDate") + .HasDefaultValueSql("getdate()"); + + entity.Property(e => e.CustNum) + .HasColumnName("CustNum") + .HasMaxLength(14) + .HasDefaultValueSql("NULL"); + + entity.Property(e => e.VendNum) + .HasColumnName("VendNum") + .HasMaxLength(14) + .HasDefaultValueSql("NULL"); + + entity.Property(e => e.RecipNum) + .HasColumnName("RecipNum") + .IsRequired(false); + + entity.Property(e => e.Uf_FKR_internal_num_matltran_zn) + .HasColumnName("Uf_FKR_internal_num_matltran_zn") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.Session_Id) + .HasColumnName("Session_Id") + .HasColumnType("uniqueidentifier") + .IsRequired(false); + + entity.Property(e => e.Uf_MobileAppUser) + .HasColumnName("Uf_MobileAppUser") + .HasMaxLength(15) + .IsRequired(false); + + entity.Property(e => e.NR_KARTY_KONTROLNEJ) + .HasColumnName("NR_KARTY_KONTROLNEJ") + .HasMaxLength(20) + .IsRequired(false); + }); } } }