using CMSMicroservice.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; //پکیج public class PackageConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasQueryFilter(p => !p.IsDeleted); builder.Ignore(entity => entity.DomainEvents); builder.HasKey(entity => entity.Id); builder.Property(entity => entity.Id).UseIdentityColumn(); builder.Property(entity => entity.Title).IsRequired(true); builder.Property(entity => entity.Description).IsRequired(true); builder.Property(entity => entity.ImagePath).IsRequired(true); builder.Property(entity => entity.Price).IsRequired(true); // فیلدهای جدید پکیج builder.Property(entity => entity.SortOrder).IsRequired().HasDefaultValue(0); builder.Property(entity => entity.IsActive).IsRequired().HasDefaultValue(true); builder.Property(entity => entity.IsBasePackage).IsRequired().HasDefaultValue(false); builder.Property(entity => entity.SupportsDayaPurchase).IsRequired().HasDefaultValue(false); builder.Property(entity => entity.SupportsDirectPurchase).IsRequired().HasDefaultValue(true); builder.Property(entity => entity.ActivationFee).IsRequired().HasDefaultValue(0L); builder.Property(entity => entity.DiscountMultiplier).IsRequired().HasDefaultValue(2.0m) .HasPrecision(18, 4); builder.Property(entity => entity.MagicWalletMultiplier).IsRequired().HasDefaultValue(2.5m) .HasPrecision(18, 4); builder.Property(entity => entity.MaxBalancesPerLeg).IsRequired().HasDefaultValue(300); builder.Property(entity => entity.MaxNetworkLevel).IsRequired().HasDefaultValue(15); builder.Property(entity => entity.MagicWalletMaxDeposit).IsRequired().HasDefaultValue(1_000_000_000L); builder.Property(entity => entity.MagicWalletMaxCredit).IsRequired().HasDefaultValue(2_500_000_000L); // Indexes builder.HasIndex(e => e.IsActive) .HasDatabaseName("IX_Package_IsActive"); builder.HasIndex(e => e.SortOrder) .HasDatabaseName("IX_Package_SortOrder"); } }