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 UserProductMapping relation
    /// </summary>
    public static void BuildTransferToProductMappingToRelation(this EntityTypeBuilder<Transfer> modelBuilder, bool autoInclude)
    {
        modelBuilder
            .HasOne(x => x.UserProductMapping)
            .WithMany(x => x.Transfers)
            .HasForeignKey(x => x.UserProductMappingId);

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