From 764ba68f56cb65fe90a2ffc1c02c4409c5e9be2b Mon Sep 17 00:00:00 2001 From: Piotr Kus Date: Fri, 22 Aug 2025 07:13:47 +0200 Subject: [PATCH] * Added ItemCustPriceAll entity --- .../Controllers/ItemCustPriceAllController.cs | 23 +++ FaKrosnoApi/Program.cs | 1 + .../Dtos/ItemCustPriceAllDto.cs | 39 ++++ .../Entities/ItemCustPriceAll.cs | 39 ++++ SytelineSaAppEfDataModel/MappingProfile.cs | 1 + .../Services/IItemCustPriceAllService.cs | 8 + .../Services/ItemCustPriceAllService.cs | 13 ++ .../SytelineSaAppDbContext.cs | 169 ++++++++++++++++++ 8 files changed, 293 insertions(+) create mode 100644 FaKrosnoApi/Controllers/ItemCustPriceAllController.cs create mode 100644 SytelineSaAppEfDataModel/Dtos/ItemCustPriceAllDto.cs create mode 100644 SytelineSaAppEfDataModel/Entities/ItemCustPriceAll.cs create mode 100644 SytelineSaAppEfDataModel/Services/IItemCustPriceAllService.cs create mode 100644 SytelineSaAppEfDataModel/Services/ItemCustPriceAllService.cs diff --git a/FaKrosnoApi/Controllers/ItemCustPriceAllController.cs b/FaKrosnoApi/Controllers/ItemCustPriceAllController.cs new file mode 100644 index 0000000..deca1a9 --- /dev/null +++ b/FaKrosnoApi/Controllers/ItemCustPriceAllController.cs @@ -0,0 +1,23 @@ +using AutoMapper; +using Microsoft.AspNetCore.Mvc; +using SytelineSaAppEfDataModel.Dtos; +using SytelineSaAppEfDataModel.Services; + +namespace FaKrosnoApi.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class ItemCustPriceAllController(IItemCustPriceAllService service, IMapper mapper) : Controller +{ + [HttpGet("by-parameters")] + public async Task> GetItemCustPriceAll(string itemCode, string customerDoInvoice) + { + var result = await service.GetItemCustPriceAllAsync(itemCode, customerDoInvoice); + if (result == null) + { + return NotFound(); + } + + return Ok(mapper.Map(result)); + } +} \ No newline at end of file diff --git a/FaKrosnoApi/Program.cs b/FaKrosnoApi/Program.cs index 7dcbed3..6a75ea6 100644 --- a/FaKrosnoApi/Program.cs +++ b/FaKrosnoApi/Program.cs @@ -107,6 +107,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddHostedService(); diff --git a/SytelineSaAppEfDataModel/Dtos/ItemCustPriceAllDto.cs b/SytelineSaAppEfDataModel/Dtos/ItemCustPriceAllDto.cs new file mode 100644 index 0000000..262dd20 --- /dev/null +++ b/SytelineSaAppEfDataModel/Dtos/ItemCustPriceAllDto.cs @@ -0,0 +1,39 @@ +namespace SytelineSaAppEfDataModel.Dtos; + +public class ItemCustPriceAllDto +{ + public string SiteRef { get; set; } + public string Item { get; set; } + public string CustNum { get; set; } + public int CustItemSeq { get; set; } + public DateTime EffectDate { get; set; } + public decimal? ContPrice { get; set; } + public decimal? BrkQty1 { get; set; } + public decimal? BrkQty2 { get; set; } + public decimal? BrkQty3 { get; set; } + public decimal? BrkQty4 { get; set; } + public decimal? BrkQty5 { get; set; } + public decimal? BrkPrice1 { get; set; } + public decimal? BrkPrice2 { get; set; } + public decimal? BrkPrice3 { get; set; } + public decimal? BrkPrice4 { get; set; } + public decimal? BrkPrice5 { get; set; } + public string BaseCode1 { get; set; } + public string BaseCode2 { get; set; } + public string BaseCode3 { get; set; } + public string BaseCode4 { get; set; } + public string BaseCode5 { get; set; } + public string DolPercent1 { get; set; } + public string DolPercent2 { get; set; } + public string DolPercent3 { get; set; } + public string DolPercent4 { get; set; } + public string DolPercent5 { 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 bool InWorkflow { get; set; } + public bool IncludeTaxInPrice { get; set; } +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/Entities/ItemCustPriceAll.cs b/SytelineSaAppEfDataModel/Entities/ItemCustPriceAll.cs new file mode 100644 index 0000000..8862ed4 --- /dev/null +++ b/SytelineSaAppEfDataModel/Entities/ItemCustPriceAll.cs @@ -0,0 +1,39 @@ +namespace SytelineSaAppEfDataModel.Entities; + +public class ItemCustPriceAll +{ + public string SiteRef { get; set; } + public string Item { get; set; } + public string CustNum { get; set; } + public int CustItemSeq { get; set; } + public DateTime EffectDate { get; set; } + public decimal? ContPrice { get; set; } + public decimal? BrkQty1 { get; set; } + public decimal? BrkQty2 { get; set; } + public decimal? BrkQty3 { get; set; } + public decimal? BrkQty4 { get; set; } + public decimal? BrkQty5 { get; set; } + public decimal? BrkPrice1 { get; set; } + public decimal? BrkPrice2 { get; set; } + public decimal? BrkPrice3 { get; set; } + public decimal? BrkPrice4 { get; set; } + public decimal? BrkPrice5 { get; set; } + public string BaseCode1 { get; set; } + public string BaseCode2 { get; set; } + public string BaseCode3 { get; set; } + public string BaseCode4 { get; set; } + public string BaseCode5 { get; set; } + public string DolPercent1 { get; set; } + public string DolPercent2 { get; set; } + public string DolPercent3 { get; set; } + public string DolPercent4 { get; set; } + public string DolPercent5 { 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 bool InWorkflow { get; set; } + public bool IncludeTaxInPrice { get; set; } +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/MappingProfile.cs b/SytelineSaAppEfDataModel/MappingProfile.cs index b3b81b3..9a27cfa 100644 --- a/SytelineSaAppEfDataModel/MappingProfile.cs +++ b/SytelineSaAppEfDataModel/MappingProfile.cs @@ -30,6 +30,7 @@ namespace SytelineSaAppEfDataModel CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); + CreateMap().ReverseMap(); } } } diff --git a/SytelineSaAppEfDataModel/Services/IItemCustPriceAllService.cs b/SytelineSaAppEfDataModel/Services/IItemCustPriceAllService.cs new file mode 100644 index 0000000..c52f43e --- /dev/null +++ b/SytelineSaAppEfDataModel/Services/IItemCustPriceAllService.cs @@ -0,0 +1,8 @@ +using SytelineSaAppEfDataModel.Dtos; + +namespace SytelineSaAppEfDataModel.Services; + +public interface IItemCustPriceAllService +{ + Task GetItemCustPriceAllAsync(string item, string customerNumber); +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/Services/ItemCustPriceAllService.cs b/SytelineSaAppEfDataModel/Services/ItemCustPriceAllService.cs new file mode 100644 index 0000000..c0b0969 --- /dev/null +++ b/SytelineSaAppEfDataModel/Services/ItemCustPriceAllService.cs @@ -0,0 +1,13 @@ +using AutoMapper; +using SytelineSaAppEfDataModel.Dtos; + +namespace SytelineSaAppEfDataModel.Services; + +public class ItemCustPriceAllService(SytelineSaAppDbContext context, IMapper mapper) : IItemCustPriceAllService +{ + public async Task GetItemCustPriceAllAsync(string item, string customerNumber) + { + return await Task.FromResult(mapper.Map(context.ItemCustPriceAlls + .OrderByDescending(x => x.EffectDate).FirstOrDefault(x => x.Item == item && x.CustNum == customerNumber))); + } +} \ No newline at end of file diff --git a/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs b/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs index a7fd0e6..8495b6f 100644 --- a/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs +++ b/SytelineSaAppEfDataModel/SytelineSaAppDbContext.cs @@ -29,6 +29,7 @@ namespace SytelineSaAppEfDataModel public DbSet CustomerTps { get; set; } public DbSet Items { get; set; } public DbSet VatCodeAssociations { get; set; } + public DbSet ItemCustPriceAlls { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { @@ -2299,6 +2300,174 @@ namespace SytelineSaAppEfDataModel .HasMaxLength(200) .IsRequired(false); }); + + modelBuilder.Entity(entity => + { + entity.ToTable("itemcustprice_all"); + + entity.HasKey(e => new { e.SiteRef, e.Item, e.CustNum, e.CustItemSeq, e.EffectDate }); + + entity.Property(e => e.SiteRef) + .HasColumnName("site_ref") + .HasMaxLength(16) + .IsRequired(); + + entity.Property(e => e.Item) + .HasColumnName("item") + .HasMaxLength(60) + .IsRequired(); + + entity.Property(e => e.CustNum) + .HasColumnName("cust_num") + .HasMaxLength(14) + .IsRequired(); + + entity.Property(e => e.CustItemSeq) + .HasColumnName("cust_item_seq") + .HasColumnType("int") + .IsRequired(); + + entity.Property(e => e.EffectDate) + .HasColumnName("effect_date") + .IsRequired(); + + entity.Property(e => e.ContPrice) + .HasColumnName("cont_price") + .IsRequired(false); + + entity.Property(e => e.BrkQty1) + .HasColumnName("brk_qty##1") + .IsRequired(false); + + entity.Property(e => e.BrkQty2) + .HasColumnName("brk_qty##2") + .IsRequired(false); + + entity.Property(e => e.BrkQty3) + .HasColumnName("brk_qty##3") + .IsRequired(false); + + entity.Property(e => e.BrkQty4) + .HasColumnName("brk_qty##4") + .IsRequired(false); + + entity.Property(e => e.BrkQty5) + .HasColumnName("brk_qty##5") + .IsRequired(false); + + entity.Property(e => e.BrkPrice1) + .HasColumnName("brk_price##1") + .IsRequired(false); + + entity.Property(e => e.BrkPrice2) + .HasColumnName("brk_price##2") + .IsRequired(false); + + entity.Property(e => e.BrkPrice3) + .HasColumnName("brk_price##3") + .IsRequired(false); + + entity.Property(e => e.BrkPrice4) + .HasColumnName("brk_price##4") + .IsRequired(false); + + entity.Property(e => e.BrkPrice5) + .HasColumnName("brk_price##5") + .IsRequired(false); + + entity.Property(e => e.BaseCode1) + .HasColumnName("base_code##1") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.BaseCode2) + .HasColumnName("base_code##2") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.BaseCode3) + .HasColumnName("base_code##3") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.BaseCode4) + .HasColumnName("base_code##4") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.BaseCode5) + .HasColumnName("base_code##5") + .HasMaxLength(2) + .IsRequired(false); + + entity.Property(e => e.DolPercent1) + .HasColumnName("dol_percent##1") + .HasMaxLength(1) + .IsRequired(false); + + entity.Property(e => e.DolPercent2) + .HasColumnName("dol_percent##2") + .HasMaxLength(1) + .IsRequired(false); + + entity.Property(e => e.DolPercent3) + .HasColumnName("dol_percent##3") + .HasMaxLength(1) + .IsRequired(false); + + entity.Property(e => e.DolPercent4) + .HasColumnName("dol_percent##4") + .HasMaxLength(1) + .IsRequired(false); + + entity.Property(e => e.DolPercent5) + .HasColumnName("dol_percent##5") + .HasMaxLength(1) + .IsRequired(false); + + entity.Property(e => e.NoteExistsFlag) + .HasColumnName("NoteExistsFlag") + .HasColumnType("tinyint") + .IsRequired(); + + entity.Property(e => e.RecordDate) + .HasColumnName("RecordDate") + .IsRequired(); + + entity.Property(e => e.RowPointer) + .HasColumnName("RowPointer") + .HasColumnType("uniqueidentifier") + .IsRequired(); + + entity.Property(e => e.CreatedBy) + .HasColumnName("CreatedBy") + .HasMaxLength(60) + .IsRequired(); + + entity.Property(e => e.UpdatedBy) + .HasColumnName("UpdatedBy") + .HasMaxLength(60) + .IsRequired(); + + entity.Property(e => e.CreateDate) + .HasColumnName("CreateDate") + .IsRequired(); + + entity.Property(e => e.InWorkflow) + .HasColumnName("InWorkflow") + .HasColumnType("tinyint") + .IsRequired(); + + entity.Property(e => e.IncludeTaxInPrice) + .HasColumnName("include_tax_in_price") + .HasColumnType("tinyint") + .IsRequired(); + + // Index + entity.HasIndex(e => new { e.RowPointer, e.SiteRef }) + .HasDatabaseName("IX_itemcustprice_all_RowPointer") + .IsUnique(); + }); } } }