Add proposal workflow and voting API
This commit is contained in:
1 parent
9ca23a2c15
commit
1ff4a0a814
17 files changed
+796
-83
No files matched your search
@@ -0,0 +1,46 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user