using Lada.Framework.Data.Domains.Hr;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Lada.Framework.Data.Mappings.EntityMappings.Hr
{
    public class AttendanceMediaMap : IEntityMappingConfiguration<AttendanceMedia>
    {
        public void Map(EntityTypeBuilder<AttendanceMedia> builder)
        {
            builder.HasKey(am => new { am.AttendanceId, am.MediaId });

            // Quan hệ Attendance - AttendanceMedia (1-nhiều)
            builder.HasOne(am => am.Attendance)
                    .WithMany(a => a.AttendanceMedias)
                    .HasForeignKey(am => am.AttendanceId);

            // Quan hệ Media - AttendanceMedia (1-nhiều)
            builder.HasOne(am => am.Media)
                    .WithMany()
                    .HasForeignKey(am => am.MediaId);

            builder.ToTable("AttendanceMedia");
        }
    }
}
