feat: Add EF configurations and migration for network-club system

EF Core Configurations (11 files):
- SystemConfigurationConfiguration with Scope+Key composite index
- ClubMembershipConfiguration with one-to-one User relationship
- ClubFeatureConfiguration with IsActive+SortOrder index
- UserClubFeatureConfiguration with composite unique index
- NetworkWeeklyBalanceConfiguration with UserId+WeekNumber index
- WeeklyCommissionPoolConfiguration with unique WeekNumber
- UserCommissionPayoutConfiguration with multiple indexes
- ClubMembershipHistoryConfiguration for audit trail
- NetworkMembershipHistoryConfiguration for audit trail
- CommissionPayoutHistoryConfiguration for audit trail
- SystemConfigurationHistoryConfiguration for audit trail

Configuration Updates:
- UserConfiguration: Add NetworkParentId, LegPosition with indexes
- UserWalletConfiguration: Add DiscountBalance field
- ProductsConfiguration: Add IsClubExclusive, ClubDiscountPercent with index

Infrastructure Updates:
- ApplicationDbContext: Add 11 new DbSets for network-club entities
- GlobalUsings: Add Domain entity namespaces

Migration:
- AddNetworkClubSystemV2: Complete database schema for network-club system
This commit is contained in:
masoodafar-web
2025-11-29 03:52:46 +03:30
parent d20dc86d2f
commit 04bc593184
19 changed files with 4246 additions and 2 deletions

View File

@@ -1,4 +1,13 @@
global using System.Threading;
global using System.Threading.Tasks;
global using System;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;
// Domain Usings
global using CMSMicroservice.Domain.Entities;
global using CMSMicroservice.Domain.Entities.Club;
global using CMSMicroservice.Domain.Entities.Network;
global using CMSMicroservice.Domain.Entities.Commission;
global using CMSMicroservice.Domain.Entities.Configuration;
global using CMSMicroservice.Domain.Entities.History;
global using CMSMicroservice.Domain.Enums;

View File

@@ -60,4 +60,25 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
public DbSet<UserOrder> UserOrders => Set<UserOrder>();
public DbSet<UserWallet> UserWallets => Set<UserWallet>();
public DbSet<UserWalletChangeLog> UserWalletChangeLogs => Set<UserWalletChangeLog>();
// ============= Network Club System DbSets =============
// Configuration
public DbSet<SystemConfiguration> SystemConfigurations => Set<SystemConfiguration>();
public DbSet<SystemConfigurationHistory> SystemConfigurationHistories => Set<SystemConfigurationHistory>();
// Club Management
public DbSet<ClubMembership> ClubMemberships => Set<ClubMembership>();
public DbSet<ClubFeature> ClubFeatures => Set<ClubFeature>();
public DbSet<UserClubFeature> UserClubFeatures => Set<UserClubFeature>();
public DbSet<ClubMembershipHistory> ClubMembershipHistories => Set<ClubMembershipHistory>();
// Network
public DbSet<NetworkWeeklyBalance> NetworkWeeklyBalances => Set<NetworkWeeklyBalance>();
public DbSet<NetworkMembershipHistory> NetworkMembershipHistories => Set<NetworkMembershipHistory>();
// Commission
public DbSet<WeeklyCommissionPool> WeeklyCommissionPools => Set<WeeklyCommissionPool>();
public DbSet<UserCommissionPayout> UserCommissionPayouts => Set<UserCommissionPayout>();
public DbSet<CommissionPayoutHistory> CommissionPayoutHistories => Set<CommissionPayoutHistory>();
}

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// فیچرهای باشگاه مشتریان
/// </summary>
public class ClubFeatureConfiguration : IEntityTypeConfiguration<ClubFeature>
{
public void Configure(EntityTypeBuilder<ClubFeature> 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().HasMaxLength(200);
builder.Property(entity => entity.Description).IsRequired(false).HasMaxLength(1000);
builder.Property(entity => entity.IsActive).IsRequired();
builder.Property(entity => entity.RequiredPoints).IsRequired(false);
builder.Property(entity => entity.SortOrder).IsRequired();
// Index برای IsActive و SortOrder
builder.HasIndex(e => new { e.IsActive, e.SortOrder })
.HasDatabaseName("IX_ClubFeature_IsActive_SortOrder");
}
}

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// عضویت باشگاه مشتریان
/// </summary>
public class ClubMembershipConfiguration : IEntityTypeConfiguration<ClubMembership>
{
public void Configure(EntityTypeBuilder<ClubMembership> 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.UserId).IsRequired();
builder.Property(entity => entity.IsActive).IsRequired();
builder.Property(entity => entity.ActivatedAt).IsRequired(false);
builder.Property(entity => entity.InitialContribution).IsRequired();
builder.Property(entity => entity.TotalEarned).IsRequired();
// رابطه یک‌به‌یک با User
builder.HasOne(entity => entity.User)
.WithOne(u => u.ClubMembership)
.HasForeignKey<ClubMembership>(entity => entity.UserId)
.OnDelete(DeleteBehavior.Restrict);
// Index برای UserId (یونیک برای یک‌به‌یک)
builder.HasIndex(e => e.UserId)
.IsUnique()
.HasDatabaseName("IX_ClubMembership_UserId");
// Index برای IsActive
builder.HasIndex(e => e.IsActive)
.HasDatabaseName("IX_ClubMembership_IsActive");
}
}

View File

