using Lada.Framework.Data.Domains.Finance.Wallets;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Lada.Framework.Data.Mappings.EntityMappings.Finances.Wallets
{
    public class TransactionOrderMap : IEntityMappingConfiguration<TransactionOrder>
    {
        public void Map(EntityTypeBuilder<TransactionOrder> builder)
        {
            builder.HasKey(to => new { to.TransactionId, to.OrderId });

            builder.HasOne(to => to.Transaction)
                    .WithMany(t => t.TransactionOrders)
                    .HasForeignKey(to => to.TransactionId);

            builder.HasOne(to => to.Order)
                    .WithMany(o => o.TransactionOrders)
                    .HasForeignKey(to => to.OrderId);
            builder.ToTable("TransactionOrder");
        }

        
    }
}
