using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SolutionErp.Domain.Contracts;

namespace SolutionErp.Infrastructure.Persistence.Configurations;

public class WorkflowTypeAssignmentConfiguration : IEntityTypeConfiguration<WorkflowTypeAssignment>
{
    public void Configure(EntityTypeBuilder<WorkflowTypeAssignment> e)
    {
        e.ToTable("WorkflowTypeAssignments");
        e.HasKey(x => x.Id);
        e.Property(x => x.ContractType).HasConversion<int>();
        e.Property(x => x.PolicyName).HasMaxLength(50).IsRequired();
        e.HasIndex(x => x.ContractType).IsUnique();
    }
}