@@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// تاریخچه تغییرات عضویت باشگاه
/// </summary>
public class ClubMembershipHistoryConfiguration : IEntityTypeConfiguration<ClubMembershipHistory>
{
public void Configure(EntityTypeBuilder<ClubMembershipHistory> 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.ClubMembershipId).IsRequired();
builder.Property(entity => entity.UserId).IsRequired();
builder.Property(entity => entity.OldIsActive).IsRequired();
builder.Property(entity => entity.NewIsActive).IsRequired();
builder.Property(entity => entity.OldInitialContribution).IsRequired(false);
builder.Property(entity => entity.NewInitialContribution).IsRequired(false);
builder.Property(entity => entity.Action).IsRequired();
builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500);
builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100);
// رابطه با ClubMembership
builder.HasOne(entity => entity.ClubMembership)
.WithMany(cm => cm.ClubMembershipHistories)
.HasForeignKey(entity => entity.ClubMembershipId)
.OnDelete(DeleteBehavior.Restrict);
// Index برای UserId و Created (برای تاریخچه)
builder.HasIndex(e => new { e.UserId, e.Created })
.HasDatabaseName("IX_ClubMembershipHistory_UserId_Created");
// Index برای ClubMembershipId
builder.HasIndex(e => e.ClubMembershipId)
.HasDatabaseName("IX_ClubMembershipHistory_ClubMembershipId");
// Index برای Action
builder.HasIndex(e => e.Action)
.HasDatabaseName("IX_ClubMembershipHistory_Action");
}
}

View File

@@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// تاریخچه تغییرات پرداخت کمیسیون
/// </summary>
public class CommissionPayoutHistoryConfiguration : IEntityTypeConfiguration<CommissionPayoutHistory>
{
public void Configure(EntityTypeBuilder<CommissionPayoutHistory> 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.UserCommissionPayoutId).IsRequired();
builder.Property(entity => entity.UserId).IsRequired();
builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20);
builder.Property(entity => entity.AmountBefore).IsRequired();
builder.Property(entity => entity.AmountAfter).IsRequired();
builder.Property(entity => entity.OldStatus).IsRequired();
builder.Property(entity => entity.NewStatus).IsRequired();
builder.Property(entity => entity.Action).IsRequired();
builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100);
builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500);
// رابطه با UserCommissionPayout
builder.HasOne(entity => entity.UserCommissionPayout)
.WithMany(ucp => ucp.CommissionPayoutHistories)
.HasForeignKey(entity => entity.UserCommissionPayoutId)
.OnDelete(DeleteBehavior.Restrict);
// Index برای UserId و Created
builder.HasIndex(e => new { e.UserId, e.Created })
.HasDatabaseName("IX_CommissionPayoutHistory_UserId_Created");
// Index برای UserCommissionPayoutId
builder.HasIndex(e => e.UserCommissionPayoutId)
.HasDatabaseName("IX_CommissionPayoutHistory_PayoutId");
// Index برای WeekNumber
builder.HasIndex(e => e.WeekNumber)
.HasDatabaseName("IX_CommissionPayoutHistory_WeekNumber");
// Index برای Action
builder.HasIndex(e => e.Action)
.HasDatabaseName("IX_CommissionPayoutHistory_Action");
}
}

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// تاریخچه جابجایی در شبکه باینری
/// </summary>
public class NetworkMembershipHistoryConfiguration : IEntityTypeConfiguration<NetworkMembershipHistory>
{
public void Configure(EntityTypeBuilder<NetworkMembershipHistory> 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.UserId).IsRequired();
builder.Property(entity => entity.OldParentId).IsRequired(false);
builder.Property(entity => entity.NewParentId).IsRequired(false);
builder.Property(entity => entity.OldLegPosition).IsRequired(false);
builder.Property(entity => entity.NewLegPosition).IsRequired(false);
builder.Property(entity => entity.Action).IsRequired();
builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500);
builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100);
// Index برای UserId و Created
builder.HasIndex(e => new { e.UserId, e.Created })
.HasDatabaseName("IX_NetworkMembershipHistory_UserId_Created");
// Index برای Action
builder.HasIndex(e => e.Action)
.HasDatabaseName("IX_NetworkMembershipHistory_Action");
}
}

View File

@@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// تعادل‌های هفتگی شبکه باینری
/// </summary>
public class NetworkWeeklyBalanceConfiguration : IEntityTypeConfiguration<NetworkWeeklyBalance>
{
public void Configure(EntityTypeBuilder<NetworkWeeklyBalance> 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.UserId).IsRequired();
builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20);
builder.Property(entity => entity.LeftLegBalances).IsRequired();
builder.Property(entity => entity.RightLegBalances).IsRequired();
builder.Property(entity => entity.TotalBalances).IsRequired();
builder.Property(entity => entity.WeeklyPoolContribution).IsRequired();
builder.Property(entity => entity.CalculatedAt).IsRequired(false);
builder.Property(entity => entity.IsExpired).IsRequired();
// رابطه با User
builder.HasOne(entity => entity.User)
.WithMany(u => u.NetworkWeeklyBalances)
.HasForeignKey(entity => entity.UserId)
.OnDelete(DeleteBehavior.Restrict);
// Composite Index برای UserId و WeekNumber
builder.HasIndex(e => new { e.UserId, e.WeekNumber })
.IsUnique()
.HasDatabaseName("IX_NetworkWeeklyBalance_UserId_WeekNumber");
// Index برای WeekNumber
builder.HasIndex(e => e.WeekNumber)
.HasDatabaseName("IX_NetworkWeeklyBalance_WeekNumber");
// Index برای IsExpired
builder.HasIndex(e => e.IsExpired)
.HasDatabaseName("IX_NetworkWeeklyBalance_IsExpired");
}
}

View File

