using CMSMicroservice.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
//تنظیمات گالری تصاویر محصول
public class ProductGalleriesConfiguration : IEntityTypeConfiguration<ProductGallery>
{
    public void Configure(EntityTypeBuilder<ProductGallery> builder)
    {
        builder.HasQueryFilter(p => !p.IsDeleted);
        builder.Ignore(entity => entity.DomainEvents);
        builder.HasKey(entity => entity.Id);
        builder.Property(entity => entity.Id).UseIdentityColumn();
        builder
            .HasOne(entity => entity.ProductImage)
            .WithMany(entity => entity.ProductGalleries)
            .HasForeignKey(entity => entity.ProductImageId)
            .IsRequired(true);
        builder
            .HasOne(entity => entity.Product)
            .WithMany(entity => entity.ProductGalleries)
            .HasForeignKey(entity => entity.ProductId)
            .IsRequired(true);

    }
}
