using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Database.ModelBuilders.Users;
using TIAM.Entities.Transfers;
using TIAM.Entities.Users;

namespace TIAM.Database.ModelBuilders.Transfers;

public static class TransferEntityTypeBuilderExtensions
{
    /// <summary>
    /// Mapping Transfer to Drivers relation
    /// </summary>
    public static void BuildTransferToDriversMappingToRelation(this EntityTypeBuilder<Transfer> modelBuilder, bool autoInclude)
    {
        modelBuilder
            .HasMany(x => x.TransferToDrivers)
            .WithOne(x => x.Transfer)
            .HasForeignKey(x=>x.TransferId)
            .OnDelete(DeleteBehavior.Cascade);

        modelBuilder.Navigation(e => e.TransferToDrivers).AutoInclude(autoInclude);
    }

}