@@ -24,5 +24,13 @@ public class ProductsConfiguration : IEntityTypeConfiguration<Products>
builder.Property(entity => entity.ViewCount).IsRequired(true);
builder.Property(entity => entity.RemainingCount).IsRequired(true);
// ============= Club Shop Fields =============
builder.Property(entity => entity.IsClubExclusive).IsRequired(true);
builder.Property(entity => entity.ClubDiscountPercent).IsRequired(true);
// Index برای IsClubExclusive
builder.HasIndex(e => e.IsClubExclusive)
.HasDatabaseName("IX_Products_IsClubExclusive");
}
}

View File

@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// تنظیمات پویای سیستم
/// </summary>
public class SystemConfigurationConfiguration : IEntityTypeConfiguration<SystemConfiguration>
{
public void Configure(EntityTypeBuilder<SystemConfiguration> 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.Scope).IsRequired();
builder.Property(entity => entity.Key).IsRequired().HasMaxLength(200);
builder.Property(entity => entity.Value).IsRequired().HasMaxLength(1000);
builder.Property(entity => entity.DataType).IsRequired(false).HasMaxLength(50);
builder.Property(entity => entity.Description).IsRequired(false).HasMaxLength(500);
builder.Property(entity => entity.IsActive).IsRequired();
// Composite Index برای جستجوی سریع
builder.HasIndex(e => new { e.Scope, e.Key })
.IsUnique()
.HasDatabaseName("IX_SystemConfiguration_Scope_Key");
// Index برای IsActive
builder.HasIndex(e => e.IsActive)
.HasDatabaseName("IX_SystemConfiguration_IsActive");
}
}

View File

@@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// تاریخچه تغییرات تنظیمات سیستم
/// </summary>
public class SystemConfigurationHistoryConfiguration : IEntityTypeConfiguration<SystemConfigurationHistory>
{
public void Configure(EntityTypeBuilder<SystemConfigurationHistory> 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.ConfigurationId).IsRequired();
builder.Property(entity => entity.Scope).IsRequired();
builder.Property(entity => entity.Key).IsRequired().HasMaxLength(200);
builder.Property(entity => entity.OldValue).IsRequired().HasMaxLength(1000);
builder.Property(entity => entity.NewValue).IsRequired().HasMaxLength(1000);
builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500);
builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100);
// رابطه با SystemConfiguration
builder.HasOne(entity => entity.Configuration)
.WithMany(sc => sc.SystemConfigurationHistories)
.HasForeignKey(entity => entity.ConfigurationId)
.OnDelete(DeleteBehavior.Restrict);
// Index برای ConfigurationId و Created
builder.HasIndex(e => new { e.ConfigurationId, e.Created })
.HasDatabaseName("IX_SystemConfigurationHistory_ConfigId_Created");
// Index برای Scope و Key
builder.HasIndex(e => new { e.Scope, e.Key })
.HasDatabaseName("IX_SystemConfigurationHistory_Scope_Key");
}
}

View File

@@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// جدول واسط کاربر-فیچر
/// </summary>
public class UserClubFeatureConfiguration : IEntityTypeConfiguration<UserClubFeature>
{
public void Configure(EntityTypeBuilder<UserClubFeature> 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.UserId).IsRequired();
builder.Property(entity => entity.ClubMembershipId).IsRequired();
builder.Property(entity => entity.ClubFeatureId).IsRequired();
builder.Property(entity => entity.GrantedAt).IsRequired();
builder.Property(entity => entity.Notes).IsRequired(false).HasMaxLength(500);
// رابطه با User
builder.HasOne(entity => entity.User)
.WithMany(u => u.UserClubFeatures)
.HasForeignKey(entity => entity.UserId)
.OnDelete(DeleteBehavior.Restrict);
// رابطه با ClubMembership
builder.HasOne(entity => entity.ClubMembership)
.WithMany(cm => cm.UserClubFeatures)
.HasForeignKey(entity => entity.ClubMembershipId)
.OnDelete(DeleteBehavior.Restrict);
// رابطه با ClubFeature
builder.HasOne(entity => entity.ClubFeature)
.WithMany(cf => cf.UserClubFeatures)
.HasForeignKey(entity => entity.ClubFeatureId)
.OnDelete(DeleteBehavior.Restrict);
// Composite Index برای جلوگیری از تکرار
builder.HasIndex(e => new { e.UserId, e.ClubFeatureId })
.IsUnique()
.HasDatabaseName("IX_UserClubFeature_UserId_ClubFeatureId");
// Index برای ClubMembershipId
builder.HasIndex(e => e.ClubMembershipId)
.HasDatabaseName("IX_UserClubFeature_ClubMembershipId");
}
}

View File

@@ -0,0 +1,60 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// پرداخت کمیسیون به کاربران
/// </summary>
public class UserCommissionPayoutConfiguration : IEntityTypeConfiguration<UserCommissionPayout>
{
public void Configure(EntityTypeBuilder<UserCommissionPayout> 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.UserId).IsRequired();
builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20);
builder.Property(entity => entity.WeeklyPoolId).IsRequired();
builder.Property(entity => entity.BalancesEarned).IsRequired();
builder.Property(entity => entity.ValuePerBalance).IsRequired();
builder.Property(entity => entity.TotalAmount).IsRequired();
builder.Property(entity => entity.Status).IsRequired();
builder.Property(entity => entity.PaidAt).IsRequired(false);
builder.Property(entity => entity.WithdrawalMethod).IsRequired(false);
builder.Property(entity => entity.IbanNumber).IsRequired(false).HasMaxLength(26);
builder.Property(entity => entity.WithdrawnAt).IsRequired(false);
// رابطه با User
builder.HasOne(entity => entity.User)
.WithMany(u => u.CommissionPayouts)
.HasForeignKey(entity => entity.UserId)
.OnDelete(DeleteBehavior.Restrict);
// رابطه با WeeklyCommissionPool
builder.HasOne(entity => entity.WeeklyPool)
.WithMany(wp => wp.UserCommissionPayouts)
.HasForeignKey(entity => entity.WeeklyPoolId)
.OnDelete(DeleteBehavior.Restrict);
// Composite Index برای UserId و WeekNumber
builder.HasIndex(e => new { e.UserId, e.WeekNumber })
.IsUnique()
.HasDatabaseName("IX_UserCommissionPayout_UserId_WeekNumber");
// Index برای WeeklyPoolId
builder.HasIndex(e => e.WeeklyPoolId)
.HasDatabaseName("IX_UserCommissionPayout_WeeklyPoolId");
// Index برای Status
builder.HasIndex(e => e.Status)
.HasDatabaseName("IX_UserCommissionPayout_Status");
// Index برای WeekNumber
builder.HasIndex(e => e.WeekNumber)
.HasDatabaseName("IX_UserCommissionPayout_WeekNumber");
}
}

