using Helpdesk.Domain.Catalogs; using Helpdesk.Domain.Issues; using Helpdesk.Domain.Notifications; using Helpdesk.Domain.Proposals; using Helpdesk.Domain.Users; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Helpdesk.Infrastructure.Persistence; internal sealed class IssueConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder b) { b.ToTable("issue"); b.Property(x => x.Title).HasMaxLength(200); b.Property(x => x.Description).HasColumnType("text"); b.Property(x => x.LocationDetail).HasMaxLength(255); b.Property(x => x.Status).HasConversion>().HasMaxLength(30); b.Property(x => x.Priority).HasConversion>().HasMaxLength(10); b.Property(x => x.RowVersion).IsConcurrencyToken(); b.HasOne().WithMany().HasForeignKey(x => x.CategoryId); b.HasOne().WithMany().HasForeignKey(x => x.BuildingId); b.HasOne().WithMany().HasForeignKey(x => x.ReporterId); b.HasOne().WithMany().HasForeignKey(x => x.AssigneeId); } } internal sealed class IssueEventConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder b) { b.ToTable("issue_event"); b.Property(x => x.EventType).HasConversion>().HasMaxLength(20); b.Property(x => x.FromStatus).HasConversion>().HasMaxLength(30); b.Property(x => x.ToStatus).HasConversion>().HasMaxLength(30); b.Property(x => x.Note).HasColumnType("text"); b.HasOne(x => x.Issue).WithMany().HasForeignKey(x => x.IssueId); b.HasOne().WithMany().HasForeignKey(x => x.ActorId); } } internal sealed class AttachmentConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder b) { b.ToTable("attachment"); b.Property(x => x.OriginalFileName).HasMaxLength(255); b.Property(x => x.StoredFileName).HasMaxLength(36); b.Property(x => x.ContentType).HasMaxLength(100); b.HasOne(x => x.Issue).WithMany().HasForeignKey(x => x.IssueId); } } internal sealed class NotificationConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder b) { b.ToTable("notification"); b.Property(x => x.Type).HasConversion>().HasMaxLength(40); b.Property(x => x.Title).HasMaxLength(200); b.Property(x => x.Message).HasMaxLength(1000); b.HasOne(x => x.Issue).WithMany().HasForeignKey(x => x.IssueId).IsRequired(false); b.HasOne().WithMany().HasForeignKey(x => x.ProposalId); b.HasOne().WithMany().HasForeignKey(x => x.UserId); } } internal sealed class NotificationDeliveryConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder b) { b.ToTable("notification_delivery"); b.Property(x => x.Channel).HasConversion>().HasMaxLength(10); b.Property(x => x.Status).HasConversion>().HasMaxLength(10); b.HasOne(x => x.Notification).WithMany().HasForeignKey(x => x.NotificationId); } }