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

namespace Lada.Framework.Data.Mappings.EntityMappings.Crm
{
    public class CustomerMap : IEntityMappingConfiguration<Customer>
    {
        public void Map(EntityTypeBuilder<Customer> builder)
        {
            builder.HasKey(a => a.Id);
            builder.HasMany(c => c.Addresses).WithOne(a => a.Customer).HasForeignKey(a => a.CustomerId);
            builder.HasMany(c => c.Orders).WithOne(a => a.Customer).HasForeignKey(a => a.CustomerId);
            builder.HasMany(c => c.Prices).WithOne(p => p.Customer).HasForeignKey(p => p.CustomerId);
            builder.HasMany(c => c.VatInfos).WithOne(v => v.Customer).HasForeignKey(v => v.CustomerId);
            builder.ToTable("Customer");
        }
    }
}