View File

@@ -32,5 +32,26 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
builder.Property(entity => entity.BirthDate).IsRequired(false);
builder.Property(entity => entity.HashPassword).IsRequired(false);
// ============= Network Club System Fields =============
builder.Property(entity => entity.NetworkParentId).IsRequired(false);
builder.Property(entity => entity.LegPosition).IsRequired(false);
// رابطه با والد در شبکه باینری
builder
.HasOne(entity => entity.NetworkParent)
.WithMany(entity => entity.NetworkChildren)
.HasForeignKey(entity => entity.NetworkParentId)
.IsRequired(false)
.OnDelete(DeleteBehavior.Restrict);
// Index برای NetworkParentId
builder.HasIndex(e => e.NetworkParentId)
.HasDatabaseName("IX_User_NetworkParentId");
// Index برای LegPosition
builder.HasIndex(e => e.LegPosition)
.HasDatabaseName("IX_User_LegPosition");
}
}

View File

@@ -18,6 +18,7 @@ public class UserWalletConfiguration : IEntityTypeConfiguration<UserWallet>
.IsRequired(true);
builder.Property(entity => entity.Balance).IsRequired(true);
builder.Property(entity => entity.NetworkBalance).IsRequired(true);
builder.Property(entity => entity.DiscountBalance).IsRequired(true);
}
}

View File

@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
/// <summary>
/// استخر کارمزد هفتگی
/// </summary>
public class WeeklyCommissionPoolConfiguration : IEntityTypeConfiguration<WeeklyCommissionPool>
{
public void Configure(EntityTypeBuilder<WeeklyCommissionPool> 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");
}
}

View File

