using Indotalent.Data.Entities; using Indotalent.Shared.Consts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Indotalent.Infrastructure.Database.MsSQL.Configuration; public class VendorConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.Property(e => e.Name) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.AutoNumber) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Description) .HasMaxLength(GlobalConsts.StringLengthMedium); builder.Property(e => e.Street) .HasMaxLength(GlobalConsts.StringLengthMedium); builder.Property(e => e.City) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.State) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.ZipCode) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Country) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.PhoneNumber) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.FaxNumber) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.EmailAddress) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Website) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.WhatsApp) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.LinkedIn) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Facebook) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Instagram) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.TwitterX) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.TikTok) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.VendorGroupId) .HasMaxLength(GlobalConsts.StringLengthId); builder.Property(e => e.VendorCategoryId) .HasMaxLength(GlobalConsts.StringLengthId); builder.HasOne(e => e.VendorGroup) .WithMany() .HasForeignKey(e => e.VendorGroupId) .OnDelete(DeleteBehavior.NoAction); builder.HasOne(e => e.VendorCategory) .WithMany() .HasForeignKey(e => e.VendorCategoryId) .OnDelete(DeleteBehavior.NoAction); builder.HasMany(e => e.VendorContactList) .WithOne(e => e.Vendor) .HasForeignKey(e => e.VendorId) .OnDelete(DeleteBehavior.Cascade); builder.HasIndex(e => new { e.TenantId, e.Name }).IsUnique(); builder.HasIndex(e => new { e.TenantId, e.AutoNumber }).IsUnique(); builder.HasIndex(e => e.VendorGroupId); builder.HasIndex(e => e.VendorCategoryId); } }