* Created Entities, Dtos and Mapping for WzClient and WzHeader

This commit is contained in:
2025-05-07 21:21:02 +02:00
parent 9f38998135
commit 1f08ae05f0
12 changed files with 215 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
namespace SytelineSaAppEfDataModel.Dtos;
public class WzClientDto
{
public Guid ID { get; set; }
public string CustomerNumber { get; set; }
public int? CustomerSequence { get; set; }
public DateTime CreatedDate { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace SytelineSaAppEfDataModel.Dtos;
public class WzHeaderDto
{
public Guid ID { get; set; }
public Guid? FK_Client { get; set; }
public DateTime CreatedDate { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace SytelineSaAppEfDataModel.Entities;
public class WzClient
{
public Guid ID { get; set; }
public string CustomerNumber { get; set; }
public int? CustomerSequence { get; set; }
public DateTime CreatedDate { get; set; }
}

View File

@@ -0,0 +1,11 @@
namespace SytelineSaAppEfDataModel.Entities;
public class WzHeader
{
public Guid ID { get; set; }
public Guid? FK_Client { get; set; }
public DateTime CreatedDate { get; set; }
// Navigation property
public WzClient Client { get; set; }
}

View File

@@ -20,6 +20,7 @@ namespace SytelineSaAppEfDataModel
CreateMap<UserName, UserNameDto>().ReverseMap();
CreateMap<EdiUser, EdiUserDto>().ReverseMap();
CreateMap<MaterialTransaction, MaterialTransactionDto>().ReverseMap();
CreateMap<WzClient, WzClientDto>().ReverseMap();
}
}
}

View File

@@ -0,0 +1,8 @@
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public interface IWzClientService
{
Task<IEnumerable<WzClientDto>> GetAll();
}

View File

@@ -0,0 +1,8 @@
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public interface IWzHeaderService
{
Task<IEnumerable<WzHeaderDto>> GetAll();
}

View File

@@ -0,0 +1,13 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public class WzClientService(SytelineSaAppDbContext context, IMapper mapper) : IWzClientService
{
public async Task<IEnumerable<WzClientDto>> GetAll()
{
return await context.WzClients.Select(x => mapper.Map<WzClientDto>(x)).ToListAsync();
}
}

View File

@@ -0,0 +1,13 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public class WzHeaderService(SytelineSaAppDbContext context, IMapper mapper) : IWzHeaderService
{
public async Task<IEnumerable<WzHeaderDto>> GetAll()
{
return await context.WzHeaders.Select(x => mapper.Map<WzHeaderDto>(x)).ToListAsync();
}
}

View File

@@ -20,6 +20,9 @@ namespace SytelineSaAppEfDataModel
public DbSet<EdiUser> EdiUsers { get; set; }
public DbSet<MaterialTransaction> MaterialTransactions { get; set; }
public DbSet<WzClient> WzClients { get; set; }
public DbSet<WzHeader> WzHeaders { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -875,6 +878,59 @@ namespace SytelineSaAppEfDataModel
.HasMaxLength(20)
.IsRequired(false);
});
modelBuilder.Entity<WzHeader>(entity =>
{
entity.ToTable("wz_header");
entity.HasKey(e => e.ID);
entity.Property(e => e.ID)
.HasColumnName("ID")
.HasColumnType("uniqueidentifier");
entity.Property(e => e.FK_Client)
.HasColumnName("FK_Client")
.HasColumnType("uniqueidentifier")
.IsRequired(false);
entity.Property(e => e.CreatedDate)
.HasColumnName("CreatedDate")
.HasColumnType("timestamp")
.IsRowVersion();
// Relationship
entity.HasOne(e => e.Client)
.WithMany()
.HasForeignKey(e => e.FK_Client)
.HasConstraintName("wz_header_wz_clients_ID_fk");
});
modelBuilder.Entity<WzClient>(entity =>
{
entity.ToTable("wz_clients");
entity.HasKey(e => e.ID);
entity.Property(e => e.ID)
.HasColumnName("ID")
.HasColumnType("uniqueidentifier");
entity.Property(e => e.CustomerNumber)
.HasColumnName("CustomerNumber")
.HasMaxLength(20)
.IsRequired(false);
entity.Property(e => e.CustomerSequence)
.HasColumnName("CustomerSequence")
.HasColumnType("int")
.IsRequired(false);
entity.Property(e => e.CreatedDate)
.HasColumnName("CreatedDate")
.HasColumnType("timestamp")
.IsRowVersion();
});
}
}
}