46 lines
1.9 KiB
C#
46 lines
1.9 KiB
C#
using Helpdesk.Domain.Catalogs;
|
|||
|
|
using Helpdesk.Domain.Proposals;
|
||
|
|
using Helpdesk.Domain.Users;
|
||
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||
|
|
|
||
|
|
namespace Helpdesk.Infrastructure.Persistence;
|
||
|
|
|
||
|
|
internal sealed class ProposalConfiguration : IEntityTypeConfiguration<Proposal>
|
||
|
|
{
|
||
|
|
public void Configure(EntityTypeBuilder<Proposal> b)
|
||
|
|
{
|
||
|
|
b.ToTable("proposal");
|
||
|
|
b.Property(x => x.Title).HasMaxLength(200);
|
||
|
|
b.Property(x => x.Description).HasColumnType("text");
|
||
|
|
b.Property(x => x.Status).HasConversion<EnumCodeConverter<ProposalStatus>>().HasMaxLength(30);
|
||
|
|
b.HasOne<ProposalCategory>().WithMany().HasForeignKey(x => x.CategoryId);
|
||
|
|
b.HasOne<User>().WithMany().HasForeignKey(x => x.AuthorId);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed class ProposalEventConfiguration : IEntityTypeConfiguration<ProposalEvent>
|
||
|
|
{
|
||
|
|
public void Configure(EntityTypeBuilder<ProposalEvent> b)
|
||
|
|
{
|
||
|
|
b.ToTable("proposal_event");
|
||
|
|
b.Property(x => x.EventType).HasConversion<EnumCodeConverter<ProposalEventType>>().HasMaxLength(20);
|
||
|
|
b.Property(x => x.FromStatus).HasConversion<EnumCodeConverter<ProposalStatus>>().HasMaxLength(30);
|
||
|
|
b.Property(x => x.ToStatus).HasConversion<EnumCodeConverter<ProposalStatus>>().HasMaxLength(30);
|
||
|
|
b.Property(x => x.Note).HasColumnType("text");
|
||
|
|
b.HasOne(x => x.Proposal).WithMany().HasForeignKey(x => x.ProposalId);
|
||
|
|
b.HasOne<User>().WithMany().HasForeignKey(x => x.ActorId);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed class ProposalVoteConfiguration : IEntityTypeConfiguration<ProposalVote>
|
||
|
|
{
|
||
|
|
public void Configure(EntityTypeBuilder<ProposalVote> b)
|
||
|
|
{
|
||
|
|
b.ToTable("proposal_vote");
|
||
|
|
b.HasKey(x => new { x.ProposalId, x.UserId });
|
||
|
|
b.Property(x => x.Value).HasColumnType("tinyint");
|
||
|
|
b.HasOne<Proposal>().WithMany().HasForeignKey(x => x.ProposalId);
|
||
|
|
b.HasOne<User>().WithMany().HasForeignKey(x => x.UserId);
|
||
|
|
}
|
||
|
|
}
|