@@ -0,0 +1,696 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddNetworkClubSystemV2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "DiscountBalance",
schema: "CMS",
table: "UserWallets",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<int>(
name: "LegPosition",
schema: "CMS",
table: "Users",
type: "int",
nullable: true);
migrationBuilder.AddColumn<long>(
name: "NetworkParentId",
schema: "CMS",
table: "Users",
type: "bigint",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ClubDiscountPercent",
schema: "CMS",
table: "Productss",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<bool>(
name: "IsClubExclusive",
schema: "CMS",
table: "Productss",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "ClubFeatures",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
RequiredPoints = table.Column<int>(type: "int", nullable: true),
SortOrder = table.Column<int>(type: "int", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClubFeatures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ClubMemberships",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<long>(type: "bigint", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
ActivatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
InitialContribution = table.Column<long>(type: "bigint", nullable: false),
TotalEarned = table.Column<long>(type: "bigint", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClubMemberships", x => x.Id);
table.ForeignKey(
name: "FK_ClubMemberships_Users_UserId",
column: x => x.UserId,
principalSchema: "CMS",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "NetworkMembershipHistories",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<long>(type: "bigint", nullable: false),
OldParentId = table.Column<long>(type: "bigint", nullable: true),
NewParentId = table.Column<long>(type: "bigint", nullable: true),
OldLegPosition = table.Column<int>(type: "int", nullable: true),
NewLegPosition = table.Column<int>(type: "int", nullable: true),
Action = table.Column<int>(type: "int", nullable: false),
Reason = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
PerformedBy = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NetworkMembershipHistories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "NetworkWeeklyBalances",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<long>(type: "bigint", nullable: false),
WeekNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
LeftLegBalances = table.Column<int>(type: "int", nullable: false),
RightLegBalances = table.Column<int>(type: "int", nullable: false),
TotalBalances = table.Column<int>(type: "int", nullable: false),
WeeklyPoolContribution = table.Column<long>(type: "bigint", nullable: false),
CalculatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
IsExpired = table.Column<bool>(type: "bit", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NetworkWeeklyBalances", x => x.Id);
table.ForeignKey(
name: "FK_NetworkWeeklyBalances_Users_UserId",
column: x => x.UserId,
principalSchema: "CMS",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "SystemConfigurations",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Scope = table.Column<int>(type: "int", nullable: false),
Key = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
Value = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
DataType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SystemConfigurations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "WeeklyCommissionPools",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WeekNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
TotalPoolAmount = table.Column<long>(type: "bigint", nullable: false),
TotalBalances = table.Column<int>(type: "int", nullable: false),
ValuePerBalance = table.Column<long>(type: "bigint", nullable: false),
IsCalculated = table.Column<bool>(type: "bit", nullable: false),
CalculatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WeeklyCommissionPools", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ClubMembershipHistories",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClubMembershipId = table.Column<long>(type: "bigint", nullable: false),
UserId = table.Column<long>(type: "bigint", nullable: false),
OldIsActive = table.Column<bool>(type: "bit", nullable: false),
NewIsActive = table.Column<bool>(type: "bit", nullable: false),
OldInitialContribution = table.Column<long>(type: "bigint", nullable: true),
NewInitialContribution = table.Column<long>(type: "bigint", nullable: true),
Action = table.Column<int>(type: "int", nullable: false),
Reason = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
PerformedBy = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClubMembershipHistories", x => x.Id);
table.ForeignKey(
name: "FK_ClubMembershipHistories_ClubMemberships_ClubMembershipId",
column: x => x.ClubMembershipId,
principalSchema: "CMS",
principalTable: "ClubMemberships",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserClubFeatures",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<long>(type: "bigint", nullable: false),
ClubMembershipId = table.Column<long>(type: "bigint", nullable: false),
ClubFeatureId = table.Column<long>(type: "bigint", nullable: false),
GrantedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
Notes = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserClubFeatures", x => x.Id);
table.ForeignKey(
name: "FK_UserClubFeatures_ClubFeatures_ClubFeatureId",
column: x => x.ClubFeatureId,
principalSchema: "CMS",
principalTable: "ClubFeatures",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_UserClubFeatures_ClubMemberships_ClubMembershipId",
column: x => x.ClubMembershipId,
principalSchema: "CMS",
principalTable: "ClubMemberships",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_UserClubFeatures_Users_UserId",
column: x => x.UserId,
principalSchema: "CMS",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "SystemConfigurationHistories",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ConfigurationId = table.Column<long>(type: "bigint", nullable: false),
Scope = table.Column<int>(type: "int", nullable: false),
Key = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
OldValue = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
NewValue = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
Reason = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
PerformedBy = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SystemConfigurationHistories", x => x.Id);
table.ForeignKey(
name: "FK_SystemConfigurationHistories_SystemConfigurations_ConfigurationId",
column: x => x.ConfigurationId,
principalSchema: "CMS",
principalTable: "SystemConfigurations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserCommissionPayouts",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<long>(type: "bigint", nullable: false),
WeekNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
WeeklyPoolId = table.Column<long>(type: "bigint", nullable: false),
BalancesEarned = table.Column<int>(type: "int", nullable: false),
ValuePerBalance = table.Column<long>(type: "bigint", nullable: false),
TotalAmount = table.Column<long>(type: "bigint", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
PaidAt = table.Column<DateTime>(type: "datetime2", nullable: true),
WithdrawalMethod = table.Column<int>(type: "int", nullable: true),
IbanNumber = table.Column<string>(type: "nvarchar(26)", maxLength: 26, nullable: true),
WithdrawnAt = table.Column<DateTime>(type: "datetime2", nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserCommissionPayouts", x => x.Id);
table.ForeignKey(
name: "FK_UserCommissionPayouts_Users_UserId",
column: x => x.UserId,
principalSchema: "CMS",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_UserCommissionPayouts_WeeklyCommissionPools_WeeklyPoolId",
column: x => x.WeeklyPoolId,
principalSchema: "CMS",
principalTable: "WeeklyCommissionPools",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CommissionPayoutHistories",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserCommissionPayoutId = table.Column<long>(type: "bigint", nullable: false),
UserId = table.Column<long>(type: "bigint", nullable: false),
WeekNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
AmountBefore = table.Column<long>(type: "bigint", nullable: false),
AmountAfter = table.Column<long>(type: "bigint", nullable: false),
OldStatus = table.Column<int>(type: "int", nullable: false),
NewStatus = table.Column<int>(type: "int", nullable: false),
Action = table.Column<int>(type: "int", nullable: false),
PerformedBy = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
Reason = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CommissionPayoutHistories", x => x.Id);
table.ForeignKey(
name: "FK_CommissionPayoutHistories_UserCommissionPayouts_UserCommissionPayoutId",
column: x => x.UserCommissionPayoutId,
principalSchema: "CMS",
principalTable: "UserCommissionPayouts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_User_LegPosition",
schema: "CMS",
table: "Users",
column: "LegPosition");
migrationBuilder.CreateIndex(
name: "IX_User_NetworkParentId",
schema: "CMS",
table: "Users",
column: "NetworkParentId");
migrationBuilder.CreateIndex(
name: "IX_Products_IsClubExclusive",
schema: "CMS",
table: "Productss",
column: "IsClubExclusive");
migrationBuilder.CreateIndex(
name: "IX_ClubFeature_IsActive_SortOrder",
schema: "CMS",
table: "ClubFeatures",
columns: new[] { "IsActive", "SortOrder" });
migrationBuilder.CreateIndex(
name: "IX_ClubMembershipHistory_Action",
schema: "CMS",
table: "ClubMembershipHistories",
column: "Action");
migrationBuilder.CreateIndex(
name: "IX_ClubMembershipHistory_ClubMembershipId",
schema: "CMS",
table: "ClubMembershipHistories",
column: "ClubMembershipId");
migrationBuilder.CreateIndex(
name: "IX_ClubMembershipHistory_UserId_Created",
schema: "CMS",
table: "ClubMembershipHistories",
columns: new[] { "UserId", "Created" });
migrationBuilder.CreateIndex(
name: "IX_ClubMembership_IsActive",
schema: "CMS",
table: "ClubMemberships",
column: "IsActive");
migrationBuilder.CreateIndex(
name: "IX_ClubMembership_UserId",
schema: "CMS",
table: "ClubMemberships",
column: "UserId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CommissionPayoutHistory_Action",
schema: "CMS",
table: "CommissionPayoutHistories",
column: "Action");
migrationBuilder.CreateIndex(
name: "IX_CommissionPayoutHistory_PayoutId",
schema: "CMS",
table: "CommissionPayoutHistories",
column: "UserCommissionPayoutId");
migrationBuilder.CreateIndex(
name: "IX_CommissionPayoutHistory_UserId_Created",
schema: "CMS",
table: "CommissionPayoutHistories",
columns: new[] { "UserId", "Created" });
migrationBuilder.CreateIndex(
name: "IX_CommissionPayoutHistory_WeekNumber",
schema: "CMS",
table: "CommissionPayoutHistories",
column: "WeekNumber");
migrationBuilder.CreateIndex(
name: "IX_NetworkMembershipHistory_Action",
schema: "CMS",
table: "NetworkMembershipHistories",
column: "Action");
migrationBuilder.CreateIndex(
name: "IX_NetworkMembershipHistory_UserId_Created",
schema: "CMS",
table: "NetworkMembershipHistories",
columns: new[] { "UserId", "Created" });
migrationBuilder.CreateIndex(
name: "IX_NetworkWeeklyBalance_IsExpired",
schema: "CMS",
table: "NetworkWeeklyBalances",
column: "IsExpired");
migrationBuilder.CreateIndex(
name: "IX_NetworkWeeklyBalance_UserId_WeekNumber",
schema: "CMS",
table: "NetworkWeeklyBalances",
columns: new[] { "UserId", "WeekNumber" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_NetworkWeeklyBalance_WeekNumber",
schema: "CMS",
table: "NetworkWeeklyBalances",
column: "WeekNumber");
migrationBuilder.CreateIndex(
name: "IX_SystemConfigurationHistory_ConfigId_Created",
schema: "CMS",
table: "SystemConfigurationHistories",
columns: new[] { "ConfigurationId", "Created" });
migrationBuilder.CreateIndex(
name: "IX_SystemConfigurationHistory_Scope_Key",
schema: "CMS",
table: "SystemConfigurationHistories",
columns: new[] { "Scope", "Key" });
migrationBuilder.CreateIndex(
name: "IX_SystemConfiguration_IsActive",
schema: "CMS",
table: "SystemConfigurations",
column: "IsActive");
migrationBuilder.CreateIndex(
name: "IX_SystemConfiguration_Scope_Key",
schema: "CMS",
table: "SystemConfigurations",
columns: new[] { "Scope", "Key" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserClubFeature_ClubMembershipId",
schema: "CMS",
table: "UserClubFeatures",
column: "ClubMembershipId");
migrationBuilder.CreateIndex(
name: "IX_UserClubFeature_UserId_ClubFeatureId",
schema: "CMS",
table: "UserClubFeatures",
columns: new[] { "UserId", "ClubFeatureId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserClubFeatures_ClubFeatureId",
schema: "CMS",
table: "UserClubFeatures",
column: "ClubFeatureId");
migrationBuilder.CreateIndex(
name: "IX_UserCommissionPayout_Status",
schema: "CMS",
table: "UserCommissionPayouts",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_UserCommissionPayout_UserId_WeekNumber",
schema: "CMS",
table: "UserCommissionPayouts",
columns: new[] { "UserId", "WeekNumber" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserCommissionPayout_WeeklyPoolId",
schema: "CMS",
table: "UserCommissionPayouts",
column: "WeeklyPoolId");
migrationBuilder.CreateIndex(
name: "IX_UserCommissionPayout_WeekNumber",
schema: "CMS",
table: "UserCommissionPayouts",
column: "WeekNumber");
migrationBuilder.CreateIndex(
name: "IX_WeeklyCommissionPool_IsCalculated",
schema: "CMS",
table: "WeeklyCommissionPools",
column: "IsCalculated");
migrationBuilder.CreateIndex(
name: "IX_WeeklyCommissionPool_WeekNumber",
schema: "CMS",
table: "WeeklyCommissionPools",
column: "WeekNumber",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_Users_Users_NetworkParentId",
schema: "CMS",
table: "Users",
column: "NetworkParentId",
principalSchema: "CMS",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Users_Users_NetworkParentId",
schema: "CMS",
table: "Users");
migrationBuilder.DropTable(
name: "ClubMembershipHistories",
schema: "CMS");
migrationBuilder.DropTable(
name: "CommissionPayoutHistories",
schema: "CMS");
migrationBuilder.DropTable(
name: "NetworkMembershipHistories",
schema: "CMS");
migrationBuilder.DropTable(
name: "NetworkWeeklyBalances",
schema: "CMS");
migrationBuilder.DropTable(
name: "SystemConfigurationHistories",
schema: "CMS");
migrationBuilder.DropTable(
name: "UserClubFeatures",
schema: "CMS");
migrationBuilder.DropTable(
name: "UserCommissionPayouts",
schema: "CMS");
migrationBuilder.DropTable(
name: "SystemConfigurations",
schema: "CMS");
migrationBuilder.DropTable(
name: "ClubFeatures",
schema: "CMS");
migrationBuilder.DropTable(
name: "ClubMemberships",
schema: "CMS");
migrationBuilder.DropTable(
name: "WeeklyCommissionPools",
schema: "CMS");
migrationBuilder.DropIndex(
name: "IX_User_LegPosition",
schema: "CMS",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_User_NetworkParentId",
schema: "CMS",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_Products_IsClubExclusive",
schema: "CMS",
table: "Productss");
migrationBuilder.DropColumn(
name: "DiscountBalance",
schema: "CMS",
table: "UserWallets");
migrationBuilder.DropColumn(
name: "LegPosition",
schema: "CMS",
table: "Users");
migrationBuilder.DropColumn(
name: "NetworkParentId",
schema: "CMS",
table: "Users");
migrationBuilder.DropColumn(
name: "ClubDiscountPercent",
schema: "CMS",
table: "Productss");
migrationBuilder.DropColumn(
name: "IsClubExclusive",
schema: "CMS",
table: "Productss");
}
}
}

View File

@@ -76,6 +76,349 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.ToTable("Categorys", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int?>("RequiredPoints")
.HasColumnType("int");
b.Property<int>("SortOrder")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.HasKey("Id");
b.HasIndex("IsActive", "SortOrder")
.HasDatabaseName("IX_ClubFeature_IsActive_SortOrder");
b.ToTable("ClubFeatures", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime?>("ActivatedAt")
.HasColumnType("datetime2");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<long>("InitialContribution")
.HasColumnType("bigint");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<long>("TotalEarned")
.HasColumnType("bigint");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("IsActive")
.HasDatabaseName("IX_ClubMembership_IsActive");
b.HasIndex("UserId")
.IsUnique()
.HasDatabaseName("IX_ClubMembership_UserId");
b.ToTable("ClubMemberships", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.UserClubFeature", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<long>("ClubFeatureId")
.HasColumnType("bigint");
b.Property<long>("ClubMembershipId")
.HasColumnType("bigint");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("GrantedAt")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("Notes")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ClubFeatureId");
b.HasIndex("ClubMembershipId")
.HasDatabaseName("IX_UserClubFeature_ClubMembershipId");
b.HasIndex("UserId", "ClubFeatureId")
.IsUnique()
.HasDatabaseName("IX_UserClubFeature_UserId_ClubFeatureId");
b.ToTable("UserClubFeatures", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<int>("BalancesEarned")
.HasColumnType("int");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("IbanNumber")
.HasMaxLength(26)
.HasColumnType("nvarchar(26)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("PaidAt")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<long>("TotalAmount")
.HasColumnType("bigint");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.Property<long>("ValuePerBalance")
.HasColumnType("bigint");
b.Property<string>("WeekNumber")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<long>("WeeklyPoolId")
.HasColumnType("bigint");
b.Property<int?>("WithdrawalMethod")
.HasColumnType("int");
b.Property<DateTime?>("WithdrawnAt")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("Status")
.HasDatabaseName("IX_UserCommissionPayout_Status");
b.HasIndex("WeekNumber")
.HasDatabaseName("IX_UserCommissionPayout_WeekNumber");
b.HasIndex("WeeklyPoolId")
.HasDatabaseName("IX_UserCommissionPayout_WeeklyPoolId");
b.HasIndex("UserId", "WeekNumber")
.IsUnique()
.HasDatabaseName("IX_UserCommissionPayout_UserId_WeekNumber");
b.ToTable("UserCommissionPayouts", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime?>("CalculatedAt")
.HasColumnType("datetime2");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsCalculated")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int>("TotalBalances")
.HasColumnType("int");
b.Property<long>("TotalPoolAmount")
.HasColumnType("bigint");
b.Property<long>("ValuePerBalance")
.HasColumnType("bigint");
b.Property<string>("WeekNumber")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.HasKey("Id");
b.HasIndex("IsCalculated")
.HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated");
b.HasIndex("WeekNumber")
.IsUnique()
.HasDatabaseName("IX_WeeklyCommissionPool_WeekNumber");
b.ToTable("WeeklyCommissionPools", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("DataType")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Description")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int>("Scope")
.HasColumnType("int");
b.Property<string>("Value")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.HasKey("Id");
b.HasIndex("IsActive")
.HasDatabaseName("IX_SystemConfiguration_IsActive");
b.HasIndex("Scope", "Key")
.IsUnique()
.HasDatabaseName("IX_SystemConfiguration_Scope_Key");
b.ToTable("SystemConfigurations", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Contract", b =>
{
b.Property<long>("Id")
@@ -172,6 +515,333 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.ToTable("FactorDetailss", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<int>("Action")
.HasColumnType("int");
b.Property<long>("ClubMembershipId")
.HasColumnType("bigint");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<long?>("NewInitialContribution")
.HasColumnType("bigint");
b.Property<bool>("NewIsActive")
.HasColumnType("bit");
b.Property<long?>("OldInitialContribution")
.HasColumnType("bigint");
b.Property<bool>("OldIsActive")
.HasColumnType("bit");
b.Property<string>("PerformedBy")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Reason")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("Action")
.HasDatabaseName("IX_ClubMembershipHistory_Action");
b.HasIndex("ClubMembershipId")
.HasDatabaseName("IX_ClubMembershipHistory_ClubMembershipId");
b.HasIndex("UserId", "Created")
.HasDatabaseName("IX_ClubMembershipHistory_UserId_Created");
b.ToTable("ClubMembershipHistories", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.CommissionPayoutHistory", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<int>("Action")
.HasColumnType("int");
b.Property<long>("AmountAfter")
.HasColumnType("bigint");
b.Property<long>("AmountBefore")
.HasColumnType("bigint");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int>("NewStatus")
.HasColumnType("int");
b.Property<int>("OldStatus")
.HasColumnType("int");
b.Property<string>("PerformedBy")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Reason")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<long>("UserCommissionPayoutId")
.HasColumnType("bigint");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.Property<string>("WeekNumber")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.HasKey("Id");
b.HasIndex("Action")
.HasDatabaseName("IX_CommissionPayoutHistory_Action");
b.HasIndex("UserCommissionPayoutId")
.HasDatabaseName("IX_CommissionPayoutHistory_PayoutId");
b.HasIndex("WeekNumber")
.HasDatabaseName("IX_CommissionPayoutHistory_WeekNumber");
b.HasIndex("UserId", "Created")
.HasDatabaseName("IX_CommissionPayoutHistory_UserId_Created");
b.ToTable("CommissionPayoutHistories", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.NetworkMembershipHistory", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<int>("Action")
.HasColumnType("int");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int?>("NewLegPosition")
.HasColumnType("int");
b.Property<long?>("NewParentId")
.HasColumnType("bigint");
b.Property<int?>("OldLegPosition")
.HasColumnType("int");
b.Property<long?>("OldParentId")
.HasColumnType("bigint");
b.Property<string>("PerformedBy")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Reason")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("Action")
.HasDatabaseName("IX_NetworkMembershipHistory_Action");
b.HasIndex("UserId", "Created")
.HasDatabaseName("IX_NetworkMembershipHistory_UserId_Created");
b.ToTable("NetworkMembershipHistories", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.SystemConfigurationHistory", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<long>("ConfigurationId")
.HasColumnType("bigint");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("NewValue")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("OldValue")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("PerformedBy")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Reason")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<int>("Scope")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ConfigurationId", "Created")
.HasDatabaseName("IX_SystemConfigurationHistory_ConfigId_Created");
b.HasIndex("Scope", "Key")
.HasDatabaseName("IX_SystemConfigurationHistory_Scope_Key");
b.ToTable("SystemConfigurationHistories", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime?>("CalculatedAt")
.HasColumnType("datetime2");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExpired")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int>("LeftLegBalances")
.HasColumnType("int");
b.Property<int>("RightLegBalances")
.HasColumnType("int");
b.Property<int>("TotalBalances")
.HasColumnType("int");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.Property<string>("WeekNumber")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<long>("WeeklyPoolContribution")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("IsExpired")
.HasDatabaseName("IX_NetworkWeeklyBalance_IsExpired");
b.HasIndex("WeekNumber")
.HasDatabaseName("IX_NetworkWeeklyBalance_WeekNumber");
b.HasIndex("UserId", "WeekNumber")
.IsUnique()
.HasDatabaseName("IX_NetworkWeeklyBalance_UserId_WeekNumber");
b.ToTable("NetworkWeeklyBalances", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b =>
{
b.Property<long>("Id")
@@ -350,6 +1020,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<int>("ClubDiscountPercent")
.HasColumnType("int");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
@@ -371,6 +1044,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsClubExclusive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
@@ -409,6 +1085,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.HasKey("Id");
b.HasIndex("IsClubExclusive")
.HasDatabaseName("IX_Products_IsClubExclusive");
b.ToTable("Productss", "CMS");
});
@@ -663,6 +1342,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<int?>("LegPosition")
.HasColumnType("int");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -673,6 +1355,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<string>("NationalCode")
.HasColumnType("nvarchar(max)");
b.Property<long?>("NetworkParentId")
.HasColumnType("bigint");
b.Property<long?>("ParentId")
.HasColumnType("bigint");
@@ -691,6 +1376,12 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.HasKey("Id");
b.HasIndex("LegPosition")
.HasDatabaseName("IX_User_LegPosition");
b.HasIndex("NetworkParentId")
.HasDatabaseName("IX_User_NetworkParentId");
b.HasIndex("ParentId");
b.ToTable("Users", "CMS");
@@ -958,6 +1649,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<long>("DiscountBalance")
.HasColumnType("bigint");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
@@ -1040,6 +1734,63 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("Parent");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithOne("ClubMembership")
.HasForeignKey("CMSMicroservice.Domain.Entities.Club.ClubMembership", "UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.UserClubFeature", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubFeature", "ClubFeature")
.WithMany("UserClubFeatures")
.HasForeignKey("ClubFeatureId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership")
.WithMany("UserClubFeatures")
.HasForeignKey("ClubMembershipId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithMany("UserClubFeatures")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("ClubFeature");
b.Navigation("ClubMembership");
b.Navigation("User");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithMany("CommissionPayouts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", "WeeklyPool")
.WithMany("UserCommissionPayouts")
.HasForeignKey("WeeklyPoolId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
b.Navigation("WeeklyPool");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order")
@@ -1059,6 +1810,50 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership")
.WithMany("ClubMembershipHistories")
.HasForeignKey("ClubMembershipId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("ClubMembership");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.CommissionPayoutHistory", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", "UserCommissionPayout")
.WithMany("CommissionPayoutHistories")
.HasForeignKey("UserCommissionPayoutId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("UserCommissionPayout");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.SystemConfigurationHistory", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", "Configuration")
.WithMany("SystemConfigurationHistories")
.HasForeignKey("ConfigurationId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Configuration");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithMany("NetworkWeeklyBalances")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product")
@@ -1118,10 +1913,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent")
.WithMany("NetworkChildren")
.HasForeignKey("NetworkParentId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("CMSMicroservice.Domain.Entities.User", "Parent")
.WithMany("Users")
.HasForeignKey("ParentId");
b.Navigation("NetworkParent");
b.Navigation("Parent");
});
@@ -1253,6 +2055,33 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("PruductCategorys");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b =>
{
b.Navigation("UserClubFeatures");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b =>
{
b.Navigation("ClubMembershipHistories");
b.Navigation("UserClubFeatures");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b =>
{
b.Navigation("CommissionPayoutHistories");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b =>
{
b.Navigation("UserCommissionPayouts");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b =>
{
b.Navigation("SystemConfigurationHistories");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Contract", b =>
{
b.Navigation("UserContracts");
@@ -1298,10 +2127,20 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
{
b.Navigation("ClubMembership");
b.Navigation("CommissionPayouts");
b.Navigation("NetworkChildren");
b.Navigation("NetworkWeeklyBalances");
b.Navigation("UserAddresss");
b.Navigation("UserCartss");
b.Navigation("UserClubFeatures");
b.Navigation("UserContracts");
b.Navigation("UserOrders");