using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
///
/// استخر کارمزد هفتگی
///
public class WeeklyCommissionPoolConfiguration : 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.WeekNumber).IsRequired().HasMaxLength(20);
builder.Property(entity => entity.TotalPoolAmount).IsRequired();
builder.Property(entity => entity.TotalBalances).IsRequired();
builder.Property(entity => entity.ValuePerBalance).IsRequired();
builder.Property(entity => entity.IsCalculated).IsRequired();
builder.Property(entity => entity.CalculatedAt).IsRequired(false);
// Index یونیک برای WeekNumber
builder.HasIndex(e => e.WeekNumber)
.IsUnique()
.HasDatabaseName("IX_WeeklyCommissionPool_WeekNumber");
// Index برای IsCalculated
builder.HasIndex(e => e.IsCalculated)
.HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated");
}
}