Files
2026-07-21 13:52:43 +07:00

87 lines
2.9 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 PatientConfiguration : IEntityTypeConfiguration<Patient>
{
public void Configure(EntityTypeBuilder<Patient> 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.StringLengthShort);
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.PatientGroupId)
.HasMaxLength(GlobalConsts.StringLengthId);
builder.Property(e => e.PatientCategoryId)
.HasMaxLength(GlobalConsts.StringLengthId);
builder.HasOne(e => e.PatientGroup)
.WithMany()
.HasForeignKey(e => e.PatientGroupId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(e => e.PatientCategory)
.WithMany()
.HasForeignKey(e => e.PatientCategoryId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasIndex(e => e.Name);
builder.HasIndex(e => e.AutoNumber).IsUnique();
builder.HasIndex(e => e.PatientGroupId);
builder.HasIndex(e => e.PatientCategoryId);
}
}