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

namespace SportsDivision.Infrastructure.Data.Configurations;

public class EventLevelConfiguration : IEntityTypeConfiguration<EventLevel>
{
    public void Configure(EntityTypeBuilder<EventLevel> builder)
    {
        builder.HasKey(e => e.EventLevelId);
        builder.Property(e => e.Name).IsRequired().HasMaxLength(100);
        builder.Property(e => e.Sex).HasConversion<string>().HasMaxLength(10);
        builder.Property(e => e.SchoolLevel).HasConversion<string>().HasMaxLength(20);
        builder.HasIndex(e => new { e.Name, e.Sex }).IsUnique();
    }
}
