using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SportsDivision.Domain.Entities;

namespace SportsDivision.Infrastructure.Data.Configurations;

public class ScoringConstantConfiguration : IEntityTypeConfiguration<ScoringConstant>
{
    public void Configure(EntityTypeBuilder<ScoringConstant> builder)
    {
        builder.HasKey(s => s.ScoringConstantId);
        builder.Property(s => s.A).HasPrecision(18, 6);
        builder.Property(s => s.B).HasPrecision(18, 6);
        builder.Property(s => s.C).HasPrecision(18, 6);
        builder.Property(s => s.Unit).IsRequired().HasMaxLength(20);
        builder.HasOne(s => s.Event).WithMany(e => e.ScoringConstants).HasForeignKey(s => s.EventId).OnDelete(DeleteBehavior.Cascade);
    }
}
