44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Indotalent.Data.Entities;
|
|
using Indotalent.Shared.Consts;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Indotalent.Infrastructure.Database.MsSQL.Configuration;
|
|
|
|
public class PurchaseRequisitionConfiguration : IEntityTypeConfiguration<PurchaseRequisition>
|
|
{
|
|
public void Configure(EntityTypeBuilder<PurchaseRequisition> builder)
|
|
{
|
|
builder.Property(e => e.AutoNumber)
|
|
.HasMaxLength(GlobalConsts.StringLengthShort);
|
|
|
|
builder.Property(e => e.Description)
|
|
.HasMaxLength(GlobalConsts.StringLengthMedium);
|
|
|
|
builder.Property(e => e.VendorId)
|
|
.HasMaxLength(GlobalConsts.StringLengthId);
|
|
|
|
builder.Property(e => e.TaxId)
|
|
.HasMaxLength(GlobalConsts.StringLengthId);
|
|
|
|
builder.HasOne(e => e.Vendor)
|
|
.WithMany()
|
|
.HasForeignKey(e => e.VendorId)
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
|
|
builder.HasOne(e => e.Tax)
|
|
.WithMany()
|
|
.HasForeignKey(e => e.TaxId)
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
|
|
builder.HasMany(e => e.PurchaseRequisitionItemList)
|
|
.WithOne(e => e.PurchaseRequisition)
|
|
.HasForeignKey(e => e.PurchaseRequisitionId)
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
|
|
builder.HasIndex(e => e.AutoNumber).IsUnique();
|
|
builder.HasIndex(e => e.RequisitionDate);
|
|
builder.HasIndex(e => e.VendorId);
|
|
builder.HasIndex(e => e.TaxId);
|
|
}
|
|
} |