diff --git a/src/CMSMicroservice.Application/CategoryCQ/Commands/CreateNewCategory/CreateNewCategoryCommandHandler.cs b/src/CMSMicroservice.Application/CategoryCQ/Commands/CreateNewCategory/CreateNewCategoryCommandHandler.cs index 67afe47..e4429aa 100644 --- a/src/CMSMicroservice.Application/CategoryCQ/Commands/CreateNewCategory/CreateNewCategoryCommandHandler.cs +++ b/src/CMSMicroservice.Application/CategoryCQ/Commands/CreateNewCategory/CreateNewCategoryCommandHandler.cs @@ -13,7 +13,7 @@ public class CreateNewCategoryCommandHandler : IRequestHandler(); - await _context.Categorys.AddAsync(entity, cancellationToken); + await _context.Categories.AddAsync(entity, cancellationToken); entity.AddDomainEvent(new CreateNewCategoryEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return entity.Adapt(); diff --git a/src/CMSMicroservice.Application/CategoryCQ/Commands/DeleteCategory/DeleteCategoryCommandHandler.cs b/src/CMSMicroservice.Application/CategoryCQ/Commands/DeleteCategory/DeleteCategoryCommandHandler.cs index b6293d3..0b79ec8 100644 --- a/src/CMSMicroservice.Application/CategoryCQ/Commands/DeleteCategory/DeleteCategoryCommandHandler.cs +++ b/src/CMSMicroservice.Application/CategoryCQ/Commands/DeleteCategory/DeleteCategoryCommandHandler.cs @@ -11,10 +11,10 @@ public class DeleteCategoryCommandHandler : IRequestHandler Handle(DeleteCategoryCommand request, CancellationToken cancellationToken) { - var entity = await _context.Categorys + var entity = await _context.Categories .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Category), request.Id); entity.IsDeleted = true; - _context.Categorys.Update(entity); + _context.Categories.Update(entity); entity.AddDomainEvent(new DeleteCategoryEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/CategoryCQ/Commands/UpdateCategory/UpdateCategoryCommandHandler.cs b/src/CMSMicroservice.Application/CategoryCQ/Commands/UpdateCategory/UpdateCategoryCommandHandler.cs index 5efef2a..ab26b1c 100644 --- a/src/CMSMicroservice.Application/CategoryCQ/Commands/UpdateCategory/UpdateCategoryCommandHandler.cs +++ b/src/CMSMicroservice.Application/CategoryCQ/Commands/UpdateCategory/UpdateCategoryCommandHandler.cs @@ -11,10 +11,10 @@ public class UpdateCategoryCommandHandler : IRequestHandler Handle(UpdateCategoryCommand request, CancellationToken cancellationToken) { - var entity = await _context.Categorys + var entity = await _context.Categories .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Category), request.Id); request.Adapt(entity); - _context.Categorys.Update(entity); + _context.Categories.Update(entity); entity.AddDomainEvent(new UpdateCategoryEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/CategoryCQ/Queries/GetAllCategoryByFilter/GetAllCategoryByFilterQueryHandler.cs b/src/CMSMicroservice.Application/CategoryCQ/Queries/GetAllCategoryByFilter/GetAllCategoryByFilterQueryHandler.cs index b5782fb..3d30861 100644 --- a/src/CMSMicroservice.Application/CategoryCQ/Queries/GetAllCategoryByFilter/GetAllCategoryByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/CategoryCQ/Queries/GetAllCategoryByFilter/GetAllCategoryByFilterQueryHandler.cs @@ -10,7 +10,7 @@ public class GetAllCategoryByFilterQueryHandler : IRequestHandler Handle(GetAllCategoryByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.Categorys + var query = _context.Categories .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); diff --git a/src/CMSMicroservice.Application/CategoryCQ/Queries/GetCategory/GetCategoryQueryHandler.cs b/src/CMSMicroservice.Application/CategoryCQ/Queries/GetCategory/GetCategoryQueryHandler.cs index 9b7700f..a1f7654 100644 --- a/src/CMSMicroservice.Application/CategoryCQ/Queries/GetCategory/GetCategoryQueryHandler.cs +++ b/src/CMSMicroservice.Application/CategoryCQ/Queries/GetCategory/GetCategoryQueryHandler.cs @@ -11,7 +11,7 @@ public class GetCategoryQueryHandler : IRequestHandler Handle(GetCategoryQuery request, CancellationToken cancellationToken) { - var response = await _context.Categorys + var response = await _context.Categories .AsNoTracking() .Where(x => x.Id == request.Id) .ProjectToType() diff --git a/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs b/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs index 67f67c6..75dee01 100644 --- a/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs +++ b/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs @@ -130,6 +130,30 @@ public class ActivateClubMembershipCommandHandler : IRequestHandler c.UserId == user.Id, cancellationToken); + // 6.1. دریافت مبلغ هدیه از تنظیمات + var giftValueConfig = await _context.SystemConfigurations + .FirstOrDefaultAsync( + c => c.Key == "Club.MembershipGiftValue" && c.IsActive, + cancellationToken + ); + + long giftValue = 25_200_000; // مقدار پیش‌فرض + if (giftValueConfig != null && long.TryParse(giftValueConfig.Value, out var configValue)) + { + giftValue = configValue; + _logger.LogInformation( + "Using Club.MembershipGiftValue from configuration: {GiftValue}", + giftValue + ); + } + else + { + _logger.LogWarning( + "Club.MembershipGiftValue not found in configuration, using default: {GiftValue}", + giftValue + ); + } + ClubMembership entity; bool isNewMembership = existingMembership == null; var activationDate = DateTime.UtcNow; @@ -143,6 +167,7 @@ public class ActivateClubMembershipCommandHandler : IRequestHandler= rightTotal ? excessBalances : 0); - var rightRemainder = (rightTotal - totalBalances) + (rightTotal >= leftTotal ? excessBalances : 0); + // محاسبه باقیمانده برای هفته بعد (Flash Out Logic) + // مثال: چپ=350، راست=450، سقف=300 + // تعادل پرداختی = MIN(MIN(350, 450), 300) = 300 + // از هر طرف نصف تعادل پرداختی کسر می‌شود: 300÷2 = 150 + // باقیمانده چپ: 350 - 150 = 200 + // باقیمانده راست: 450 - 150 = 300 + var balancesToPay = cappedBalances; // تعادل نهایی قابل پرداخت + var balancesConsumedPerSide = balancesToPay / 2; // هر طرف نصف تعادل را مصرف می‌کند + + var leftRemainder = leftTotal - balancesConsumedPerSide; + var rightRemainder = rightTotal - balancesConsumedPerSide; // محاسبه سهم استخر (20% از مجموع فعال‌سازی‌های جدید کل شبکه) // طبق گفته دکتر: کل افراد جدید در شبکه × هزینه فعال‌سازی × 20% diff --git a/src/CMSMicroservice.Application/CommissionCQ/Queries/GetWithdrawalReports/GetWithdrawalReportsQuery.cs b/src/CMSMicroservice.Application/CommissionCQ/Queries/GetWithdrawalReports/GetWithdrawalReportsQuery.cs new file mode 100644 index 0000000..e6f3348 --- /dev/null +++ b/src/CMSMicroservice.Application/CommissionCQ/Queries/GetWithdrawalReports/GetWithdrawalReportsQuery.cs @@ -0,0 +1,172 @@ +using CMSMicroservice.Domain.Enums; + +namespace CMSMicroservice.Application.CommissionCQ.Queries.GetWithdrawalReports; + +/// +/// Query برای دریافت گزارش برداشت‌ها +/// +public record GetWithdrawalReportsQuery : IRequest +{ + /// + /// تاریخ شروع + /// + public DateTime? StartDate { get; init; } + + /// + /// تاریخ پایان + /// + public DateTime? EndDate { get; init; } + + /// + /// نوع بازه زمانی (روزانه، هفتگی، ماهانه) + /// + public ReportPeriodType PeriodType { get; init; } = ReportPeriodType.Daily; + + /// + /// فیلتر بر اساس وضعیت + /// + public CommissionPayoutStatus? Status { get; init; } + + /// + /// شناسه کاربر (برای فیلتر کردن بر اساس کاربر خاص) + /// + public long? UserId { get; init; } +} + +/// +/// نوع بازه زمانی گزارش +/// +public enum ReportPeriodType +{ + Daily = 1, + Weekly = 2, + Monthly = 3 +} + +/// +/// DTO گزارش برداشت‌ها +/// +public class WithdrawalReportsDto +{ + /// + /// گزارش‌های بازه‌های زمانی + /// + public List PeriodReports { get; set; } = new(); + + /// + /// خلاصه کلی + /// + public WithdrawalSummaryDto Summary { get; set; } = new(); +} + +/// +/// گزارش یک بازه زمانی +/// +public class PeriodReportDto +{ + /// + /// عنوان بازه (مثلاً "هفته 1" یا "دی ماه") + /// + public string PeriodLabel { get; set; } = string.Empty; + + /// + /// تاریخ شروع بازه + /// + public DateTime StartDate { get; set; } + + /// + /// تاریخ پایان بازه + /// + public DateTime EndDate { get; set; } + + /// + /// تعداد کل درخواست‌ها + /// + public int TotalRequests { get; set; } + + /// + /// تعداد درخواست‌های در انتظار + /// + public int PendingCount { get; set; } + + /// + /// تعداد درخواست‌های تأیید شده + /// + public int ApprovedCount { get; set; } + + /// + /// تعداد درخواست‌های رد شده + /// + public int RejectedCount { get; set; } + + /// + /// تعداد درخواست‌های موفق + /// + public int CompletedCount { get; set; } + + /// + /// تعداد درخواست‌های ناموفق + /// + public int FailedCount { get; set; } + + /// + /// مجموع مبلغ درخواست‌ها + /// + public long TotalAmount { get; set; } + + /// + /// مجموع مبلغ پرداخت شده + /// + public long PaidAmount { get; set; } + + /// + /// مجموع مبلغ در انتظار + /// + public long PendingAmount { get; set; } +} + +/// +/// خلاصه کلی برداشت‌ها +/// +public class WithdrawalSummaryDto +{ + /// + /// تعداد کل درخواست‌ها + /// + public int TotalRequests { get; set; } + + /// + /// مجموع کل مبالغ + /// + public long TotalAmount { get; set; } + + /// + /// مجموع مبلغ پرداخت شده + /// + public long TotalPaid { get; set; } + + /// + /// مجموع مبلغ در انتظار + /// + public long TotalPending { get; set; } + + /// + /// مجموع مبلغ رد شده + /// + public long TotalRejected { get; set; } + + /// + /// میانگین مبلغ هر درخواست + /// + public long AverageAmount { get; set; } + + /// + /// تعداد کاربران منحصر به فرد + /// + public int UniqueUsers { get; set; } + + /// + /// درصد موفقیت (Completed / Total) + /// + public decimal SuccessRate { get; set; } +} diff --git a/src/CMSMicroservice.Application/CommissionCQ/Queries/GetWithdrawalReports/GetWithdrawalReportsQueryHandler.cs b/src/CMSMicroservice.Application/CommissionCQ/Queries/GetWithdrawalReports/GetWithdrawalReportsQueryHandler.cs new file mode 100644 index 0000000..347b577 --- /dev/null +++ b/src/CMSMicroservice.Application/CommissionCQ/Queries/GetWithdrawalReports/GetWithdrawalReportsQueryHandler.cs @@ -0,0 +1,213 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Enums; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.CommissionCQ.Queries.GetWithdrawalReports; + +/// +/// Handler برای دریافت گزارش برداشت‌ها +/// +public class GetWithdrawalReportsQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetWithdrawalReportsQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetWithdrawalReportsQuery request, CancellationToken cancellationToken) + { + // تعیین بازه زمانی پیش‌فرض (30 روز گذشته) + var endDate = request.EndDate ?? DateTime.UtcNow; + var startDate = request.StartDate ?? endDate.AddDays(-30); + + // Query پایه + var query = _context.UserCommissionPayouts + .Where(p => p.Created >= startDate && p.Created <= endDate); + + // فیلتر بر اساس وضعیت + if (request.Status.HasValue) + { + query = query.Where(p => p.Status == request.Status.Value); + } + + // فیلتر بر اساس کاربر + if (request.UserId.HasValue) + { + query = query.Where(p => p.UserId == request.UserId.Value); + } + + var payouts = await query + .OrderBy(p => p.Created) + .ToListAsync(cancellationToken); + + // گروه‌بندی بر اساس نوع بازه + var periodReports = request.PeriodType switch + { + ReportPeriodType.Daily => GroupByDay(payouts, startDate, endDate), + ReportPeriodType.Weekly => GroupByWeek(payouts, startDate, endDate), + ReportPeriodType.Monthly => GroupByMonth(payouts, startDate, endDate), + _ => GroupByDay(payouts, startDate, endDate) + }; + + // محاسبه خلاصه کلی + var summary = CalculateSummary(payouts); + + return new WithdrawalReportsDto + { + PeriodReports = periodReports, + Summary = summary + }; + } + + private List GroupByDay(List payouts, DateTime startDate, DateTime endDate) + { + var reports = new List(); + var currentDate = startDate.Date; + + while (currentDate <= endDate.Date) + { + var dayPayouts = payouts.Where(p => p.Created.Date == currentDate).ToList(); + + reports.Add(new PeriodReportDto + { + PeriodLabel = currentDate.ToString("yyyy-MM-dd"), + StartDate = currentDate, + EndDate = currentDate.AddDays(1).AddSeconds(-1), + TotalRequests = dayPayouts.Count, + PendingCount = dayPayouts.Count(p => p.Status == CommissionPayoutStatus.Pending || + p.Status == CommissionPayoutStatus.WithdrawRequested), + ApprovedCount = 0, // تایید جداگانه نداریم + RejectedCount = dayPayouts.Count(p => p.Status == CommissionPayoutStatus.Cancelled), + CompletedCount = dayPayouts.Count(p => p.Status == CommissionPayoutStatus.Withdrawn), + FailedCount = dayPayouts.Count(p => p.Status == CommissionPayoutStatus.PaymentFailed), + TotalAmount = dayPayouts.Sum(p => p.TotalAmount), + PaidAmount = dayPayouts.Where(p => p.Status == CommissionPayoutStatus.Withdrawn).Sum(p => p.TotalAmount), + PendingAmount = dayPayouts.Where(p => p.Status == CommissionPayoutStatus.Pending || + p.Status == CommissionPayoutStatus.WithdrawRequested).Sum(p => p.TotalAmount) + }); + + currentDate = currentDate.AddDays(1); + } + + return reports; + } + + private List GroupByWeek(List payouts, DateTime startDate, DateTime endDate) + { + var reports = new List(); + var currentWeekStart = startDate.Date; + + int weekNumber = 1; + while (currentWeekStart <= endDate) + { + var weekEnd = currentWeekStart.AddDays(7).AddSeconds(-1); + if (weekEnd > endDate) + weekEnd = endDate; + + var weekPayouts = payouts.Where(p => p.Created >= currentWeekStart && p.Created <= weekEnd).ToList(); + + reports.Add(new PeriodReportDto + { + PeriodLabel = $"هفته {weekNumber}", + StartDate = currentWeekStart, + EndDate = weekEnd, + TotalRequests = weekPayouts.Count, + PendingCount = weekPayouts.Count(p => p.Status == CommissionPayoutStatus.Pending || + p.Status == CommissionPayoutStatus.WithdrawRequested), + ApprovedCount = 0, // تایید جداگانه نداریم + RejectedCount = weekPayouts.Count(p => p.Status == CommissionPayoutStatus.Cancelled), + CompletedCount = weekPayouts.Count(p => p.Status == CommissionPayoutStatus.Withdrawn), + FailedCount = weekPayouts.Count(p => p.Status == CommissionPayoutStatus.PaymentFailed), + TotalAmount = weekPayouts.Sum(p => p.TotalAmount), + PaidAmount = weekPayouts.Where(p => p.Status == CommissionPayoutStatus.Withdrawn).Sum(p => p.TotalAmount), + PendingAmount = weekPayouts.Where(p => p.Status == CommissionPayoutStatus.Pending || + p.Status == CommissionPayoutStatus.WithdrawRequested).Sum(p => p.TotalAmount) + }); + + currentWeekStart = currentWeekStart.AddDays(7); + weekNumber++; + } + + return reports; + } + + private List GroupByMonth(List payouts, DateTime startDate, DateTime endDate) + { + var reports = new List(); + var currentMonthStart = new DateTime(startDate.Year, startDate.Month, 1); + + while (currentMonthStart <= endDate) + { + var monthEnd = currentMonthStart.AddMonths(1).AddSeconds(-1); + if (monthEnd > endDate) + monthEnd = endDate; + + var monthPayouts = payouts.Where(p => p.Created >= currentMonthStart && p.Created <= monthEnd).ToList(); + + var persianMonthName = GetPersianMonthName(currentMonthStart.Month); + + reports.Add(new PeriodReportDto + { + PeriodLabel = $"{persianMonthName} {currentMonthStart.Year}", + StartDate = currentMonthStart, + EndDate = monthEnd, + TotalRequests = monthPayouts.Count, + PendingCount = monthPayouts.Count(p => p.Status == CommissionPayoutStatus.Pending || + p.Status == CommissionPayoutStatus.WithdrawRequested), + ApprovedCount = 0, // تایید جداگانه نداریم + RejectedCount = monthPayouts.Count(p => p.Status == CommissionPayoutStatus.Cancelled), + CompletedCount = monthPayouts.Count(p => p.Status == CommissionPayoutStatus.Withdrawn), + FailedCount = monthPayouts.Count(p => p.Status == CommissionPayoutStatus.PaymentFailed), + TotalAmount = monthPayouts.Sum(p => p.TotalAmount), + PaidAmount = monthPayouts.Where(p => p.Status == CommissionPayoutStatus.Withdrawn).Sum(p => p.TotalAmount), + PendingAmount = monthPayouts.Where(p => p.Status == CommissionPayoutStatus.Pending || + p.Status == CommissionPayoutStatus.WithdrawRequested).Sum(p => p.TotalAmount) + }); + + currentMonthStart = currentMonthStart.AddMonths(1); + } + + return reports; + } + + private WithdrawalSummaryDto CalculateSummary(List payouts) + { + var totalRequests = payouts.Count; + var completedCount = payouts.Count(p => p.Status == CommissionPayoutStatus.Withdrawn); + + return new WithdrawalSummaryDto + { + TotalRequests = totalRequests, + TotalAmount = payouts.Sum(p => p.TotalAmount), + TotalPaid = payouts.Where(p => p.Status == CommissionPayoutStatus.Withdrawn).Sum(p => p.TotalAmount), + TotalPending = payouts.Where(p => p.Status == CommissionPayoutStatus.Pending || + p.Status == CommissionPayoutStatus.WithdrawRequested).Sum(p => p.TotalAmount), + TotalRejected = payouts.Where(p => p.Status == CommissionPayoutStatus.Cancelled).Sum(p => p.TotalAmount), + AverageAmount = totalRequests > 0 ? payouts.Sum(p => p.TotalAmount) / totalRequests : 0, + UniqueUsers = payouts.Select(p => p.UserId).Distinct().Count(), + SuccessRate = totalRequests > 0 ? (decimal)completedCount / totalRequests * 100 : 0 + }; + } + + private string GetPersianMonthName(int month) + { + return month switch + { + 1 => "فروردین", + 2 => "اردیبهشت", + 3 => "خرداد", + 4 => "تیر", + 5 => "مرداد", + 6 => "شهریور", + 7 => "مهر", + 8 => "آبان", + 9 => "آذر", + 10 => "دی", + 11 => "بهمن", + 12 => "اسفند", + _ => month.ToString() + }; + } +} diff --git a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs index 7759d73..76f973a 100644 --- a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs +++ b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs @@ -1,30 +1,39 @@ +using CMSMicroservice.Domain.Entities.Payment; +using CMSMicroservice.Domain.Entities.Message; +using CMSMicroservice.Domain.Entities.Order; +using CMSMicroservice.Domain.Entities.DiscountShop; + namespace CMSMicroservice.Application.Common.Interfaces; public interface IApplicationDbContext { - DbSet UserAddresss { get; } + DbSet UserAddresses { get; } DbSet Packages { get; } DbSet Roles { get; } - DbSet Categorys { get; } + DbSet Categories { get; } DbSet UserRoles { get; } - DbSet UserCartss { get; } - DbSet ProductGalleryss { get; } - DbSet FactorDetailss { get; } - DbSet Productss { get; } - DbSet ProductImagess { get; } + DbSet UserCarts { get; } + DbSet ProductGalleries { get; } + DbSet FactorDetails { get; } + DbSet Products { get; } + DbSet ProductImages { get; } DbSet Users { get; } DbSet OtpTokens { get; } DbSet Contracts { get; } DbSet UserContracts { get; } DbSet Tags { get; } - DbSet PruductCategorys { get; } - DbSet PruductTags { get; } - DbSet Transactionss { get; } + DbSet ProductCategories { get; } + DbSet ProductTags { get; } + DbSet Transactions { get; } DbSet UserOrders { get; } + DbSet OrderVATs { get; } + DbSet UserPackagePurchases { get; } DbSet UserWallets { get; } DbSet UserWalletChangeLogs { get; } DbSet SystemConfigurations { get; } DbSet SystemConfigurationHistories { get; } + DbSet ManualPayments { get; } + DbSet PublicMessages { get; } DbSet ClubMemberships { get; } DbSet ClubMembershipHistories { get; } DbSet ClubFeatures { get; } @@ -36,5 +45,14 @@ public interface IApplicationDbContext DbSet CommissionPayoutHistories { get; } DbSet WorkerExecutionLogs { get; } DbSet DayaLoanContracts { get; } + + // ============= Discount Shop ============= + DbSet DiscountProducts { get; } + DbSet DiscountCategories { get; } + DbSet DiscountProductCategories { get; } + DbSet DiscountShoppingCarts { get; } + DbSet DiscountOrders { get; } + DbSet DiscountOrderDetails { get; } + Task SaveChangesAsync(CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/src/CMSMicroservice.Application/Common/Mappings/ProductGallerysProfile.cs b/src/CMSMicroservice.Application/Common/Mappings/ProductGalleriesProfile.cs similarity index 100% rename from src/CMSMicroservice.Application/Common/Mappings/ProductGallerysProfile.cs rename to src/CMSMicroservice.Application/Common/Mappings/ProductGalleriesProfile.cs diff --git a/src/CMSMicroservice.Application/Common/Mappings/UserCartsProfile.cs b/src/CMSMicroservice.Application/Common/Mappings/UserCartsProfile.cs index 7b1493f..5e31d61 100644 --- a/src/CMSMicroservice.Application/Common/Mappings/UserCartsProfile.cs +++ b/src/CMSMicroservice.Application/Common/Mappings/UserCartsProfile.cs @@ -6,7 +6,7 @@ public class UserCartsProfile : IRegister { void IRegister.Register(TypeAdapterConfig config) { - config.NewConfig() + config.NewConfig() .Map(dest => dest.Id, src => src.Id) .Map(dest => dest.Count, src => src.Count) .Map(dest => dest.ProductId, src => src.ProductId) diff --git a/src/CMSMicroservice.Application/Common/Mappings/UserOrderProfile.cs b/src/CMSMicroservice.Application/Common/Mappings/UserOrderProfile.cs index 6940d65..3426718 100644 --- a/src/CMSMicroservice.Application/Common/Mappings/UserOrderProfile.cs +++ b/src/CMSMicroservice.Application/Common/Mappings/UserOrderProfile.cs @@ -18,7 +18,7 @@ public class UserOrderProfile : IRegister .Map(dest => dest.UserAddressId, src => src.UserAddressId) .Map(dest => dest.PaymentMethod, src => src.PaymentMethod) .Map(dest => dest.UserAddressText, src => src.UserAddress.Address) - .Map(dest => dest.FactorDetails, src => src.FactorDetailss.Select(s=>s.Adapt())) + .Map(dest => dest.FactorDetails, src => src.FactorDetails.Select(s=>s.Adapt())) ; @@ -33,7 +33,7 @@ public class UserOrderProfile : IRegister .Map(dest => dest.UserAddressId, src => src.UserAddressId) .Map(dest => dest.PaymentMethod, src => src.PaymentMethod) .Map(dest => dest.UserAddressText, src => src.UserAddress.Address) - .Map(dest => dest.FactorDetails, src => src.FactorDetailss.Select(s=>s.Adapt())) + .Map(dest => dest.FactorDetails, src => src.FactorDetails.Select(s=>s.Adapt())) ; config.NewConfig() diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SeedVATConfiguration/SeedVATConfigurationCommand.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SeedVATConfiguration/SeedVATConfigurationCommand.cs new file mode 100644 index 0000000..5b3b1ac --- /dev/null +++ b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SeedVATConfiguration/SeedVATConfigurationCommand.cs @@ -0,0 +1,77 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ConfigurationCQ.Commands.SeedVATConfiguration; + +/// +/// Seed initial VAT configuration +/// نرخ مالیات پیش‌فرض ۹٪ +/// +public class SeedVATConfigurationCommand : IRequest +{ +} + +public class SeedVATConfigurationCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public SeedVATConfigurationCommandHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(SeedVATConfigurationCommand request, CancellationToken cancellationToken) + { + var configs = new[] + { + new + { + Scope = ConfigurationScope.VAT, + Key = "Rate", + Value = "0.09", + Description = "نرخ مالیات بر ارزش افزوده (۹٪)" + }, + new + { + Scope = ConfigurationScope.VAT, + Key = "IsEnabled", + Value = "true", + Description = "فعال/غیرفعال بودن محاسبه مالیات" + } + }; + + foreach (var config in configs) + { + var exists = _context.SystemConfigurations + .Any(x => x.Scope == config.Scope && x.Key == config.Key); + + if (!exists) + { + _context.SystemConfigurations.Add(new Domain.Entities.Configuration.SystemConfiguration + { + Scope = config.Scope, + Key = config.Key, + Value = config.Value, + Description = config.Description + }); + + _logger.LogInformation( + "VAT configuration seeded: {Scope}.{Key} = {Value}", + config.Scope, + config.Key, + config.Value + ); + } + } + + await _context.SaveChangesAsync(cancellationToken); + + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs index 6f7e1eb..4e7dfbe 100644 --- a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs +++ b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs @@ -31,7 +31,7 @@ public class ProcessDayaLoanApprovalCommandHandler : IRequestHandler p.Title.Contains("طلایی") || p.Title.Contains("Golden"), cancellationToken); if (goldenPackage != null) { // پیدا کردن آدرس پیش‌فرض کاربر - var defaultAddress = await _context.UserAddresss + var defaultAddress = await _context.UserAddresses .Where(a => a.UserId == request.UserId) .OrderByDescending(a => a.Created) .FirstOrDefaultAsync(cancellationToken); diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommand.cs new file mode 100644 index 0000000..b7b6fac --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommand.cs @@ -0,0 +1,17 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.AddToCart; + +public class AddToCartCommand : IRequest +{ + public long UserId { get; set; } + public long ProductId { get; set; } + public int Count { get; set; } +} + +public class AddToCartResponseDto +{ + public bool Success { get; set; } + public string Message { get; set; } + public long CartItemId { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommandHandler.cs new file mode 100644 index 0000000..5f90323 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommandHandler.cs @@ -0,0 +1,89 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities.DiscountShop; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.AddToCart; + +public class AddToCartCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public AddToCartCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(AddToCartCommand request, CancellationToken cancellationToken) + { + // Check if product exists and is active + var product = await _context.DiscountProducts + .FirstOrDefaultAsync(p => p.Id == request.ProductId && p.IsActive, cancellationToken); + + if (product == null) + { + return new AddToCartResponseDto + { + Success = false, + Message = "محصول یافت نشد یا غیرفعال است" + }; + } + + // Check stock availability + if (product.RemainingCount < request.Count) + { + return new AddToCartResponseDto + { + Success = false, + Message = $"موجودی کافی نیست. موجودی فعلی: {product.RemainingCount}" + }; + } + + // Check if item already exists in cart + var existingCartItem = await _context.DiscountShoppingCarts + .FirstOrDefaultAsync(c => c.UserId == request.UserId && c.ProductId == request.ProductId, cancellationToken); + + if (existingCartItem != null) + { + // Update quantity + var newCount = existingCartItem.Count + request.Count; + + if (product.RemainingCount < newCount) + { + return new AddToCartResponseDto + { + Success = false, + Message = $"موجودی کافی نیست. موجودی فعلی: {product.RemainingCount}" + }; + } + + existingCartItem.Count = newCount; + await _context.SaveChangesAsync(cancellationToken); + + return new AddToCartResponseDto + { + Success = true, + Message = "تعداد محصول در سبد خرید به‌روزرسانی شد", + CartItemId = existingCartItem.Id + }; + } + + // Add new item to cart + var cartItem = new DiscountShoppingCart + { + UserId = request.UserId, + ProductId = request.ProductId, + Count = request.Count + }; + + _context.DiscountShoppingCarts.Add(cartItem); + await _context.SaveChangesAsync(cancellationToken); + + return new AddToCartResponseDto + { + Success = true, + Message = "محصول به سبد خرید اضافه شد", + CartItemId = cartItem.Id + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommandValidator.cs new file mode 100644 index 0000000..77de180 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddToCart/AddToCartCommandValidator.cs @@ -0,0 +1,18 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.AddToCart; + +public class AddToCartCommandValidator : AbstractValidator +{ + public AddToCartCommandValidator() + { + RuleFor(v => v.UserId) + .GreaterThan(0).WithMessage("شناسه کاربر نامعتبر است"); + + RuleFor(v => v.ProductId) + .GreaterThan(0).WithMessage("شناسه محصول نامعتبر است"); + + RuleFor(v => v.Count) + .GreaterThan(0).WithMessage("تعداد باید بیشتر از صفر باشد"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ClearCart/ClearCartCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ClearCart/ClearCartCommand.cs new file mode 100644 index 0000000..e27de9f --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ClearCart/ClearCartCommand.cs @@ -0,0 +1,8 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.ClearCart; + +public class ClearCartCommand : IRequest +{ + public long UserId { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ClearCart/ClearCartCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ClearCart/ClearCartCommandHandler.cs new file mode 100644 index 0000000..66ff9e9 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ClearCart/ClearCartCommandHandler.cs @@ -0,0 +1,33 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.ClearCart; + +public class ClearCartCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public ClearCartCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(ClearCartCommand request, CancellationToken cancellationToken) + { + var cartItems = await _context.DiscountShoppingCarts + .Where(c => c.UserId == request.UserId) + .ToListAsync(cancellationToken); + + if (!cartItems.Any()) + { + return true; // Cart already empty + } + + _context.DiscountShoppingCarts.RemoveRange(cartItems); + await _context.SaveChangesAsync(cancellationToken); + + return true; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CompleteOrderPayment/CompleteOrderPaymentCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CompleteOrderPayment/CompleteOrderPaymentCommand.cs new file mode 100644 index 0000000..c64d084 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CompleteOrderPayment/CompleteOrderPaymentCommand.cs @@ -0,0 +1,18 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CompleteOrderPayment; + +public class CompleteOrderPaymentCommand : IRequest +{ + public long OrderId { get; set; } + public long TransactionId { get; set; } + public bool PaymentSuccess { get; set; } + public string? RefId { get; set; } +} + +public class CompleteOrderPaymentResponseDto +{ + public bool Success { get; set; } + public string Message { get; set; } + public long? OrderId { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CompleteOrderPayment/CompleteOrderPaymentCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CompleteOrderPayment/CompleteOrderPaymentCommandHandler.cs new file mode 100644 index 0000000..b3b88e8 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CompleteOrderPayment/CompleteOrderPaymentCommandHandler.cs @@ -0,0 +1,99 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CompleteOrderPayment; + +public class CompleteOrderPaymentCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public CompleteOrderPaymentCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CompleteOrderPaymentCommand request, CancellationToken cancellationToken) + { + var order = await _context.DiscountOrders + .Include(o => o.OrderDetails) + .ThenInclude(od => od.Product) + .FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken); + + if (order == null) + { + return new CompleteOrderPaymentResponseDto + { + Success = false, + Message = "سفارش یافت نشد" + }; + } + + var transaction = await _context.Transactions + .FirstOrDefaultAsync(t => t.Id == request.TransactionId, cancellationToken); + + if (transaction == null) + { + return new CompleteOrderPaymentResponseDto + { + Success = false, + Message = "تراکنش یافت نشد" + }; + } + + if (request.PaymentSuccess) + { + // Update transaction + transaction.PaymentStatus = PaymentStatus.Success; + transaction.PaymentDate = DateTime.UtcNow; + transaction.RefId = request.RefId; + + // Update order + order.PaymentStatus = PaymentStatus.Success; + order.PaymentDate = DateTime.UtcNow; + order.DeliveryStatus = DeliveryStatus.InTransit; + + // Deduct discount balance from user wallet + var userWallet = await _context.UserWallets + .FirstOrDefaultAsync(w => w.UserId == order.UserId, cancellationToken); + + if (userWallet != null) + { + userWallet.DiscountBalance -= order.DiscountBalanceUsed; + } + + // Update product stock and sale count + foreach (var orderDetail in order.OrderDetails) + { + var product = orderDetail.Product; + product.RemainingCount -= orderDetail.Count; + product.SaleCount += orderDetail.Count; + } + + await _context.SaveChangesAsync(cancellationToken); + + return new CompleteOrderPaymentResponseDto + { + Success = true, + Message = "پرداخت با موفقیت انجام شد", + OrderId = order.Id + }; + } + else + { + // Payment failed + transaction.PaymentStatus = PaymentStatus.Reject; + order.PaymentStatus = PaymentStatus.Reject; + + await _context.SaveChangesAsync(cancellationToken); + + return new CompleteOrderPaymentResponseDto + { + Success = false, + Message = "پرداخت ناموفق بود", + OrderId = order.Id + }; + } + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommand.cs new file mode 100644 index 0000000..0373b30 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommand.cs @@ -0,0 +1,14 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountCategory; + +public class CreateDiscountCategoryCommand : IRequest +{ + public string Name { get; set; } + public string Title { get; set; } + public string? Description { get; set; } + public string? ImagePath { get; set; } + public long? ParentCategoryId { get; set; } + public int SortOrder { get; set; } + public bool IsActive { get; set; } = true; +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandHandler.cs new file mode 100644 index 0000000..278d772 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandHandler.cs @@ -0,0 +1,58 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using CMSMicroservice.Domain.Entities.DiscountShop; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountCategory; + +public class CreateDiscountCategoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public CreateDiscountCategoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CreateDiscountCategoryCommand request, CancellationToken cancellationToken) + { + // بررسی وجود دسته‌بندی با همین نام + var existingCategory = await _context.DiscountCategories + .FirstOrDefaultAsync(c => c.Name == request.Name, cancellationToken); + + if (existingCategory != null) + { + throw new InvalidOperationException("دسته‌بندی با این نام قبلاً ثبت شده است"); + } + + // بررسی وجود دسته‌بندی والد + if (request.ParentCategoryId.HasValue) + { + var parentExists = await _context.DiscountCategories + .AnyAsync(c => c.Id == request.ParentCategoryId.Value, cancellationToken); + + if (!parentExists) + { + throw new InvalidOperationException("دسته‌بندی والد یافت نشد"); + } + } + + var category = new DiscountCategory + { + Name = request.Name, + Title = request.Title, + Description = request.Description, + ImagePath = request.ImagePath, + ParentCategoryId = request.ParentCategoryId, + SortOrder = request.SortOrder, + IsActive = request.IsActive, + Created = DateTime.UtcNow + }; + + _context.DiscountCategories.Add(category); + await _context.SaveChangesAsync(cancellationToken); + + return category.Id; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandValidator.cs new file mode 100644 index 0000000..c81ca8f --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandValidator.cs @@ -0,0 +1,32 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountCategory; + +public class CreateDiscountCategoryCommandValidator : AbstractValidator +{ + public CreateDiscountCategoryCommandValidator() + { + RuleFor(x => x.Name) + .NotEmpty().WithMessage("نام دسته‌بندی الزامی است") + .MaximumLength(100).WithMessage("نام دسته‌بندی نباید بیشتر از 100 کاراکتر باشد"); + + RuleFor(x => x.Title) + .NotEmpty().WithMessage("عنوان دسته‌بندی الزامی است") + .MaximumLength(200).WithMessage("عنوان دسته‌بندی نباید بیشتر از 200 کاراکتر باشد"); + + RuleFor(x => x.Description) + .MaximumLength(1000).WithMessage("توضیحات نباید بیشتر از 1000 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.Description)); + + RuleFor(x => x.ImagePath) + .MaximumLength(500).WithMessage("مسیر تصویر نباید بیشتر از 500 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.ImagePath)); + + RuleFor(x => x.ParentCategoryId) + .GreaterThan(0).WithMessage("شناسه دسته‌بندی والد باید مثبت باشد") + .When(x => x.ParentCategoryId.HasValue); + + RuleFor(x => x.SortOrder) + .GreaterThanOrEqualTo(0).WithMessage("ترتیب نمایش نمی‌تواند منفی باشد"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommand.cs new file mode 100644 index 0000000..9549145 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommand.cs @@ -0,0 +1,16 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountProduct; + +public class CreateDiscountProductCommand : IRequest +{ + public string Title { get; set; } + public string ShortInfomation { get; set; } + public string FullInformation { get; set; } + public long Price { get; set; } + public int MaxDiscountPercent { get; set; } + public string ImagePath { get; set; } + public string ThumbnailPath { get; set; } + public int RemainingCount { get; set; } + public List CategoryIds { get; set; } = new(); +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandHandler.cs new file mode 100644 index 0000000..542952b --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandHandler.cs @@ -0,0 +1,53 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities.DiscountShop; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountProduct; + +public class CreateDiscountProductCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public CreateDiscountProductCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CreateDiscountProductCommand request, CancellationToken cancellationToken) + { + var product = new DiscountProduct + { + Title = request.Title, + ShortInfomation = request.ShortInfomation, + FullInformation = request.FullInformation, + Price = request.Price, + MaxDiscountPercent = request.MaxDiscountPercent, + ImagePath = request.ImagePath, + ThumbnailPath = request.ThumbnailPath, + RemainingCount = request.RemainingCount, + Rate = 0, + SaleCount = 0, + ViewCount = 0, + IsActive = true + }; + + _context.DiscountProducts.Add(product); + await _context.SaveChangesAsync(cancellationToken); + + // Add product categories + if (request.CategoryIds.Any()) + { + var productCategories = request.CategoryIds.Select(categoryId => new DiscountProductCategory + { + ProductId = product.Id, + CategoryId = categoryId + }).ToList(); + + _context.DiscountProductCategories.AddRange(productCategories); + await _context.SaveChangesAsync(cancellationToken); + } + + return product.Id; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandValidator.cs new file mode 100644 index 0000000..29908dd --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandValidator.cs @@ -0,0 +1,36 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountProduct; + +public class CreateDiscountProductCommandValidator : AbstractValidator +{ + public CreateDiscountProductCommandValidator() + { + RuleFor(v => v.Title) + .NotEmpty().WithMessage("عنوان محصول الزامی است") + .MaximumLength(200).WithMessage("عنوان محصول نمی‌تواند بیشتر از 200 کاراکتر باشد"); + + RuleFor(v => v.ShortInfomation) + .NotEmpty().WithMessage("توضیحات کوتاه الزامی است") + .MaximumLength(500).WithMessage("توضیحات کوتاه نمی‌تواند بیشتر از 500 کاراکتر باشد"); + + RuleFor(v => v.FullInformation) + .NotEmpty().WithMessage("توضیحات کامل الزامی است") + .MaximumLength(2000).WithMessage("توضیحات کامل نمی‌تواند بیشتر از 2000 کاراکتر باشد"); + + RuleFor(v => v.Price) + .GreaterThan(0).WithMessage("قیمت باید بیشتر از صفر باشد"); + + RuleFor(v => v.MaxDiscountPercent) + .InclusiveBetween(0, 100).WithMessage("درصد تخفیف باید بین 0 تا 100 باشد"); + + RuleFor(v => v.RemainingCount) + .GreaterThanOrEqualTo(0).WithMessage("موجودی نمی‌تواند منفی باشد"); + + RuleFor(v => v.ImagePath) + .NotEmpty().WithMessage("تصویر محصول الزامی است"); + + RuleFor(v => v.ThumbnailPath) + .NotEmpty().WithMessage("تصویر بندانگشتی الزامی است"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountCategory/DeleteDiscountCategoryCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountCategory/DeleteDiscountCategoryCommand.cs new file mode 100644 index 0000000..c22f3cd --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountCategory/DeleteDiscountCategoryCommand.cs @@ -0,0 +1,8 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountCategory; + +public class DeleteDiscountCategoryCommand : IRequest +{ + public long CategoryId { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountCategory/DeleteDiscountCategoryCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountCategory/DeleteDiscountCategoryCommandHandler.cs new file mode 100644 index 0000000..343d16a --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountCategory/DeleteDiscountCategoryCommandHandler.cs @@ -0,0 +1,46 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountCategory; + +public class DeleteDiscountCategoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public DeleteDiscountCategoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(DeleteDiscountCategoryCommand request, CancellationToken cancellationToken) + { + var category = await _context.DiscountCategories + .Include(c => c.ChildCategories) + .Include(c => c.ProductCategories) + .FirstOrDefaultAsync(c => c.Id == request.CategoryId, cancellationToken); + + if (category == null) + { + throw new Exception($"Discount category with ID {request.CategoryId} not found"); + } + + // Check if category has child categories + if (category.ChildCategories.Any()) + { + throw new Exception($"Cannot delete category. It has {category.ChildCategories.Count} child categories. Please delete child categories first."); + } + + // Check if category has products + if (category.ProductCategories.Any()) + { + throw new Exception($"Cannot delete category. It has {category.ProductCategories.Count} products. Please move or delete products first."); + } + + _context.DiscountCategories.Remove(category); + await _context.SaveChangesAsync(cancellationToken); + + return true; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProduct/DeleteDiscountProductCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProduct/DeleteDiscountProductCommand.cs new file mode 100644 index 0000000..a6d2bf1 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProduct/DeleteDiscountProductCommand.cs @@ -0,0 +1,8 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountProduct; + +public class DeleteDiscountProductCommand : IRequest +{ + public long ProductId { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProduct/DeleteDiscountProductCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProduct/DeleteDiscountProductCommandHandler.cs new file mode 100644 index 0000000..df58044 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProduct/DeleteDiscountProductCommandHandler.cs @@ -0,0 +1,39 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountProduct; + +public class DeleteDiscountProductCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public DeleteDiscountProductCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(DeleteDiscountProductCommand request, CancellationToken cancellationToken) + { + var product = await _context.DiscountProducts + .FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken); + + if (product == null) + { + return false; + } + + // حذف رابطه‌های دسته‌بندی + var productCategories = await _context.DiscountProductCategories + .Where(pc => pc.ProductId == request.ProductId) + .ToListAsync(cancellationToken); + + _context.DiscountProductCategories.RemoveRange(productCategories); + + // حذف محصول + _context.DiscountProducts.Remove(product); + await _context.SaveChangesAsync(cancellationToken); + + return true; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommand.cs new file mode 100644 index 0000000..b32b074 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommand.cs @@ -0,0 +1,21 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.PlaceOrder; + +public class PlaceOrderCommand : IRequest +{ + public long UserId { get; set; } + public long UserAddressId { get; set; } + public long DiscountBalanceToUse { get; set; } +} + +public class PlaceOrderResponseDto +{ + public bool Success { get; set; } + public string Message { get; set; } + public long? OrderId { get; set; } + public long? TransactionId { get; set; } + public long TotalAmount { get; set; } + public long DiscountBalanceUsed { get; set; } + public long GatewayAmountRequired { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandHandler.cs new file mode 100644 index 0000000..7032a20 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandHandler.cs @@ -0,0 +1,169 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities.DiscountShop; +using CMSMicroservice.Domain.Entities.Payment; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.PlaceOrder; + +public class PlaceOrderCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public PlaceOrderCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(PlaceOrderCommand request, CancellationToken cancellationToken) + { + // Get user wallet + var userWallet = await _context.UserWallets + .FirstOrDefaultAsync(w => w.UserId == request.UserId, cancellationToken); + + if (userWallet == null) + { + return new PlaceOrderResponseDto + { + Success = false, + Message = "کیف پول کاربر یافت نشد" + }; + } + + // Get cart items with products + var cartItems = await _context.DiscountShoppingCarts + .Where(c => c.UserId == request.UserId) + .Include(c => c.Product) + .ToListAsync(cancellationToken); + + if (!cartItems.Any()) + { + return new PlaceOrderResponseDto + { + Success = false, + Message = "سبد خرید خالی است" + }; + } + + // Validate stock and calculate totals + long totalAmount = 0; + long totalDiscountAmount = 0; + var orderDetails = new List(); + + foreach (var cartItem in cartItems) + { + var product = cartItem.Product; + + // Check stock + if (product.RemainingCount < cartItem.Count) + { + return new PlaceOrderResponseDto + { + Success = false, + Message = $"موجودی محصول '{product.Title}' کافی نیست" + }; + } + + // Check if product is active + if (!product.IsActive) + { + return new PlaceOrderResponseDto + { + Success = false, + Message = $"محصول '{product.Title}' غیرفعال است" + }; + } + + // Calculate discount for this product + var itemTotal = product.Price * cartItem.Count; + var maxDiscountForItem = (itemTotal * product.MaxDiscountPercent) / 100; + + totalAmount += itemTotal; + totalDiscountAmount += maxDiscountForItem; + + orderDetails.Add(new DiscountOrderDetail + { + ProductId = product.Id, + Count = cartItem.Count, + UnitPrice = product.Price, + DiscountPercentUsed = product.MaxDiscountPercent, + DiscountAmount = maxDiscountForItem, + FinalPrice = itemTotal - maxDiscountForItem + }); + } + + // Validate discount balance usage + var maxDiscountBalanceUsable = totalDiscountAmount; + var actualDiscountBalanceUsed = Math.Min(request.DiscountBalanceToUse, maxDiscountBalanceUsable); + actualDiscountBalanceUsed = Math.Min(actualDiscountBalanceUsed, userWallet.DiscountBalance); + + if (actualDiscountBalanceUsed < request.DiscountBalanceToUse) + { + return new PlaceOrderResponseDto + { + Success = false, + Message = $"موجودی تخفیف کافی نیست. حداکثر قابل استفاده: {maxDiscountBalanceUsable:N0} تومان، موجودی شما: {userWallet.DiscountBalance:N0} تومان" + }; + } + + var gatewayAmountRequired = totalAmount - actualDiscountBalanceUsed; + + // Calculate VAT (9%) + var vatAmount = (gatewayAmountRequired * 9) / 100; + var finalGatewayAmount = gatewayAmountRequired + vatAmount; + + // Create transaction for gateway payment + var transaction = new Transaction + { + Amount = finalGatewayAmount, + Description = $"خرید از فروشگاه تخفیف - مبلغ کل: {totalAmount:N0}، اعتبار تخفیف: {actualDiscountBalanceUsed:N0}", + PaymentStatus = PaymentStatus.Pending, + Type = TransactionType.DiscountShopPurchase + }; + + _context.Transactions.Add(transaction); + await _context.SaveChangesAsync(cancellationToken); + + // Create order + var order = new DiscountOrder + { + UserId = request.UserId, + TotalAmount = totalAmount, + DiscountBalanceUsed = actualDiscountBalanceUsed, + GatewayAmountPaid = finalGatewayAmount, + VatAmount = vatAmount, + PaymentStatus = PaymentStatus.Pending, + TransactionId = transaction.Id, + UserAddressId = request.UserAddressId, + DeliveryStatus = DeliveryStatus.Pending + }; + + _context.DiscountOrders.Add(order); + await _context.SaveChangesAsync(cancellationToken); + + // Add order details + foreach (var detail in orderDetails) + { + detail.DiscountOrderId = order.Id; + } + + _context.DiscountOrderDetails.AddRange(orderDetails); + + // Clear cart + _context.DiscountShoppingCarts.RemoveRange(cartItems); + + await _context.SaveChangesAsync(cancellationToken); + + return new PlaceOrderResponseDto + { + Success = true, + Message = "سفارش ایجاد شد. لطفا پرداخت را تکمیل کنید", + OrderId = order.Id, + TransactionId = transaction.Id, + TotalAmount = totalAmount, + DiscountBalanceUsed = actualDiscountBalanceUsed, + GatewayAmountRequired = finalGatewayAmount + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandValidator.cs new file mode 100644 index 0000000..4af6fad --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandValidator.cs @@ -0,0 +1,18 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.PlaceOrder; + +public class PlaceOrderCommandValidator : AbstractValidator +{ + public PlaceOrderCommandValidator() + { + RuleFor(x => x.UserId) + .GreaterThan(0).WithMessage("شناسه کاربر باید مثبت باشد"); + + RuleFor(x => x.UserAddressId) + .GreaterThan(0).WithMessage("آدرس تحویل باید انتخاب شود"); + + RuleFor(x => x.DiscountBalanceToUse) + .GreaterThanOrEqualTo(0).WithMessage("مبلغ استفاده از موجودی تخفیف نمی‌تواند منفی باشد"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommand.cs new file mode 100644 index 0000000..a9c1376 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommand.cs @@ -0,0 +1,15 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.RemoveFromCart; + +public class RemoveFromCartCommand : IRequest +{ + public long UserId { get; set; } + public long ProductId { get; set; } +} + +public class RemoveFromCartResponseDto +{ + public bool Success { get; set; } + public string Message { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommandHandler.cs new file mode 100644 index 0000000..5768b77 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommandHandler.cs @@ -0,0 +1,39 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.RemoveFromCart; + +public class RemoveFromCartCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public RemoveFromCartCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(RemoveFromCartCommand request, CancellationToken cancellationToken) + { + var cartItem = await _context.DiscountShoppingCarts + .FirstOrDefaultAsync(c => c.UserId == request.UserId && c.ProductId == request.ProductId, cancellationToken); + + if (cartItem == null) + { + return new RemoveFromCartResponseDto + { + Success = false, + Message = "محصول در سبد خرید یافت نشد" + }; + } + + _context.DiscountShoppingCarts.Remove(cartItem); + await _context.SaveChangesAsync(cancellationToken); + + return new RemoveFromCartResponseDto + { + Success = true, + Message = "محصول از سبد خرید حذف شد" + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommandValidator.cs new file mode 100644 index 0000000..a5d0d97 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/RemoveFromCart/RemoveFromCartCommandValidator.cs @@ -0,0 +1,15 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.RemoveFromCart; + +public class RemoveFromCartCommandValidator : AbstractValidator +{ + public RemoveFromCartCommandValidator() + { + RuleFor(x => x.UserId) + .GreaterThan(0).WithMessage("شناسه کاربر باید مثبت باشد"); + + RuleFor(x => x.ProductId) + .GreaterThan(0).WithMessage("شناسه محصول باید مثبت باشد"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommand.cs new file mode 100644 index 0000000..fbaa770 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommand.cs @@ -0,0 +1,16 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateCartItemCount; + +public class UpdateCartItemCountCommand : IRequest +{ + public long UserId { get; set; } + public long ProductId { get; set; } + public int NewCount { get; set; } +} + +public class UpdateCartItemCountResponseDto +{ + public bool Success { get; set; } + public string Message { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommandHandler.cs new file mode 100644 index 0000000..602c65e --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommandHandler.cs @@ -0,0 +1,65 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateCartItemCount; + +public class UpdateCartItemCountCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateCartItemCountCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateCartItemCountCommand request, CancellationToken cancellationToken) + { + // پیدا کردن آیتم سبد خرید + var cartItem = await _context.DiscountShoppingCarts + .Include(c => c.Product) + .FirstOrDefaultAsync(c => c.UserId == request.UserId && c.ProductId == request.ProductId, cancellationToken); + + if (cartItem == null) + { + return new UpdateCartItemCountResponseDto + { + Success = false, + Message = "آیتم در سبد خرید یافت نشد" + }; + } + + // بررسی موجودی محصول + if (request.NewCount > cartItem.Product.RemainingCount) + { + return new UpdateCartItemCountResponseDto + { + Success = false, + Message = $"موجودی محصول کافی نیست. موجودی فعلی: {cartItem.Product.RemainingCount}" + }; + } + + // اگر تعداد جدید صفر یا منفی باشد، آیتم را حذف کن + if (request.NewCount <= 0) + { + _context.DiscountShoppingCarts.Remove(cartItem); + await _context.SaveChangesAsync(cancellationToken); + + return new UpdateCartItemCountResponseDto + { + Success = true, + Message = "محصول از سبد خرید حذف شد" + }; + } + + // به‌روزرسانی تعداد + cartItem.Count = request.NewCount; + await _context.SaveChangesAsync(cancellationToken); + + return new UpdateCartItemCountResponseDto + { + Success = true, + Message = "تعداد محصول به‌روزرسانی شد" + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommandValidator.cs new file mode 100644 index 0000000..3d97362 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateCartItemCount/UpdateCartItemCountCommandValidator.cs @@ -0,0 +1,18 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateCartItemCount; + +public class UpdateCartItemCountCommandValidator : AbstractValidator +{ + public UpdateCartItemCountCommandValidator() + { + RuleFor(x => x.UserId) + .GreaterThan(0).WithMessage("شناسه کاربر باید مثبت باشد"); + + RuleFor(x => x.ProductId) + .GreaterThan(0).WithMessage("شناسه محصول باید مثبت باشد"); + + RuleFor(x => x.NewCount) + .GreaterThanOrEqualTo(0).WithMessage("تعداد نمی‌تواند منفی باشد"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommand.cs new file mode 100644 index 0000000..d7985f6 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommand.cs @@ -0,0 +1,15 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountCategory; + +public class UpdateDiscountCategoryCommand : IRequest +{ + public long CategoryId { get; set; } + public string Name { get; set; } + public string Title { get; set; } + public string? Description { get; set; } + public string? ImagePath { get; set; } + public long? ParentCategoryId { get; set; } + public int SortOrder { get; set; } + public bool IsActive { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandHandler.cs new file mode 100644 index 0000000..2730a4e --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandHandler.cs @@ -0,0 +1,90 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountCategory; + +public class UpdateDiscountCategoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateDiscountCategoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateDiscountCategoryCommand request, CancellationToken cancellationToken) + { + var category = await _context.DiscountCategories + .FirstOrDefaultAsync(c => c.Id == request.CategoryId, cancellationToken); + + if (category == null) + { + return false; + } + + // بررسی وجود دسته‌بندی دیگری با همین نام (به جز خودش) + var duplicateName = await _context.DiscountCategories + .AnyAsync(c => c.Name == request.Name && c.Id != request.CategoryId, cancellationToken); + + if (duplicateName) + { + throw new InvalidOperationException("دسته‌بندی دیگری با این نام وجود دارد"); + } + + // بررسی عدم ایجاد حلقه در سلسله مراتب + if (request.ParentCategoryId.HasValue) + { + if (request.ParentCategoryId.Value == request.CategoryId) + { + throw new InvalidOperationException("دسته‌بندی نمی‌تواند والد خودش باشد"); + } + + // بررسی وجود دسته‌بندی والد + var parentExists = await _context.DiscountCategories + .AnyAsync(c => c.Id == request.ParentCategoryId.Value, cancellationToken); + + if (!parentExists) + { + throw new InvalidOperationException("دسته‌بندی والد یافت نشد"); + } + + // بررسی اینکه والد جدید زیرمجموعه این دسته‌بندی نباشد + var isDescendant = await IsDescendant(request.ParentCategoryId.Value, request.CategoryId, cancellationToken); + if (isDescendant) + { + throw new InvalidOperationException("دسته‌بندی والد نمی‌تواند زیرمجموعه این دسته‌بندی باشد"); + } + } + + category.Name = request.Name; + category.Title = request.Title; + category.Description = request.Description; + category.ImagePath = request.ImagePath; + category.ParentCategoryId = request.ParentCategoryId; + category.SortOrder = request.SortOrder; + category.IsActive = request.IsActive; + + await _context.SaveChangesAsync(cancellationToken); + + return true; + } + + private async Task IsDescendant(long potentialDescendantId, long ancestorId, CancellationToken cancellationToken) + { + var category = await _context.DiscountCategories + .FirstOrDefaultAsync(c => c.Id == potentialDescendantId, cancellationToken); + + if (category == null || !category.ParentCategoryId.HasValue) + { + return false; + } + + if (category.ParentCategoryId.Value == ancestorId) + { + return true; + } + + return await IsDescendant(category.ParentCategoryId.Value, ancestorId, cancellationToken); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandValidator.cs new file mode 100644 index 0000000..e62a86f --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandValidator.cs @@ -0,0 +1,35 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountCategory; + +public class UpdateDiscountCategoryCommandValidator : AbstractValidator +{ + public UpdateDiscountCategoryCommandValidator() + { + RuleFor(x => x.CategoryId) + .GreaterThan(0).WithMessage("شناسه دسته‌بندی باید مثبت باشد"); + + RuleFor(x => x.Name) + .NotEmpty().WithMessage("نام دسته‌بندی الزامی است") + .MaximumLength(100).WithMessage("نام دسته‌بندی نباید بیشتر از 100 کاراکتر باشد"); + + RuleFor(x => x.Title) + .NotEmpty().WithMessage("عنوان دسته‌بندی الزامی است") + .MaximumLength(200).WithMessage("عنوان دسته‌بندی نباید بیشتر از 200 کاراکتر باشد"); + + RuleFor(x => x.Description) + .MaximumLength(1000).WithMessage("توضیحات نباید بیشتر از 1000 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.Description)); + + RuleFor(x => x.ImagePath) + .MaximumLength(500).WithMessage("مسیر تصویر نباید بیشتر از 500 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.ImagePath)); + + RuleFor(x => x.ParentCategoryId) + .GreaterThan(0).WithMessage("شناسه دسته‌بندی والد باید مثبت باشد") + .When(x => x.ParentCategoryId.HasValue); + + RuleFor(x => x.SortOrder) + .GreaterThanOrEqualTo(0).WithMessage("ترتیب نمایش نمی‌تواند منفی باشد"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommand.cs new file mode 100644 index 0000000..a071314 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommand.cs @@ -0,0 +1,18 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProduct; + +public class UpdateDiscountProductCommand : IRequest +{ + public long ProductId { get; set; } + public string Title { get; set; } + public string ShortInfomation { get; set; } + public string FullInformation { get; set; } + public long Price { get; set; } + public int MaxDiscountPercent { get; set; } + public string ImagePath { get; set; } + public string ThumbnailPath { get; set; } + public int RemainingCount { get; set; } + public bool IsActive { get; set; } + public List CategoryIds { get; set; } = new(); +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommandHandler.cs new file mode 100644 index 0000000..19252ad --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommandHandler.cs @@ -0,0 +1,57 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities.DiscountShop; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProduct; + +public class UpdateDiscountProductCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateDiscountProductCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateDiscountProductCommand request, CancellationToken cancellationToken) + { + var product = await _context.DiscountProducts + .FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken); + + if (product == null) + throw new Exception("محصول یافت نشد"); + + product.Title = request.Title; + product.ShortInfomation = request.ShortInfomation; + product.FullInformation = request.FullInformation; + product.Price = request.Price; + product.MaxDiscountPercent = request.MaxDiscountPercent; + product.ImagePath = request.ImagePath; + product.ThumbnailPath = request.ThumbnailPath; + product.RemainingCount = request.RemainingCount; + product.IsActive = request.IsActive; + + // Update categories + var existingCategories = await _context.DiscountProductCategories + .Where(pc => pc.ProductId == request.ProductId) + .ToListAsync(cancellationToken); + + _context.DiscountProductCategories.RemoveRange(existingCategories); + + if (request.CategoryIds.Any()) + { + var newCategories = request.CategoryIds.Select(categoryId => new DiscountProductCategory + { + ProductId = product.Id, + CategoryId = categoryId + }).ToList(); + + _context.DiscountProductCategories.AddRange(newCategories); + } + + await _context.SaveChangesAsync(cancellationToken); + + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommandValidator.cs new file mode 100644 index 0000000..6d3f818 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProduct/UpdateDiscountProductCommandValidator.cs @@ -0,0 +1,45 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProduct; + +public class UpdateDiscountProductCommandValidator : AbstractValidator +{ + public UpdateDiscountProductCommandValidator() + { + RuleFor(x => x.ProductId) + .GreaterThan(0).WithMessage("شناسه محصول باید مثبت باشد"); + + RuleFor(x => x.Title) + .NotEmpty().WithMessage("عنوان محصول الزامی است") + .MaximumLength(200).WithMessage("عنوان محصول نباید بیشتر از 200 کاراکتر باشد"); + + RuleFor(x => x.ShortInfomation) + .NotEmpty().WithMessage("توضیحات کوتاه الزامی است") + .MaximumLength(500).WithMessage("توضیحات کوتاه نباید بیشتر از 500 کاراکتر باشد"); + + RuleFor(x => x.FullInformation) + .NotEmpty().WithMessage("توضیحات کامل الزامی است") + .MaximumLength(5000).WithMessage("توضیحات کامل نباید بیشتر از 5000 کاراکتر باشد"); + + RuleFor(x => x.Price) + .GreaterThan(0).WithMessage("قیمت باید بزرگتر از صفر باشد"); + + RuleFor(x => x.MaxDiscountPercent) + .InclusiveBetween(0, 100).WithMessage("درصد تخفیف باید بین 0 تا 100 باشد"); + + RuleFor(x => x.ImagePath) + .NotEmpty().WithMessage("مسیر تصویر اصلی الزامی است") + .MaximumLength(500).WithMessage("مسیر تصویر نباید بیشتر از 500 کاراکتر باشد"); + + RuleFor(x => x.ThumbnailPath) + .NotEmpty().WithMessage("مسیر تصویر بندانگشتی الزامی است") + .MaximumLength(500).WithMessage("مسیر تصویر نباید بیشتر از 500 کاراکتر باشد"); + + RuleFor(x => x.RemainingCount) + .GreaterThanOrEqualTo(0).WithMessage("موجودی نمی‌تواند منفی باشد"); + + RuleFor(x => x.CategoryIds) + .NotEmpty().WithMessage("حداقل یک دسته‌بندی باید انتخاب شود") + .Must(ids => ids.All(id => id > 0)).WithMessage("شناسه دسته‌بندی‌ها باید مثبت باشند"); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommand.cs new file mode 100644 index 0000000..613e0fa --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommand.cs @@ -0,0 +1,18 @@ +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateOrderStatus; + +public class UpdateOrderStatusCommand : IRequest +{ + public long OrderId { get; set; } + public DeliveryStatus DeliveryStatus { get; set; } + public string? TrackingCode { get; set; } + public string? AdminNotes { get; set; } +} + +public class UpdateOrderStatusResponseDto +{ + public bool Success { get; set; } + public string Message { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandHandler.cs new file mode 100644 index 0000000..2016ba9 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandHandler.cs @@ -0,0 +1,46 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateOrderStatus; + +public class UpdateOrderStatusCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateOrderStatusCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateOrderStatusCommand request, CancellationToken cancellationToken) + { + var order = await _context.DiscountOrders + .FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken); + + if (order == null) + { + return new UpdateOrderStatusResponseDto + { + Success = false, + Message = "سفارش یافت نشد" + }; + } + + // به‌روزرسانی وضعیت + order.DeliveryStatus = request.DeliveryStatus; + + if (!string.IsNullOrEmpty(request.TrackingCode)) + { + order.TrackingCode = request.TrackingCode; + } + + await _context.SaveChangesAsync(cancellationToken); + + return new UpdateOrderStatusResponseDto + { + Success = true, + Message = "وضعیت سفارش به‌روزرسانی شد" + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandValidator.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandValidator.cs new file mode 100644 index 0000000..23e1237 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandValidator.cs @@ -0,0 +1,19 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateOrderStatus; + +public class UpdateOrderStatusCommandValidator : AbstractValidator +{ + public UpdateOrderStatusCommandValidator() + { + RuleFor(x => x.OrderId) + .GreaterThan(0).WithMessage("شناسه سفارش باید مثبت باشد"); + + RuleFor(x => x.DeliveryStatus) + .IsInEnum().WithMessage("وضعیت ارسال نامعتبر است"); + + RuleFor(x => x.TrackingCode) + .MaximumLength(50).WithMessage("کد رهگیری نباید بیشتر از 50 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.TrackingCode)); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountCategories/GetDiscountCategoriesQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountCategories/GetDiscountCategoriesQuery.cs new file mode 100644 index 0000000..2817db1 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountCategories/GetDiscountCategoriesQuery.cs @@ -0,0 +1,28 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountCategories; + +public class GetDiscountCategoriesQuery : IRequest +{ + public long? ParentCategoryId { get; set; } + public bool? IsActive { get; set; } +} + +public class GetDiscountCategoriesResponseDto +{ + public List Categories { get; set; } +} + +public class DiscountCategoryDto +{ + public long Id { get; set; } + public string Name { get; set; } + public string Title { get; set; } + public string? Description { get; set; } + public string? ImagePath { get; set; } + public long? ParentCategoryId { get; set; } + public int SortOrder { get; set; } + public bool IsActive { get; set; } + public int ProductCount { get; set; } + public List? Children { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountCategories/GetDiscountCategoriesQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountCategories/GetDiscountCategoriesQueryHandler.cs new file mode 100644 index 0000000..d87c44b --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountCategories/GetDiscountCategoriesQueryHandler.cs @@ -0,0 +1,99 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountCategories; + +public class GetDiscountCategoriesQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetDiscountCategoriesQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetDiscountCategoriesQuery request, CancellationToken cancellationToken) + { + var query = _context.DiscountCategories.AsQueryable(); + + // فیلتر بر اساس ParentCategoryId + if (request.ParentCategoryId.HasValue) + { + query = query.Where(c => c.ParentCategoryId == request.ParentCategoryId.Value); + } + else + { + // اگر ParentCategoryId مشخص نشده، فقط دسته‌های اصلی (بدون والد) را برگردان + query = query.Where(c => c.ParentCategoryId == null); + } + + // فیلتر بر اساس وضعیت فعال + if (request.IsActive.HasValue) + { + query = query.Where(c => c.IsActive == request.IsActive.Value); + } + + var categories = await query + .OrderBy(c => c.SortOrder) + .ThenBy(c => c.Title) + .Select(c => new DiscountCategoryDto + { + Id = c.Id, + Name = c.Name, + Title = c.Title, + Description = c.Description, + ImagePath = c.ImagePath, + ParentCategoryId = c.ParentCategoryId, + SortOrder = c.SortOrder, + IsActive = c.IsActive, + ProductCount = _context.DiscountProductCategories.Count(pc => pc.CategoryId == c.Id) + }) + .ToListAsync(cancellationToken); + + // بارگذاری زیرمجموعه‌ها به صورت بازگشتی + foreach (var category in categories) + { + category.Children = await LoadChildren(category.Id, request.IsActive, cancellationToken); + } + + return new GetDiscountCategoriesResponseDto + { + Categories = categories + }; + } + + private async Task> LoadChildren(long parentId, bool? isActive, CancellationToken cancellationToken) + { + var query = _context.DiscountCategories.Where(c => c.ParentCategoryId == parentId); + + if (isActive.HasValue) + { + query = query.Where(c => c.IsActive == isActive.Value); + } + + var children = await query + .OrderBy(c => c.SortOrder) + .ThenBy(c => c.Title) + .Select(c => new DiscountCategoryDto + { + Id = c.Id, + Name = c.Name, + Title = c.Title, + Description = c.Description, + ImagePath = c.ImagePath, + ParentCategoryId = c.ParentCategoryId, + SortOrder = c.SortOrder, + IsActive = c.IsActive, + ProductCount = _context.DiscountProductCategories.Count(pc => pc.CategoryId == c.Id) + }) + .ToListAsync(cancellationToken); + + foreach (var child in children) + { + child.Children = await LoadChildren(child.Id, isActive, cancellationToken); + } + + return children; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductById/GetDiscountProductByIdQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductById/GetDiscountProductByIdQuery.cs new file mode 100644 index 0000000..462aa24 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductById/GetDiscountProductByIdQuery.cs @@ -0,0 +1,33 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProductById; + +public class GetDiscountProductByIdQuery : IRequest +{ + public long ProductId { get; set; } +} + +public class DiscountProductDetailDto +{ + public long Id { get; set; } + public string Title { get; set; } + public string ShortInfomation { get; set; } + public string FullInformation { get; set; } + public long Price { get; set; } + public int MaxDiscountPercent { get; set; } + public int Rate { get; set; } + public string ImagePath { get; set; } + public string ThumbnailPath { get; set; } + public int SaleCount { get; set; } + public int ViewCount { get; set; } + public int RemainingCount { get; set; } + public bool IsActive { get; set; } + public List Categories { get; set; } = new(); +} + +public class CategoryDto +{ + public long Id { get; set; } + public string Name { get; set; } + public string Title { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductById/GetDiscountProductByIdQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductById/GetDiscountProductByIdQueryHandler.cs new file mode 100644 index 0000000..b8a6885 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductById/GetDiscountProductByIdQueryHandler.cs @@ -0,0 +1,64 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProductById; + +public class GetDiscountProductByIdQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetDiscountProductByIdQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetDiscountProductByIdQuery request, CancellationToken cancellationToken) + { + var product = await _context.DiscountProducts + .Where(p => p.Id == request.ProductId) + .Select(p => new DiscountProductDetailDto + { + Id = p.Id, + Title = p.Title, + ShortInfomation = p.ShortInfomation, + FullInformation = p.FullInformation, + Price = p.Price, + MaxDiscountPercent = p.MaxDiscountPercent, + Rate = p.Rate, + ImagePath = p.ImagePath, + ThumbnailPath = p.ThumbnailPath, + SaleCount = p.SaleCount, + ViewCount = p.ViewCount, + RemainingCount = p.RemainingCount, + IsActive = p.IsActive + }) + .FirstOrDefaultAsync(cancellationToken); + + if (product == null) + return null; + + // Get categories + var categories = await _context.DiscountProductCategories + .Where(pc => pc.ProductId == request.ProductId) + .Select(pc => new CategoryDto + { + Id = pc.Category.Id, + Name = pc.Category.Name, + Title = pc.Category.Title + }) + .ToListAsync(cancellationToken); + + product.Categories = categories; + + // Increment view count + var productEntity = await _context.DiscountProducts.FindAsync(new object[] { request.ProductId }, cancellationToken); + if (productEntity != null) + { + productEntity.ViewCount++; + await _context.SaveChangesAsync(cancellationToken); + } + + return product; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProducts/GetDiscountProductsQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProducts/GetDiscountProductsQuery.cs new file mode 100644 index 0000000..e094519 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProducts/GetDiscountProductsQuery.cs @@ -0,0 +1,36 @@ +using CMSMicroservice.Application.Common.Models; +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProducts; + +public class GetDiscountProductsQuery : IRequest +{ + public PaginationState? PaginationQuery { get; set; } + public long? CategoryId { get; set; } + public string? SearchTerm { get; set; } + public bool? IsActive { get; set; } + public int? MinPrice { get; set; } + public int? MaxPrice { get; set; } +} + +public class GetDiscountProductsResponseDto +{ + public MetaData MetaData { get; set; } + public List Models { get; set; } +} + +public class DiscountProductDto +{ + public long Id { get; set; } + public string Title { get; set; } + public string ShortInfomation { get; set; } + public long Price { get; set; } + public int MaxDiscountPercent { get; set; } + public int Rate { get; set; } + public string ImagePath { get; set; } + public string ThumbnailPath { get; set; } + public int SaleCount { get; set; } + public int ViewCount { get; set; } + public int RemainingCount { get; set; } + public bool IsActive { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProducts/GetDiscountProductsQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProducts/GetDiscountProductsQueryHandler.cs new file mode 100644 index 0000000..6b3f7c7 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProducts/GetDiscountProductsQueryHandler.cs @@ -0,0 +1,92 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProducts; + +public class GetDiscountProductsQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetDiscountProductsQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetDiscountProductsQuery request, CancellationToken cancellationToken) + { + var query = _context.DiscountProducts.AsQueryable(); + + // Apply filters + if (request.CategoryId.HasValue) + { + var productIds = await _context.DiscountProductCategories + .Where(pc => pc.CategoryId == request.CategoryId.Value) + .Select(pc => pc.ProductId) + .ToListAsync(cancellationToken); + + query = query.Where(p => productIds.Contains(p.Id)); + } + + if (!string.IsNullOrWhiteSpace(request.SearchTerm)) + { + query = query.Where(p => + p.Title.Contains(request.SearchTerm) || + p.ShortInfomation.Contains(request.SearchTerm)); + } + + if (request.IsActive.HasValue) + { + query = query.Where(p => p.IsActive == request.IsActive.Value); + } + + if (request.MinPrice.HasValue) + { + query = query.Where(p => p.Price >= request.MinPrice.Value); + } + + if (request.MaxPrice.HasValue) + { + query = query.Where(p => p.Price <= request.MaxPrice.Value); + } + + var totalCount = await query.CountAsync(cancellationToken); + + // Apply pagination + var pagination = request.PaginationQuery ?? new PaginationState { PageNumber = 1, PageSize = 10 }; + + var products = await query + .OrderByDescending(p => p.Created) + .Skip((pagination.PageNumber - 1) * pagination.PageSize) + .Take(pagination.PageSize) + .Select(p => new DiscountProductDto + { + Id = p.Id, + Title = p.Title, + ShortInfomation = p.ShortInfomation, + Price = p.Price, + MaxDiscountPercent = p.MaxDiscountPercent, + Rate = p.Rate, + ImagePath = p.ImagePath, + ThumbnailPath = p.ThumbnailPath, + SaleCount = p.SaleCount, + ViewCount = p.ViewCount, + RemainingCount = p.RemainingCount, + IsActive = p.IsActive + }) + .ToListAsync(cancellationToken); + + return new GetDiscountProductsResponseDto + { + MetaData = new MetaData + { + TotalCount = totalCount, + PageSize = pagination.PageSize, + CurrentPage = pagination.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)pagination.PageSize) + }, + Models = products + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetOrderById/GetOrderByIdQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetOrderById/GetOrderByIdQuery.cs new file mode 100644 index 0000000..ead7df8 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetOrderById/GetOrderByIdQuery.cs @@ -0,0 +1,46 @@ +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetOrderById; + +public class GetOrderByIdQuery : IRequest +{ + public long OrderId { get; set; } + public long UserId { get; set; } +} + +public class OrderDetailDto +{ + public long Id { get; set; } + public long UserId { get; set; } + public long TotalAmount { get; set; } + public long DiscountBalanceUsed { get; set; } + public long GatewayAmountPaid { get; set; } + public long VatAmount { get; set; } + public PaymentStatus PaymentStatus { get; set; } + public DateTime? PaymentDate { get; set; } + public DeliveryStatus DeliveryStatus { get; set; } + public string? TrackingCode { get; set; } + public string? DeliveryDescription { get; set; } + public DateTime Created { get; set; } + public UserAddressDto Address { get; set; } + public List Items { get; set; } = new(); +} + +public class UserAddressDto +{ + public string Title { get; set; } + public string Address { get; set; } + public string PostalCode { get; set; } +} + +public class OrderItemDto +{ + public long ProductId { get; set; } + public string ProductTitle { get; set; } + public int Count { get; set; } + public long UnitPrice { get; set; } + public int DiscountPercentUsed { get; set; } + public long DiscountAmount { get; set; } + public long FinalPrice { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetOrderById/GetOrderByIdQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetOrderById/GetOrderByIdQueryHandler.cs new file mode 100644 index 0000000..a5e7292 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetOrderById/GetOrderByIdQueryHandler.cs @@ -0,0 +1,60 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetOrderById; + +public class GetOrderByIdQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetOrderByIdQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetOrderByIdQuery request, CancellationToken cancellationToken) + { + var order = await _context.DiscountOrders + .Where(o => o.Id == request.OrderId && o.UserId == request.UserId) + .Include(o => o.UserAddress) + .Include(o => o.OrderDetails) + .ThenInclude(od => od.Product) + .FirstOrDefaultAsync(cancellationToken); + + if (order == null) + return null; + + return new OrderDetailDto + { + Id = order.Id, + UserId = order.UserId, + TotalAmount = order.TotalAmount, + DiscountBalanceUsed = order.DiscountBalanceUsed, + GatewayAmountPaid = order.GatewayAmountPaid, + VatAmount = order.VatAmount, + PaymentStatus = order.PaymentStatus, + PaymentDate = order.PaymentDate, + DeliveryStatus = order.DeliveryStatus, + TrackingCode = order.TrackingCode, + DeliveryDescription = order.DeliveryDescription, + Created = order.Created, + Address = new UserAddressDto + { + Title = order.UserAddress.Title, + Address = order.UserAddress.Address, + PostalCode = order.UserAddress.PostalCode + }, + Items = order.OrderDetails.Select(od => new OrderItemDto + { + ProductId = od.ProductId, + ProductTitle = od.Product.Title, + Count = od.Count, + UnitPrice = od.UnitPrice, + DiscountPercentUsed = od.DiscountPercentUsed, + DiscountAmount = od.DiscountAmount, + FinalPrice = od.FinalPrice + }).ToList() + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserCart/GetUserCartQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserCart/GetUserCartQuery.cs new file mode 100644 index 0000000..647a13e --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserCart/GetUserCartQuery.cs @@ -0,0 +1,32 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetUserCart; + +public class GetUserCartQuery : IRequest +{ + public long UserId { get; set; } +} + +public class UserCartDto +{ + public List Items { get; set; } = new(); + public long TotalAmount { get; set; } + public long MaxDiscountAmount { get; set; } + public long MinPayableAmount { get; set; } +} + +public class CartItemDto +{ + public long CartItemId { get; set; } + public long ProductId { get; set; } + public string ProductTitle { get; set; } + public string ProductImagePath { get; set; } + public long UnitPrice { get; set; } + public int Count { get; set; } + public long SubTotal { get; set; } + public int MaxDiscountPercent { get; set; } + public long MaxDiscountAmount { get; set; } + public long MinPayable { get; set; } + public int RemainingStock { get; set; } + public bool IsActive { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserCart/GetUserCartQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserCart/GetUserCartQueryHandler.cs new file mode 100644 index 0000000..a0904b6 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserCart/GetUserCartQueryHandler.cs @@ -0,0 +1,50 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetUserCart; + +public class GetUserCartQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetUserCartQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetUserCartQuery request, CancellationToken cancellationToken) + { + var cartItems = await _context.DiscountShoppingCarts + .Where(c => c.UserId == request.UserId) + .Include(c => c.Product) + .Select(c => new CartItemDto + { + CartItemId = c.Id, + ProductId = c.ProductId, + ProductTitle = c.Product.Title, + ProductImagePath = c.Product.ThumbnailPath, + UnitPrice = c.Product.Price, + Count = c.Count, + SubTotal = c.Product.Price * c.Count, + MaxDiscountPercent = c.Product.MaxDiscountPercent, + MaxDiscountAmount = (c.Product.Price * c.Count * c.Product.MaxDiscountPercent) / 100, + MinPayable = c.Product.Price * c.Count - ((c.Product.Price * c.Count * c.Product.MaxDiscountPercent) / 100), + RemainingStock = c.Product.RemainingCount, + IsActive = c.Product.IsActive + }) + .ToListAsync(cancellationToken); + + var totalAmount = cartItems.Sum(i => i.SubTotal); + var maxDiscountAmount = cartItems.Sum(i => i.MaxDiscountAmount); + var minPayableAmount = cartItems.Sum(i => i.MinPayable); + + return new UserCartDto + { + Items = cartItems, + TotalAmount = totalAmount, + MaxDiscountAmount = maxDiscountAmount, + MinPayableAmount = minPayableAmount + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserOrders/GetUserOrdersQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserOrders/GetUserOrdersQuery.cs new file mode 100644 index 0000000..18a5340 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserOrders/GetUserOrdersQuery.cs @@ -0,0 +1,34 @@ +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetUserOrders; + +public class GetUserOrdersQuery : IRequest +{ + public long UserId { get; set; } + public PaginationState? PaginationQuery { get; set; } + public PaymentStatus? PaymentStatus { get; set; } + public DeliveryStatus? DeliveryStatus { get; set; } +} + +public class GetUserOrdersResponseDto +{ + public MetaData MetaData { get; set; } + public List Models { get; set; } +} + +public class OrderSummaryDto +{ + public long Id { get; set; } + public long TotalAmount { get; set; } + public long DiscountBalanceUsed { get; set; } + public long GatewayAmountPaid { get; set; } + public long VatAmount { get; set; } + public PaymentStatus PaymentStatus { get; set; } + public DateTime? PaymentDate { get; set; } + public DeliveryStatus DeliveryStatus { get; set; } + public string? TrackingCode { get; set; } + public DateTime Created { get; set; } + public int ItemsCount { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserOrders/GetUserOrdersQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserOrders/GetUserOrdersQueryHandler.cs new file mode 100644 index 0000000..4a892bd --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetUserOrders/GetUserOrdersQueryHandler.cs @@ -0,0 +1,70 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetUserOrders; + +public class GetUserOrdersQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetUserOrdersQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetUserOrdersQuery request, CancellationToken cancellationToken) + { + var query = _context.DiscountOrders + .Where(o => o.UserId == request.UserId); + + // Apply filters + if (request.PaymentStatus.HasValue) + { + query = query.Where(o => o.PaymentStatus == request.PaymentStatus.Value); + } + + if (request.DeliveryStatus.HasValue) + { + query = query.Where(o => o.DeliveryStatus == request.DeliveryStatus.Value); + } + + var totalCount = await query.CountAsync(cancellationToken); + + // Apply pagination + var pagination = request.PaginationQuery ?? new PaginationState { PageNumber = 1, PageSize = 10 }; + + var orders = await query + .OrderByDescending(o => o.Created) + .Skip((pagination.PageNumber - 1) * pagination.PageSize) + .Take(pagination.PageSize) + .Select(o => new OrderSummaryDto + { + Id = o.Id, + TotalAmount = o.TotalAmount, + DiscountBalanceUsed = o.DiscountBalanceUsed, + GatewayAmountPaid = o.GatewayAmountPaid, + VatAmount = o.VatAmount, + PaymentStatus = o.PaymentStatus, + PaymentDate = o.PaymentDate, + DeliveryStatus = o.DeliveryStatus, + TrackingCode = o.TrackingCode, + Created = o.Created, + ItemsCount = o.OrderDetails.Count + }) + .ToListAsync(cancellationToken); + + return new GetUserOrdersResponseDto + { + MetaData = new MetaData + { + TotalCount = totalCount, + PageSize = pagination.PageSize, + CurrentPage = pagination.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)pagination.PageSize) + }, + Models = orders + }; + } +} diff --git a/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/CreateNewFactorDetails/CreateNewFactorDetailsCommandHandler.cs b/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/CreateNewFactorDetails/CreateNewFactorDetailsCommandHandler.cs index 0e327cc..db7a747 100644 --- a/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/CreateNewFactorDetails/CreateNewFactorDetailsCommandHandler.cs +++ b/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/CreateNewFactorDetails/CreateNewFactorDetailsCommandHandler.cs @@ -13,7 +13,7 @@ public class CreateNewFactorDetailsCommandHandler : IRequestHandler(); - await _context.FactorDetailss.AddAsync(entity, cancellationToken); + await _context.FactorDetails.AddAsync(entity, cancellationToken); entity.AddDomainEvent(new CreateNewFactorDetailsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return entity.Adapt(); diff --git a/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/DeleteFactorDetails/DeleteFactorDetailsCommandHandler.cs b/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/DeleteFactorDetails/DeleteFactorDetailsCommandHandler.cs index a64f1fc..4de557f 100644 --- a/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/DeleteFactorDetails/DeleteFactorDetailsCommandHandler.cs +++ b/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/DeleteFactorDetails/DeleteFactorDetailsCommandHandler.cs @@ -11,10 +11,10 @@ public class DeleteFactorDetailsCommandHandler : IRequestHandler Handle(DeleteFactorDetailsCommand request, CancellationToken cancellationToken) { - var entity = await _context.FactorDetailss + var entity = await _context.FactorDetails .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(FactorDetails), request.Id); entity.IsDeleted = true; - _context.FactorDetailss.Update(entity); + _context.FactorDetails.Update(entity); entity.AddDomainEvent(new DeleteFactorDetailsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/UpdateFactorDetails/UpdateFactorDetailsCommandHandler.cs b/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/UpdateFactorDetails/UpdateFactorDetailsCommandHandler.cs index 5976b23..acc741a 100644 --- a/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/UpdateFactorDetails/UpdateFactorDetailsCommandHandler.cs +++ b/src/CMSMicroservice.Application/FactorDetailsCQ/Commands/UpdateFactorDetails/UpdateFactorDetailsCommandHandler.cs @@ -11,10 +11,10 @@ public class UpdateFactorDetailsCommandHandler : IRequestHandler Handle(UpdateFactorDetailsCommand request, CancellationToken cancellationToken) { - var entity = await _context.FactorDetailss + var entity = await _context.FactorDetails .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(FactorDetails), request.Id); request.Adapt(entity); - _context.FactorDetailss.Update(entity); + _context.FactorDetails.Update(entity); entity.AddDomainEvent(new UpdateFactorDetailsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetAllFactorDetailsByFilter/GetAllFactorDetailsByFilterQueryHandler.cs b/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetAllFactorDetailsByFilter/GetAllFactorDetailsByFilterQueryHandler.cs index 4e7e716..a36f69d 100644 --- a/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetAllFactorDetailsByFilter/GetAllFactorDetailsByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetAllFactorDetailsByFilter/GetAllFactorDetailsByFilterQueryHandler.cs @@ -10,7 +10,7 @@ public class GetAllFactorDetailsByFilterQueryHandler : IRequestHandler Handle(GetAllFactorDetailsByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.FactorDetailss + var query = _context.FactorDetails .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); diff --git a/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetFactorDetails/GetFactorDetailsQueryHandler.cs b/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetFactorDetails/GetFactorDetailsQueryHandler.cs index ce7f6f2..9f023f9 100644 --- a/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetFactorDetails/GetFactorDetailsQueryHandler.cs +++ b/src/CMSMicroservice.Application/FactorDetailsCQ/Queries/GetFactorDetails/GetFactorDetailsQueryHandler.cs @@ -11,7 +11,7 @@ public class GetFactorDetailsQueryHandler : IRequestHandler Handle(GetFactorDetailsQuery request, CancellationToken cancellationToken) { - var response = await _context.FactorDetailss + var response = await _context.FactorDetails .AsNoTracking() .Where(x => x.Id == request.Id) .ProjectToType() diff --git a/src/CMSMicroservice.Application/GlobalUsings.cs b/src/CMSMicroservice.Application/GlobalUsings.cs index a4f52a1..1b65fed 100644 --- a/src/CMSMicroservice.Application/GlobalUsings.cs +++ b/src/CMSMicroservice.Application/GlobalUsings.cs @@ -1,6 +1,7 @@ global using MediatR; global using FluentValidation; global using Mapster; +global using Microsoft.Extensions.Logging; global using CMSMicroservice.Domain.Entities; global using CMSMicroservice.Domain.Entities.Club; diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/ApproveManualPayment/ApproveManualPaymentCommand.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/ApproveManualPayment/ApproveManualPaymentCommand.cs new file mode 100644 index 0000000..7ff16cc --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/ApproveManualPayment/ApproveManualPaymentCommand.cs @@ -0,0 +1,19 @@ +using MediatR; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Commands.ApproveManualPayment; + +/// +/// دستور تایید پرداخت دستی توسط SuperAdmin +/// +public class ApproveManualPaymentCommand : IRequest +{ + /// + /// شناسه ManualPayment + /// + public long ManualPaymentId { get; set; } + + /// + /// یادداشت تایید (اختیاری) + /// + public string? ApprovalNote { get; set; } +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/ApproveManualPayment/ApproveManualPaymentCommandHandler.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/ApproveManualPayment/ApproveManualPaymentCommandHandler.cs new file mode 100644 index 0000000..99f8938 --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/ApproveManualPayment/ApproveManualPaymentCommandHandler.cs @@ -0,0 +1,261 @@ +using CMSMicroservice.Application.Common.Exceptions; +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using CMSMicroservice.Domain.Entities.Payment; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Commands.ApproveManualPayment; + +public class ApproveManualPaymentCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public ApproveManualPaymentCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle( + ApproveManualPaymentCommand request, + CancellationToken cancellationToken) + { + try + { + _logger.LogInformation( + "Approving manual payment: {ManualPaymentId}", + request.ManualPaymentId + ); + + // 1. پیدا کردن ManualPayment + var manualPayment = await _context.ManualPayments + .Include(m => m.User) + .FirstOrDefaultAsync(m => m.Id == request.ManualPaymentId, cancellationToken); + + if (manualPayment == null) + { + _logger.LogWarning("ManualPayment not found: {Id}", request.ManualPaymentId); + throw new NotFoundException(nameof(ManualPayment), request.ManualPaymentId); + } + + // 2. بررسی وضعیت + if (manualPayment.Status != ManualPaymentStatus.Pending) + { + _logger.LogWarning( + "ManualPayment {Id} is not in Pending status: {Status}", + request.ManualPaymentId, + manualPayment.Status + ); + throw new BadRequestException($"فقط درخواست‌های در وضعیت Pending قابل تایید هستند. وضعیت فعلی: {manualPayment.Status}"); + } + + // 3. بررسی SuperAdmin + var currentUserId = _currentUser.UserId; + if (string.IsNullOrEmpty(currentUserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + if (!long.TryParse(currentUserId, out var approvedById)) + { + throw new UnauthorizedAccessException("شناسه کاربر نامعتبر است"); + } + + // 4. پیدا کردن Wallet کاربر + var wallet = await _context.UserWallets + .FirstOrDefaultAsync(w => w.UserId == manualPayment.UserId, cancellationToken); + + if (wallet == null) + { + _logger.LogError("Wallet not found for UserId: {UserId}", manualPayment.UserId); + throw new NotFoundException($"کیف پول کاربر {manualPayment.UserId} یافت نشد"); + } + + // 5. ایجاد Transaction + var transaction = new Transaction + { + Amount = manualPayment.Amount, + Description = $"پرداخت دستی - {manualPayment.Type} - {manualPayment.Description}", + PaymentStatus = PaymentStatus.Success, + PaymentDate = DateTime.UtcNow, + RefId = manualPayment.ReferenceNumber, + Type = MapToTransactionType(manualPayment.Type) + }; + + _context.Transactions.Add(transaction); + await _context.SaveChangesAsync(cancellationToken); + + // 6. اعمال تغییرات بر کیف پول + var oldBalance = wallet.Balance; + var oldDiscountBalance = wallet.DiscountBalance; + var oldNetworkBalance = wallet.NetworkBalance; + + switch (manualPayment.Type) + { + case ManualPaymentType.CashDeposit: + case ManualPaymentType.Settlement: + case ManualPaymentType.ErrorCorrection: + wallet.Balance += manualPayment.Amount; + wallet.DiscountBalance += manualPayment.Amount; + + // لاگ Balance + await _context.UserWalletChangeLogs.AddAsync(new UserWalletChangeLog + { + WalletId = wallet.Id, + CurrentBalance = wallet.Balance, + ChangeValue = manualPayment.Amount, + CurrentNetworkBalance = wallet.NetworkBalance, + ChangeNerworkValue = 0, + CurrentDiscountBalance = oldDiscountBalance, + ChangeDiscountValue = 0, + IsIncrease = true, + RefrenceId = transaction.Id + }, cancellationToken); + + // لاگ DiscountBalance + await _context.UserWalletChangeLogs.AddAsync(new UserWalletChangeLog + { + WalletId = wallet.Id, + CurrentBalance = wallet.Balance, + ChangeValue = 0, + CurrentNetworkBalance = wallet.NetworkBalance, + ChangeNerworkValue = 0, + CurrentDiscountBalance = wallet.DiscountBalance, + ChangeDiscountValue = manualPayment.Amount, + IsIncrease = true, + RefrenceId = transaction.Id + }, cancellationToken); + break; + + case ManualPaymentType.DiscountWalletCharge: + wallet.DiscountBalance += manualPayment.Amount; + + await _context.UserWalletChangeLogs.AddAsync(new UserWalletChangeLog + { + WalletId = wallet.Id, + CurrentBalance = wallet.Balance, + ChangeValue = 0, + CurrentNetworkBalance = wallet.NetworkBalance, + ChangeNerworkValue = 0, + CurrentDiscountBalance = wallet.DiscountBalance, + ChangeDiscountValue = manualPayment.Amount, + IsIncrease = true, + RefrenceId = transaction.Id + }, cancellationToken); + break; + + case ManualPaymentType.NetworkWalletCharge: + wallet.NetworkBalance += manualPayment.Amount; + + await _context.UserWalletChangeLogs.AddAsync(new UserWalletChangeLog + { + WalletId = wallet.Id, + CurrentBalance = wallet.Balance, + ChangeValue = 0, + CurrentNetworkBalance = wallet.NetworkBalance, + ChangeNerworkValue = manualPayment.Amount, + CurrentDiscountBalance = wallet.DiscountBalance, + ChangeDiscountValue = 0, + IsIncrease = true, + RefrenceId = transaction.Id + }, cancellationToken); + break; + + case ManualPaymentType.Refund: + // بازگشت وجه - کم کردن از Balance و DiscountBalance + if (wallet.Balance < manualPayment.Amount) + { + throw new BadRequestException("موجودی کیف پول برای بازگشت وجه کافی نیست"); + } + + wallet.Balance -= manualPayment.Amount; + if (wallet.DiscountBalance >= manualPayment.Amount) + { + wallet.DiscountBalance -= manualPayment.Amount; + } + + await _context.UserWalletChangeLogs.AddAsync(new UserWalletChangeLog + { + WalletId = wallet.Id, + CurrentBalance = wallet.Balance, + ChangeValue = manualPayment.Amount, + CurrentNetworkBalance = wallet.NetworkBalance, + ChangeNerworkValue = 0, + CurrentDiscountBalance = wallet.DiscountBalance, + ChangeDiscountValue = wallet.DiscountBalance < oldDiscountBalance ? manualPayment.Amount : 0, + IsIncrease = false, + RefrenceId = transaction.Id + }, cancellationToken); + break; + + default: + // Other یا سایر موارد - فقط Balance + wallet.Balance += manualPayment.Amount; + + await _context.UserWalletChangeLogs.AddAsync(new UserWalletChangeLog + { + WalletId = wallet.Id, + CurrentBalance = wallet.Balance, + ChangeValue = manualPayment.Amount, + CurrentNetworkBalance = wallet.NetworkBalance, + ChangeNerworkValue = 0, + CurrentDiscountBalance = wallet.DiscountBalance, + ChangeDiscountValue = 0, + IsIncrease = true, + RefrenceId = transaction.Id + }, cancellationToken); + break; + } + + // 7. به‌روزرسانی ManualPayment + manualPayment.Status = ManualPaymentStatus.Approved; + manualPayment.ApprovedBy = approvedById; + manualPayment.ApprovedAt = DateTime.UtcNow; + manualPayment.TransactionId = transaction.Id; + + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Manual payment approved successfully. Id: {Id}, UserId: {UserId}, Amount: {Amount}, ApprovedBy: {ApprovedBy}", + manualPayment.Id, + manualPayment.UserId, + manualPayment.Amount, + approvedById + ); + + return true; + } + catch (Exception ex) + { + _logger.LogError( + ex, + "Error approving manual payment: {ManualPaymentId}", + request.ManualPaymentId + ); + throw; + } + } + + private TransactionType MapToTransactionType(ManualPaymentType type) + { + return type switch + { + ManualPaymentType.CashDeposit => TransactionType.DepositExternal1, + ManualPaymentType.DiscountWalletCharge => TransactionType.DiscountWalletCharge, + ManualPaymentType.NetworkWalletCharge => TransactionType.NetworkCommission, + ManualPaymentType.Settlement => TransactionType.DepositExternal1, + ManualPaymentType.ErrorCorrection => TransactionType.DepositExternal1, + ManualPaymentType.Refund => TransactionType.Withdraw, + _ => TransactionType.DepositExternal1 + }; + } +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommand.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommand.cs new file mode 100644 index 0000000..7bbc290 --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommand.cs @@ -0,0 +1,35 @@ +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Commands.CreateManualPayment; + +/// +/// دستور ثبت پرداخت دستی توسط Admin +/// +public class CreateManualPaymentCommand : IRequest +{ + /// + /// شناسه کاربری که پرداخت برای او ثبت می‌شود + /// + public long UserId { get; set; } + + /// + /// مبلغ تراکنش (ریال) + /// + public long Amount { get; set; } + + /// + /// نوع تراکنش دستی + /// + public ManualPaymentType Type { get; set; } + + /// + /// توضیحات (اجباری) + /// + public string Description { get; set; } = string.Empty; + + /// + /// شماره مرجع یا شماره فیش (اختیاری) + /// + public string? ReferenceNumber { get; set; } +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommandHandler.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommandHandler.cs new file mode 100644 index 0000000..2f353de --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommandHandler.cs @@ -0,0 +1,97 @@ +using CMSMicroservice.Application.Common.Exceptions; +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using CMSMicroservice.Domain.Entities.Payment; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Commands.CreateManualPayment; + +public class CreateManualPaymentCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public CreateManualPaymentCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle( + CreateManualPaymentCommand request, + CancellationToken cancellationToken) + { + try + { + _logger.LogInformation( + "Creating manual payment for UserId: {UserId}, Amount: {Amount}, Type: {Type}", + request.UserId, + request.Amount, + request.Type + ); + + // 1. بررسی وجود کاربر + var user = await _context.Users + .FirstOrDefaultAsync(u => u.Id == request.UserId, cancellationToken); + + if (user == null) + { + _logger.LogWarning("User not found: {UserId}", request.UserId); + throw new NotFoundException(nameof(User), request.UserId); + } + + // 2. بررسی Admin فعلی + var currentUserId = _currentUser.UserId; + if (string.IsNullOrEmpty(currentUserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + if (!long.TryParse(currentUserId, out var requestedById)) + { + throw new UnauthorizedAccessException("شناسه کاربر نامعتبر است"); + } + + // 3. ایجاد ManualPayment + var manualPayment = new ManualPayment + { + UserId = request.UserId, + Amount = request.Amount, + Type = request.Type, + Description = request.Description, + ReferenceNumber = request.ReferenceNumber, + Status = ManualPaymentStatus.Pending, + RequestedBy = requestedById + }; + + _context.ManualPayments.Add(manualPayment); + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Manual payment created successfully. Id: {Id}, UserId: {UserId}, RequestedBy: {RequestedBy}", + manualPayment.Id, + request.UserId, + requestedById + ); + + return manualPayment.Id; + } + catch (Exception ex) + { + _logger.LogError( + ex, + "Error creating manual payment for UserId: {UserId}", + request.UserId + ); + throw; + } + } +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommandValidator.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommandValidator.cs new file mode 100644 index 0000000..325bec9 --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/CreateManualPayment/CreateManualPaymentCommandValidator.cs @@ -0,0 +1,34 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Commands.CreateManualPayment; + +public class CreateManualPaymentCommandValidator : AbstractValidator +{ + public CreateManualPaymentCommandValidator() + { + RuleFor(x => x.UserId) + .GreaterThan(0) + .WithMessage("شناسه کاربر باید بزرگتر از صفر باشد"); + + RuleFor(x => x.Amount) + .GreaterThan(0) + .WithMessage("مبلغ باید بزرگتر از صفر باشد") + .LessThanOrEqualTo(1_000_000_000) + .WithMessage("مبلغ نمی‌تواند بیشتر از 1 میلیارد ریال باشد"); + + RuleFor(x => x.Type) + .IsInEnum() + .WithMessage("نوع تراکنش نامعتبر است"); + + RuleFor(x => x.Description) + .NotEmpty() + .WithMessage("توضیحات الزامی است") + .MaximumLength(1000) + .WithMessage("توضیحات نمی‌تواند بیشتر از 1000 کاراکتر باشد"); + + RuleFor(x => x.ReferenceNumber) + .MaximumLength(100) + .WithMessage("شماره مرجع نمی‌تواند بیشتر از 100 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.ReferenceNumber)); + } +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/RejectManualPayment/RejectManualPaymentCommand.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/RejectManualPayment/RejectManualPaymentCommand.cs new file mode 100644 index 0000000..b112646 --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/RejectManualPayment/RejectManualPaymentCommand.cs @@ -0,0 +1,19 @@ +using MediatR; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Commands.RejectManualPayment; + +/// +/// دستور رد پرداخت دستی توسط SuperAdmin +/// +public class RejectManualPaymentCommand : IRequest +{ + /// + /// شناسه ManualPayment + /// + public long ManualPaymentId { get; set; } + + /// + /// دلیل رد (الزامی) + /// + public string RejectionReason { get; set; } = string.Empty; +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/RejectManualPayment/RejectManualPaymentCommandHandler.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/RejectManualPayment/RejectManualPaymentCommandHandler.cs new file mode 100644 index 0000000..a8dbfae --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Commands/RejectManualPayment/RejectManualPaymentCommandHandler.cs @@ -0,0 +1,98 @@ +using CMSMicroservice.Application.Common.Exceptions; +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities.Payment; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Commands.RejectManualPayment; + +public class RejectManualPaymentCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public RejectManualPaymentCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle( + RejectManualPaymentCommand request, + CancellationToken cancellationToken) + { + try + { + _logger.LogInformation( + "Rejecting manual payment: {ManualPaymentId}", + request.ManualPaymentId + ); + + // 1. پیدا کردن ManualPayment + var manualPayment = await _context.ManualPayments + .FirstOrDefaultAsync(m => m.Id == request.ManualPaymentId, cancellationToken); + + if (manualPayment == null) + { + _logger.LogWarning("ManualPayment not found: {Id}", request.ManualPaymentId); + throw new NotFoundException(nameof(ManualPayment), request.ManualPaymentId); + } + + // 2. بررسی وضعیت + if (manualPayment.Status != ManualPaymentStatus.Pending) + { + _logger.LogWarning( + "ManualPayment {Id} is not in Pending status: {Status}", + request.ManualPaymentId, + manualPayment.Status + ); + throw new BadRequestException($"فقط درخواست‌های در وضعیت Pending قابل رد هستند. وضعیت فعلی: {manualPayment.Status}"); + } + + // 3. بررسی SuperAdmin + var currentUserId = _currentUser.UserId; + if (string.IsNullOrEmpty(currentUserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + if (!long.TryParse(currentUserId, out var rejectedById)) + { + throw new UnauthorizedAccessException("شناسه کاربر نامعتبر است"); + } + + // 4. رد درخواست + manualPayment.Status = ManualPaymentStatus.Rejected; + manualPayment.ApprovedBy = rejectedById; + manualPayment.ApprovedAt = DateTime.UtcNow; + manualPayment.RejectionReason = request.RejectionReason; + + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Manual payment rejected successfully. Id: {Id}, RejectedBy: {RejectedBy}, Reason: {Reason}", + manualPayment.Id, + rejectedById, + request.RejectionReason + ); + + return true; + } + catch (Exception ex) + { + _logger.LogError( + ex, + "Error rejecting manual payment: {ManualPaymentId}", + request.ManualPaymentId + ); + throw; + } + } +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsQuery.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsQuery.cs new file mode 100644 index 0000000..593aee9 --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsQuery.cs @@ -0,0 +1,46 @@ +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Queries.GetAllManualPayments; + +/// +/// کوئری دریافت لیست پرداخت‌های دستی با فیلتر +/// +public class GetAllManualPaymentsQuery : IRequest +{ + /// + /// شماره صفحه + /// + public int PageNumber { get; set; } = 1; + + /// + /// تعداد رکورد در هر صفحه + /// + public int PageSize { get; set; } = 10; + + /// + /// فیلتر بر اساس UserId (اختیاری) + /// + public long? UserId { get; set; } + + /// + /// فیلتر بر اساس وضعیت (اختیاری) + /// + public ManualPaymentStatus? Status { get; set; } + + /// + /// فیلتر بر اساس نوع (اختیاری) + /// + public ManualPaymentType? Type { get; set; } + + /// + /// فیلتر بر اساس RequestedBy (اختیاری) + /// + public long? RequestedBy { get; set; } + + /// + /// مرتب‌سازی بر اساس تاریخ ایجاد (نزولی: true, صعودی: false) + /// + public bool OrderByDescending { get; set; } = true; +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsQueryHandler.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsQueryHandler.cs new file mode 100644 index 0000000..15f5902 --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsQueryHandler.cs @@ -0,0 +1,121 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Queries.GetAllManualPayments; + +public class GetAllManualPaymentsQueryHandler + : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetAllManualPaymentsQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle( + GetAllManualPaymentsQuery request, + CancellationToken cancellationToken) + { + _logger.LogInformation( + "Getting manual payments. Page: {Page}, PageSize: {PageSize}", + request.PageNumber, + request.PageSize + ); + + // ساخت Query با فیلترها + var query = _context.ManualPayments + .Include(m => m.User) + .AsQueryable(); + + // فیلتر UserId + if (request.UserId.HasValue) + { + query = query.Where(m => m.UserId == request.UserId.Value); + } + + // فیلتر Status + if (request.Status.HasValue) + { + query = query.Where(m => m.Status == request.Status.Value); + } + + // فیلتر Type + if (request.Type.HasValue) + { + query = query.Where(m => m.Type == request.Type.Value); + } + + // فیلتر RequestedBy + if (request.RequestedBy.HasValue) + { + query = query.Where(m => m.RequestedBy == request.RequestedBy.Value); + } + + // شمارش کل + var totalCount = await query.CountAsync(cancellationToken); + + // مرتب‌سازی + query = request.OrderByDescending + ? query.OrderByDescending(m => m.Created) + : query.OrderBy(m => m.Created); + + // Pagination + var skip = (request.PageNumber - 1) * request.PageSize; + var data = await query + .Skip(skip) + .Take(request.PageSize) + .Select(m => new ManualPaymentDto + { + Id = m.Id, + UserId = m.UserId, + UserFullName = m.User.FirstName + " " + m.User.LastName, + UserMobile = m.User.Mobile ?? "", + Amount = m.Amount, + Type = m.Type, + TypeDisplay = m.Type.ToString(), + Description = m.Description, + ReferenceNumber = m.ReferenceNumber, + Status = m.Status, + StatusDisplay = m.Status.ToString(), + RequestedBy = m.RequestedBy, + RequestedByName = "", // باید از جدول User گرفته شود + ApprovedBy = m.ApprovedBy, + ApprovedByName = null, + ApprovedAt = m.ApprovedAt, + RejectionReason = m.RejectionReason, + TransactionId = m.TransactionId, + Created = m.Created + }) + .ToListAsync(cancellationToken); + + var metaData = new MetaData + { + TotalCount = totalCount, + PageSize = request.PageSize, + CurrentPage = request.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasNext = request.PageNumber < (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasPrevious = request.PageNumber > 1 + }; + + _logger.LogInformation( + "Retrieved {Count} manual payments. Total: {Total}", + data.Count, + totalCount + ); + + return new GetAllManualPaymentsResponseDto + { + MetaData = metaData, + Models = data + }; + } +} diff --git a/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsResponseDto.cs b/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsResponseDto.cs new file mode 100644 index 0000000..938b5fa --- /dev/null +++ b/src/CMSMicroservice.Application/ManualPaymentCQ/Queries/GetAllManualPayments/GetAllManualPaymentsResponseDto.cs @@ -0,0 +1,33 @@ +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Domain.Enums; + +namespace CMSMicroservice.Application.ManualPaymentCQ.Queries.GetAllManualPayments; + +public class GetAllManualPaymentsResponseDto +{ + public MetaData? MetaData { get; set; } + public List? Models { get; set; } +} + +public class ManualPaymentDto +{ + public long Id { get; set; } + public long UserId { get; set; } + public string UserFullName { get; set; } = string.Empty; + public string UserMobile { get; set; } = string.Empty; + public long Amount { get; set; } + public ManualPaymentType Type { get; set; } + public string TypeDisplay { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string? ReferenceNumber { get; set; } + public ManualPaymentStatus Status { get; set; } + public string StatusDisplay { get; set; } = string.Empty; + public long RequestedBy { get; set; } + public string RequestedByName { get; set; } = string.Empty; + public long? ApprovedBy { get; set; } + public string? ApprovedByName { get; set; } + public DateTime? ApprovedAt { get; set; } + public string? RejectionReason { get; set; } + public long? TransactionId { get; set; } + public DateTime Created { get; set; } +} diff --git a/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommand.cs b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommand.cs new file mode 100644 index 0000000..aceec3e --- /dev/null +++ b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommand.cs @@ -0,0 +1,13 @@ +using MediatR; + +namespace CMSMicroservice.Application.OrderManagementCQ.Commands.CancelOrderByAdmin; + +/// +/// دستور لغو سفارش توسط Admin +/// +public class CancelOrderByAdminCommand : IRequest +{ + public long OrderId { get; set; } + public string CancelReason { get; set; } = string.Empty; + public bool RefundToWallet { get; set; } = true; +} diff --git a/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommandHandler.cs b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommandHandler.cs new file mode 100644 index 0000000..de8af0b --- /dev/null +++ b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommandHandler.cs @@ -0,0 +1,100 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.OrderManagementCQ.Commands.CancelOrderByAdmin; + +public class CancelOrderByAdminCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public CancelOrderByAdminCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle(CancelOrderByAdminCommand request, CancellationToken cancellationToken) + { + // بررسی Admin + if (string.IsNullOrEmpty(_currentUser.UserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + var order = await _context.UserOrders + .Include(x => x.User) + .ThenInclude(x => x.UserWallets) + .FirstOrDefaultAsync(x => x.Id == request.OrderId && !x.IsDeleted, cancellationToken); + + if (order == null) + { + throw new KeyNotFoundException($"سفارش با شناسه {request.OrderId} یافت نشد"); + } + + if (order.DeliveryStatus == DeliveryStatus.Cancelled) + { + throw new InvalidOperationException("این سفارش قبلاً لغو شده است"); + } + + if (order.DeliveryStatus == DeliveryStatus.Delivered) + { + throw new InvalidOperationException("سفارش تحویل داده شده را نمی‌توان لغو کرد"); + } + + // تغییر وضعیت به لغو شده + order.DeliveryStatus = DeliveryStatus.Cancelled; + order.DeliveryDescription = $"لغو توسط Admin: {request.CancelReason}"; + + // بازگشت وجه به کیف پول + if (request.RefundToWallet && order.PaymentMethod == PaymentMethod.Wallet) + { + var wallet = order.User.UserWallets.FirstOrDefault(); + if (wallet != null) + { + var walletLog = new UserWalletChangeLog + { + WalletId = wallet.Id, + CurrentBalance = wallet.Balance, + CurrentNetworkBalance = wallet.NetworkBalance, + CurrentDiscountBalance = wallet.DiscountBalance, + ChangeValue = order.Amount, + ChangeDiscountValue = 0, + IsIncrease = true, + RefrenceId = order.Id + }; + + wallet.Balance += order.Amount; + + await _context.UserWalletChangeLogs.AddAsync(walletLog, cancellationToken); + + _logger.LogInformation( + "Refund processed. OrderId: {OrderId}, Amount: {Amount}, UserId: {UserId}", + order.Id, + order.Amount, + order.UserId + ); + } + } + + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Order cancelled by admin. OrderId: {OrderId}, Reason: {Reason}, Refunded: {Refunded}, Admin: {AdminId}", + order.Id, + request.CancelReason, + request.RefundToWallet, + _currentUser.UserId + ); + + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommandValidator.cs b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommandValidator.cs new file mode 100644 index 0000000..a6b486b --- /dev/null +++ b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/CancelOrderByAdmin/CancelOrderByAdminCommandValidator.cs @@ -0,0 +1,16 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.OrderManagementCQ.Commands.CancelOrderByAdmin; + +public class CancelOrderByAdminCommandValidator : AbstractValidator +{ + public CancelOrderByAdminCommandValidator() + { + RuleFor(x => x.OrderId) + .GreaterThan(0).WithMessage("شناسه سفارش نامعتبر است"); + + RuleFor(x => x.CancelReason) + .NotEmpty().WithMessage("دلیل لغو الزامی است") + .MaximumLength(500).WithMessage("دلیل لغو نمی‌تواند بیشتر از 500 کاراکتر باشد"); + } +} diff --git a/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommand.cs b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommand.cs new file mode 100644 index 0000000..c6a062d --- /dev/null +++ b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommand.cs @@ -0,0 +1,15 @@ +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.OrderManagementCQ.Commands.UpdateOrderStatus; + +/// +/// دستور تغییر وضعیت ارسال سفارش (Admin) +/// +public class UpdateOrderStatusCommand : IRequest +{ + public long OrderId { get; set; } + public DeliveryStatus NewStatus { get; set; } + public string? TrackingCode { get; set; } + public string? Description { get; set; } +} diff --git a/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandHandler.cs b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandHandler.cs new file mode 100644 index 0000000..ba23a88 --- /dev/null +++ b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandHandler.cs @@ -0,0 +1,66 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.OrderManagementCQ.Commands.UpdateOrderStatus; + +public class UpdateOrderStatusCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public UpdateOrderStatusCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle(UpdateOrderStatusCommand request, CancellationToken cancellationToken) + { + // بررسی Admin + if (string.IsNullOrEmpty(_currentUser.UserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + var order = await _context.UserOrders + .FirstOrDefaultAsync(x => x.Id == request.OrderId && !x.IsDeleted, cancellationToken); + + if (order == null) + { + throw new KeyNotFoundException($"سفارش با شناسه {request.OrderId} یافت نشد"); + } + + var oldStatus = order.DeliveryStatus; + + order.DeliveryStatus = request.NewStatus; + + if (!string.IsNullOrEmpty(request.TrackingCode)) + { + order.TrackingCode = request.TrackingCode.Trim(); + } + + if (!string.IsNullOrEmpty(request.Description)) + { + order.DeliveryDescription = request.Description.Trim(); + } + + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Order status updated by admin. OrderId: {OrderId}, OldStatus: {OldStatus}, NewStatus: {NewStatus}, Admin: {AdminId}", + order.Id, + oldStatus, + request.NewStatus, + _currentUser.UserId + ); + + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandValidator.cs b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandValidator.cs new file mode 100644 index 0000000..e8600fe --- /dev/null +++ b/src/CMSMicroservice.Application/OrderManagementCQ/Commands/UpdateOrderStatus/UpdateOrderStatusCommandValidator.cs @@ -0,0 +1,23 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.OrderManagementCQ.Commands.UpdateOrderStatus; + +public class UpdateOrderStatusCommandValidator : AbstractValidator +{ + public UpdateOrderStatusCommandValidator() + { + RuleFor(x => x.OrderId) + .GreaterThan(0).WithMessage("شناسه سفارش نامعتبر است"); + + RuleFor(x => x.NewStatus) + .IsInEnum().WithMessage("وضعیت ارسال نامعتبر است"); + + RuleFor(x => x.TrackingCode) + .MaximumLength(50).WithMessage("کد رهگیری نمی‌تواند بیشتر از 50 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.TrackingCode)); + + RuleFor(x => x.Description) + .MaximumLength(500).WithMessage("توضیحات نمی‌تواند بیشتر از 500 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.Description)); + } +} diff --git a/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/GetOrderVATQuery.cs b/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/GetOrderVATQuery.cs new file mode 100644 index 0000000..1753fda --- /dev/null +++ b/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/GetOrderVATQuery.cs @@ -0,0 +1,11 @@ +using MediatR; + +namespace CMSMicroservice.Application.OrderVATCQ.Queries.GetOrderVAT; + +/// +/// کوئری دریافت اطلاعات مالیات سفارش +/// +public class GetOrderVATQuery : IRequest +{ + public long OrderId { get; set; } +} diff --git a/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/GetOrderVATQueryHandler.cs b/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/GetOrderVATQueryHandler.cs new file mode 100644 index 0000000..254744c --- /dev/null +++ b/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/GetOrderVATQueryHandler.cs @@ -0,0 +1,52 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.OrderVATCQ.Queries.GetOrderVAT; + +public class GetOrderVATQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetOrderVATQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(GetOrderVATQuery request, CancellationToken cancellationToken) + { + var orderVAT = await _context.OrderVATs + .Where(x => x.OrderId == request.OrderId && !x.IsDeleted) + .Select(x => new OrderVATDto + { + Id = x.Id, + OrderId = x.OrderId, + VATRate = x.VATRate, + VATRatePercentage = $"{x.VATRate * 100:F1}%", + BaseAmount = x.BaseAmount, + VATAmount = x.VATAmount, + TotalAmount = x.TotalAmount, + IsPaid = x.IsPaid, + PaidAt = x.PaidAt, + Note = x.Note, + Created = x.Created + }) + .FirstOrDefaultAsync(cancellationToken); + + if (orderVAT != null) + { + _logger.LogInformation( + "Retrieved VAT for order {OrderId}. VAT Amount: {VATAmount}", + request.OrderId, + orderVAT.VATAmount + ); + } + + return orderVAT; + } +} diff --git a/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/OrderVATDto.cs b/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/OrderVATDto.cs new file mode 100644 index 0000000..ea1b2e9 --- /dev/null +++ b/src/CMSMicroservice.Application/OrderVATCQ/Queries/GetOrderVAT/OrderVATDto.cs @@ -0,0 +1,19 @@ +namespace CMSMicroservice.Application.OrderVATCQ.Queries.GetOrderVAT; + +/// +/// DTO اطلاعات مالیات سفارش +/// +public class OrderVATDto +{ + public long Id { get; set; } + public long OrderId { get; set; } + public decimal VATRate { get; set; } + public string VATRatePercentage { get; set; } = string.Empty; + public long BaseAmount { get; set; } + public long VATAmount { get; set; } + public long TotalAmount { get; set; } + public bool IsPaid { get; set; } + public DateTime? PaidAt { get; set; } + public string? Note { get; set; } + public DateTime Created { get; set; } +} diff --git a/src/CMSMicroservice.Application/OtpTokenCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs b/src/CMSMicroservice.Application/OtpTokenCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs index 99c1161..c82bf7a 100644 --- a/src/CMSMicroservice.Application/OtpTokenCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs +++ b/src/CMSMicroservice.Application/OtpTokenCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs @@ -62,7 +62,7 @@ public class VerifyOtpTokenCommandHandler : IRequestHandler x.ParentId == parent.Id, cancellationToken: cancellationToken) > 1) + if (await _context.Users.CountAsync(x => x.NetworkParentId == parent.Id, cancellationToken: cancellationToken) > 1) return new VerifyOtpTokenResponseDto() { Success = false, Message = "ظرفیت معرف تکمیل است!!" }; user = new User @@ -73,7 +73,7 @@ public class VerifyOtpTokenCommandHandler : IRequestHandler -/// دستور خرید پکیج طلایی از طریق درگاه بانکی +/// دستور خرید پکیج از طریق درگاه بانکی /// -public class PurchaseGoldenPackageCommand : IRequest +public class PurchasePackageCommand : IRequest { /// /// شناسه کاربر diff --git a/src/CMSMicroservice.Application/PackageCQ/Commands/PurchaseGoldenPackage/PurchaseGoldenPackageCommandHandler.cs b/src/CMSMicroservice.Application/PackageCQ/Commands/PurchasePackage/PurchasePackageCommandHandler.cs similarity index 83% rename from src/CMSMicroservice.Application/PackageCQ/Commands/PurchaseGoldenPackage/PurchaseGoldenPackageCommandHandler.cs rename to src/CMSMicroservice.Application/PackageCQ/Commands/PurchasePackage/PurchasePackageCommandHandler.cs index 8f9b51d..2f7bd0e 100644 --- a/src/CMSMicroservice.Application/PackageCQ/Commands/PurchaseGoldenPackage/PurchaseGoldenPackageCommandHandler.cs +++ b/src/CMSMicroservice.Application/PackageCQ/Commands/PurchasePackage/PurchasePackageCommandHandler.cs @@ -8,19 +8,19 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using ValidationException = FluentValidation.ValidationException; -namespace CMSMicroservice.Application.PackageCQ.Commands.PurchaseGoldenPackage; +namespace CMSMicroservice.Application.PackageCQ.Commands.PurchasePackage; -public class PurchaseGoldenPackageCommandHandler - : IRequestHandler +public class PurchasePackageCommandHandler + : IRequestHandler { private readonly IApplicationDbContext _context; private readonly IPaymentGatewayService _paymentGateway; - private readonly ILogger _logger; + private readonly ILogger _logger; - public PurchaseGoldenPackageCommandHandler( + public PurchasePackageCommandHandler( IApplicationDbContext context, IPaymentGatewayService paymentGateway, - ILogger logger) + ILogger logger) { _context = context; _paymentGateway = paymentGateway; @@ -28,13 +28,13 @@ public class PurchaseGoldenPackageCommandHandler } public async Task Handle( - PurchaseGoldenPackageCommand request, + PurchasePackageCommand request, CancellationToken cancellationToken) { try { _logger.LogInformation( - "Starting golden package purchase for UserId: {UserId}", + "Starting package purchase for UserId: {UserId}", request.UserId ); @@ -57,11 +57,11 @@ public class PurchaseGoldenPackageCommandHandler user.PackagePurchaseMethod ); throw new ValidationException( - "شما قبلاً پکیج طلایی را خریداری کرده‌اید" + "شما قبلاً پکیج را خریداری کرده‌اید" ); } - // 3. پیدا کردن پکیج طلایی + // 3. پیدا کردن پکیج (فعلاً پکیج طلایی) var goldenPackage = await _context.Packages .FirstOrDefaultAsync( p => p.Title.Contains("طلایی") || p.Title.Contains("Golden"), @@ -70,12 +70,12 @@ public class PurchaseGoldenPackageCommandHandler if (goldenPackage == null) { - _logger.LogError("Golden package not found in database"); - throw new NotFoundException("پکیج طلایی یافت نشد"); + _logger.LogError("Package not found in database"); + throw new NotFoundException("پکیج یافت نشد"); } // 4. پیدا کردن آدرس پیش‌فرض کاربر (برای فیلد اجباری) - var defaultAddress = await _context.UserAddresss + var defaultAddress = await _context.UserAddresses .Where(a => a.UserId == request.UserId) .OrderByDescending(a => a.Created) .FirstOrDefaultAsync(cancellationToken); @@ -116,8 +116,8 @@ public class PurchaseGoldenPackageCommandHandler Amount = order.Amount, UserId = user.Id, Mobile = user.Mobile ?? "", - CallbackUrl = $"https://yourdomain.com/api/package/verify-golden-package", - Description = $"خرید پکیج طلایی - سفارش #{order.Id}" + CallbackUrl = $"https://yourdomain.com/api/package/verify-package", + Description = $"خرید پکیج - سفارش #{order.Id}" }; var paymentResult = await _paymentGateway.InitiatePaymentAsync(paymentRequest); @@ -151,7 +151,7 @@ public class PurchaseGoldenPackageCommandHandler { _logger.LogError( ex, - "Error in PurchaseGoldenPackageCommand for UserId: {UserId}", + "Error in PurchasePackageCommand for UserId: {UserId}", request.UserId ); throw; diff --git a/src/CMSMicroservice.Application/PackageCQ/Commands/PurchaseGoldenPackage/PurchaseGoldenPackageCommandValidator.cs b/src/CMSMicroservice.Application/PackageCQ/Commands/PurchasePackage/PurchasePackageCommandValidator.cs similarity index 60% rename from src/CMSMicroservice.Application/PackageCQ/Commands/PurchaseGoldenPackage/PurchaseGoldenPackageCommandValidator.cs rename to src/CMSMicroservice.Application/PackageCQ/Commands/PurchasePackage/PurchasePackageCommandValidator.cs index 0b7289b..002c022 100644 --- a/src/CMSMicroservice.Application/PackageCQ/Commands/PurchaseGoldenPackage/PurchaseGoldenPackageCommandValidator.cs +++ b/src/CMSMicroservice.Application/PackageCQ/Commands/PurchasePackage/PurchasePackageCommandValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -namespace CMSMicroservice.Application.PackageCQ.Commands.PurchaseGoldenPackage; +namespace CMSMicroservice.Application.PackageCQ.Commands.PurchasePackage; -public class PurchaseGoldenPackageCommandValidator : AbstractValidator +public class PurchasePackageCommandValidator : AbstractValidator { - public PurchaseGoldenPackageCommandValidator() + public PurchasePackageCommandValidator() { RuleFor(x => x.UserId) .GreaterThan(0) diff --git a/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyGoldenPackagePurchase/VerifyGoldenPackagePurchaseCommand.cs b/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyPackagePurchase/VerifyPackagePurchaseCommand.cs similarity index 62% rename from src/CMSMicroservice.Application/PackageCQ/Commands/VerifyGoldenPackagePurchase/VerifyGoldenPackagePurchaseCommand.cs rename to src/CMSMicroservice.Application/PackageCQ/Commands/VerifyPackagePurchase/VerifyPackagePurchaseCommand.cs index 5e3fb37..68ed88a 100644 --- a/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyGoldenPackagePurchase/VerifyGoldenPackagePurchaseCommand.cs +++ b/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyPackagePurchase/VerifyPackagePurchaseCommand.cs @@ -2,12 +2,12 @@ using CMSMicroservice.Application.Common.Interfaces; using CMSMicroservice.Application.Common.Models; using MediatR; -namespace CMSMicroservice.Application.PackageCQ.Commands.VerifyGoldenPackagePurchase; +namespace CMSMicroservice.Application.PackageCQ.Commands.VerifyPackagePurchase; /// -/// دستور تأیید پرداخت پکیج طلایی و شارژ کیف پول +/// دستور تأیید پرداخت پکیج و شارژ کیف پول /// -public class VerifyGoldenPackagePurchaseCommand : IRequest +public class VerifyPackagePurchaseCommand : IRequest { /// /// شناسه سفارش diff --git a/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyGoldenPackagePurchase/VerifyGoldenPackagePurchaseCommandHandler.cs b/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyPackagePurchase/VerifyPackagePurchaseCommandHandler.cs similarity index 87% rename from src/CMSMicroservice.Application/PackageCQ/Commands/VerifyGoldenPackagePurchase/VerifyGoldenPackagePurchaseCommandHandler.cs rename to src/CMSMicroservice.Application/PackageCQ/Commands/VerifyPackagePurchase/VerifyPackagePurchaseCommandHandler.cs index 125c9c2..4907abc 100644 --- a/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyGoldenPackagePurchase/VerifyGoldenPackagePurchaseCommandHandler.cs +++ b/src/CMSMicroservice.Application/PackageCQ/Commands/VerifyPackagePurchase/VerifyPackagePurchaseCommandHandler.cs @@ -8,19 +8,19 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using ValidationException = FluentValidation.ValidationException; -namespace CMSMicroservice.Application.PackageCQ.Commands.VerifyGoldenPackagePurchase; +namespace CMSMicroservice.Application.PackageCQ.Commands.VerifyPackagePurchase; -public class VerifyGoldenPackagePurchaseCommandHandler - : IRequestHandler +public class VerifyPackagePurchaseCommandHandler + : IRequestHandler { private readonly IApplicationDbContext _context; private readonly IPaymentGatewayService _paymentGateway; - private readonly ILogger _logger; + private readonly ILogger _logger; - public VerifyGoldenPackagePurchaseCommandHandler( + public VerifyPackagePurchaseCommandHandler( IApplicationDbContext context, IPaymentGatewayService paymentGateway, - ILogger logger) + ILogger logger) { _context = context; _paymentGateway = paymentGateway; @@ -28,13 +28,13 @@ public class VerifyGoldenPackagePurchaseCommandHandler } public async Task Handle( - VerifyGoldenPackagePurchaseCommand request, + VerifyPackagePurchaseCommand request, CancellationToken cancellationToken) { try { _logger.LogInformation( - "Verifying golden package purchase. OrderId: {OrderId}, Authority: {Authority}", + "Verifying package purchase. OrderId: {OrderId}, Authority: {Authority}", request.OrderId, request.Authority ); @@ -111,17 +111,17 @@ public class VerifyGoldenPackagePurchaseCommandHandler ); // 5. ثبت Transaction - var transaction = new Transactions + var transaction = new Transaction { Amount = order.Amount, - Description = $"خرید پکیج طلایی از درگاه - سفارش #{order.Id}", + Description = $"خرید پکیج از درگاه - سفارش #{order.Id}", PaymentStatus = PaymentStatus.Success, PaymentDate = DateTime.UtcNow, RefId = verifyResult.RefId, Type = TransactionType.DepositIpg }; - _context.Transactionss.Add(transaction); + _context.Transactions.Add(transaction); await _context.SaveChangesAsync(cancellationToken); // 6. ثبت لاگ تغییر Balance @@ -166,7 +166,7 @@ public class VerifyGoldenPackagePurchaseCommandHandler await _context.SaveChangesAsync(cancellationToken); _logger.LogInformation( - "Golden package purchase verified successfully. " + + "Package purchase verified successfully. " + "OrderId: {OrderId}, UserId: {UserId}, TransactionId: {TransactionId}, RefId: {RefId}", order.Id, order.UserId, @@ -180,7 +180,7 @@ public class VerifyGoldenPackagePurchaseCommandHandler { _logger.LogError( ex, - "Error in VerifyGoldenPackagePurchaseCommand. OrderId: {OrderId}", + "Error in VerifyPackagePurchaseCommand. OrderId: {OrderId}", request.OrderId ); throw; diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommand.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommand.cs new file mode 100644 index 0000000..692459c --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommand.cs @@ -0,0 +1,9 @@ +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.CreateNewProductCategory; +public record CreateNewProductCategoryCommand : IRequest +{ + //شناسه محصول + public long ProductId { get; init; } + //شناسه دسته بندی + public long CategoryId { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommandHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommandHandler.cs new file mode 100644 index 0000000..08ec9f5 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommandHandler.cs @@ -0,0 +1,21 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.CreateNewProductCategory; +public class CreateNewProductCategoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public CreateNewProductCategoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CreateNewProductCategoryCommand request, + CancellationToken cancellationToken) + { + var entity = request.Adapt(); + await _context.ProductCategories.AddAsync(entity, cancellationToken); + entity.AddDomainEvent(new CreateNewProductCategoryEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return entity.Adapt(); + } +} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommandValidator.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommandValidator.cs similarity index 62% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommandValidator.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommandValidator.cs index 89f82bc..d4c5c70 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryCommandValidator.cs @@ -1,7 +1,7 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.CreateNewPruductCategory; -public class CreateNewPruductCategoryCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.CreateNewProductCategory; +public class CreateNewProductCategoryCommandValidator : AbstractValidator { - public CreateNewPruductCategoryCommandValidator() + public CreateNewProductCategoryCommandValidator() { RuleFor(model => model.ProductId) .NotNull(); @@ -10,7 +10,7 @@ public class CreateNewPruductCategoryCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewPruductCategoryCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductCategoryCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryResponseDto.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryResponseDto.cs new file mode 100644 index 0000000..4970967 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/CreateNewProductCategory/CreateNewPruductCategoryResponseDto.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.CreateNewProductCategory; +public class CreateNewProductCategoryResponseDto +{ + //شناسه + public long Id { get; set; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommand.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommand.cs new file mode 100644 index 0000000..9ab6645 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommand.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.DeleteProductCategory; +public record DeleteProductCategoryCommand : IRequest +{ + //شناسه + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommandHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommandHandler.cs new file mode 100644 index 0000000..0ee63f6 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommandHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.DeleteProductCategory; +public class DeleteProductCategoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public DeleteProductCategoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(DeleteProductCategoryCommand request, CancellationToken cancellationToken) + { + var entity = await _context.ProductCategories + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductCategory), request.Id); + entity.IsDeleted = true; + _context.ProductCategories.Update(entity); + entity.AddDomainEvent(new DeleteProductCategoryEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommandValidator.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommandValidator.cs similarity index 59% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommandValidator.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommandValidator.cs index 2d4aa9e..24eb521 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/DeleteProductCategory/DeletePruductCategoryCommandValidator.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.DeletePruductCategory; -public class DeletePruductCategoryCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.DeleteProductCategory; +public class DeleteProductCategoryCommandValidator : AbstractValidator { - public DeletePruductCategoryCommandValidator() + public DeleteProductCategoryCommandValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeletePruductCategoryCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductCategoryCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommand.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommand.cs similarity index 57% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommand.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommand.cs index 7969e6c..f2efa15 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommand.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommand.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.UpdatePruductCategory; -public record UpdatePruductCategoryCommand : IRequest +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.UpdateProductCategory; +public record UpdateProductCategoryCommand : IRequest { //شناسه public long Id { get; init; } diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommandHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommandHandler.cs new file mode 100644 index 0000000..1923078 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommandHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.UpdateProductCategory; +public class UpdateProductCategoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateProductCategoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateProductCategoryCommand request, CancellationToken cancellationToken) + { + var entity = await _context.ProductCategories + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductCategory), request.Id); + request.Adapt(entity); + _context.ProductCategories.Update(entity); + entity.AddDomainEvent(new UpdateProductCategoryEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommandValidator.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommandValidator.cs similarity index 65% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommandValidator.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommandValidator.cs index 6d7b2a8..ada08d0 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Commands/UpdateProductCategory/UpdatePruductCategoryCommandValidator.cs @@ -1,7 +1,7 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.UpdatePruductCategory; -public class UpdatePruductCategoryCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductCategoryCQ.Commands.UpdateProductCategory; +public class UpdateProductCategoryCommandValidator : AbstractValidator { - public UpdatePruductCategoryCommandValidator() + public UpdateProductCategoryCommandValidator() { RuleFor(model => model.Id) .NotNull(); @@ -12,7 +12,7 @@ public class UpdatePruductCategoryCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdatePruductCategoryCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductCategoryCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/CreateNewProductCategoryEventHandlers/CreateNewPruductCategoryEventHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/CreateNewProductCategoryEventHandlers/CreateNewPruductCategoryEventHandler.cs new file mode 100644 index 0000000..162f001 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/CreateNewProductCategoryEventHandlers/CreateNewPruductCategoryEventHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ProductCategoryCQ.EventHandlers; + +public class CreateNewProductCategoryEventHandler : INotificationHandler +{ + private readonly ILogger< + CreateNewProductCategoryEventHandler> _logger; + + public CreateNewProductCategoryEventHandler(ILogger logger) + { + _logger = logger; + } + + public Task Handle(CreateNewProductCategoryEvent notification, CancellationToken cancellationToken) + { + _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); + + return Task.CompletedTask; + } +} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/DeletePruductCategoryEventHandlers/DeletePruductCategoryEventHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/DeleteProductCategoryEventHandlers/DeletePruductCategoryEventHandler.cs similarity index 51% rename from src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/DeletePruductCategoryEventHandlers/DeletePruductCategoryEventHandler.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/DeleteProductCategoryEventHandlers/DeletePruductCategoryEventHandler.cs index 1490cab..a201469 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/DeletePruductCategoryEventHandlers/DeletePruductCategoryEventHandler.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/DeleteProductCategoryEventHandlers/DeletePruductCategoryEventHandler.cs @@ -1,19 +1,19 @@ using CMSMicroservice.Domain.Events; using Microsoft.Extensions.Logging; -namespace CMSMicroservice.Application.PruductCategoryCQ.EventHandlers; +namespace CMSMicroservice.Application.ProductCategoryCQ.EventHandlers; -public class DeletePruductCategoryEventHandler : INotificationHandler +public class DeleteProductCategoryEventHandler : INotificationHandler { private readonly ILogger< - DeletePruductCategoryEventHandler> _logger; + DeleteProductCategoryEventHandler> _logger; - public DeletePruductCategoryEventHandler(ILogger logger) + public DeleteProductCategoryEventHandler(ILogger logger) { _logger = logger; } - public Task Handle(DeletePruductCategoryEvent notification, CancellationToken cancellationToken) + public Task Handle(DeleteProductCategoryEvent notification, CancellationToken cancellationToken) { _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/UpdatePruductCategoryEventHandlers/UpdatePruductCategoryEventHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/UpdateProductCategoryEventHandlers/UpdatePruductCategoryEventHandler.cs similarity index 51% rename from src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/UpdatePruductCategoryEventHandlers/UpdatePruductCategoryEventHandler.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/UpdateProductCategoryEventHandlers/UpdatePruductCategoryEventHandler.cs index 42fade5..f589937 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/UpdatePruductCategoryEventHandlers/UpdatePruductCategoryEventHandler.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/EventHandlers/UpdateProductCategoryEventHandlers/UpdatePruductCategoryEventHandler.cs @@ -1,19 +1,19 @@ using CMSMicroservice.Domain.Events; using Microsoft.Extensions.Logging; -namespace CMSMicroservice.Application.PruductCategoryCQ.EventHandlers; +namespace CMSMicroservice.Application.ProductCategoryCQ.EventHandlers; -public class UpdatePruductCategoryEventHandler : INotificationHandler +public class UpdateProductCategoryEventHandler : INotificationHandler { private readonly ILogger< - UpdatePruductCategoryEventHandler> _logger; + UpdateProductCategoryEventHandler> _logger; - public UpdatePruductCategoryEventHandler(ILogger logger) + public UpdateProductCategoryEventHandler(ILogger logger) { _logger = logger; } - public Task Handle(UpdatePruductCategoryEvent notification, CancellationToken cancellationToken) + public Task Handle(UpdateProductCategoryEvent notification, CancellationToken cancellationToken) { _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQuery.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQuery.cs similarity index 56% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQuery.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQuery.cs index f4dd9b0..38c6616 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQuery.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQuery.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetAllPruductCategoryByFilter; -public record GetAllPruductCategoryByFilterQuery : IRequest +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetAllProductCategoryByFilter; +public record GetAllProductCategoryByFilterQuery : IRequest { //موقعیت صفحه بندی public PaginationState? PaginationState { get; init; } //مرتب سازی بر اساس public string? SortBy { get; init; } //فیلتر - public GetAllPruductCategoryByFilterFilter? Filter { get; init; } + public GetAllProductCategoryByFilterFilter? Filter { get; init; } -}public class GetAllPruductCategoryByFilterFilter +}public class GetAllProductCategoryByFilterFilter { //شناسه public long? Id { get; set; } diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQueryHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQueryHandler.cs similarity index 61% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQueryHandler.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQueryHandler.cs index 1ace90d..31e1306 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQueryHandler.cs @@ -1,16 +1,16 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetAllPruductCategoryByFilter; -public class GetAllPruductCategoryByFilterQueryHandler : IRequestHandler +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetAllProductCategoryByFilter; +public class GetAllProductCategoryByFilterQueryHandler : IRequestHandler { private readonly IApplicationDbContext _context; - public GetAllPruductCategoryByFilterQueryHandler(IApplicationDbContext context) + public GetAllProductCategoryByFilterQueryHandler(IApplicationDbContext context) { _context = context; } - public async Task Handle(GetAllPruductCategoryByFilterQuery request, CancellationToken cancellationToken) + public async Task Handle(GetAllProductCategoryByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.PruductCategorys + var query = _context.ProductCategories .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); @@ -22,11 +22,11 @@ public class GetAllPruductCategoryByFilterQueryHandler : IRequestHandler request.Filter.CategoryId == null || x.CategoryId==request.Filter.CategoryId) ; } - return new GetAllPruductCategoryByFilterResponseDto + return new GetAllProductCategoryByFilterResponseDto { MetaData = await query.GetMetaData(request.PaginationState, cancellationToken), Models = await query.PaginatedListAsync(paginationState: request.PaginationState) - .ProjectToType().ToListAsync(cancellationToken) + .ProjectToType().ToListAsync(cancellationToken) }; } } diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQueryValidator.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQueryValidator.cs similarity index 54% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQueryValidator.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQueryValidator.cs index dac1c0b..0262d8c 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterQueryValidator.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterQueryValidator.cs @@ -1,12 +1,12 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetAllPruductCategoryByFilter; -public class GetAllPruductCategoryByFilterQueryValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetAllProductCategoryByFilter; +public class GetAllProductCategoryByFilterQueryValidator : AbstractValidator { - public GetAllPruductCategoryByFilterQueryValidator() + public GetAllProductCategoryByFilterQueryValidator() { } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllPruductCategoryByFilterQuery)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductCategoryByFilterQuery)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterResponseDto.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterResponseDto.cs similarity index 53% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterResponseDto.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterResponseDto.cs index d16097a..5bf996d 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetAllPruductCategoryByFilter/GetAllPruductCategoryByFilterResponseDto.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetAllProductCategoryByFilter/GetAllPruductCategoryByFilterResponseDto.cs @@ -1,12 +1,12 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetAllPruductCategoryByFilter; -public class GetAllPruductCategoryByFilterResponseDto +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetAllProductCategoryByFilter; +public class GetAllProductCategoryByFilterResponseDto { //متادیتا public MetaData MetaData { get; set; } //مدل خروجی - public List? Models { get; set; } + public List? Models { get; set; } -}public class GetAllPruductCategoryByFilterResponseModel +}public class GetAllProductCategoryByFilterResponseModel { //شناسه public long Id { get; set; } diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQuery.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQuery.cs new file mode 100644 index 0000000..2f58937 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQuery.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetProductCategory; +public record GetProductCategoryQuery : IRequest +{ + //شناسه + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQueryHandler.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQueryHandler.cs new file mode 100644 index 0000000..cceea03 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQueryHandler.cs @@ -0,0 +1,22 @@ +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetProductCategory; +public class GetProductCategoryQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetProductCategoryQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetProductCategoryQuery request, + CancellationToken cancellationToken) + { + var response = await _context.ProductCategories + .AsNoTracking() + .Where(x => x.Id == request.Id) + .ProjectToType() + .FirstOrDefaultAsync(cancellationToken); + + return response ?? throw new NotFoundException(nameof(ProductCategory), request.Id); + } +} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQueryValidator.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQueryValidator.cs similarity index 60% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQueryValidator.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQueryValidator.cs index 8bb4a8d..0fe4615 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQueryValidator.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryQueryValidator.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetPruductCategory; -public class GetPruductCategoryQueryValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetProductCategory; +public class GetProductCategoryQueryValidator : AbstractValidator { - public GetPruductCategoryQueryValidator() + public GetProductCategoryQueryValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetPruductCategoryQuery)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductCategoryQuery)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryResponseDto.cs b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryResponseDto.cs similarity index 61% rename from src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryResponseDto.cs rename to src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryResponseDto.cs index c05f9cd..e0dc635 100644 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryResponseDto.cs +++ b/src/CMSMicroservice.Application/ProductCategoryCQ/Queries/GetProductCategory/GetPruductCategoryResponseDto.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetPruductCategory; -public class GetPruductCategoryResponseDto +namespace CMSMicroservice.Application.ProductCategoryCQ.Queries.GetProductCategory; +public class GetProductCategoryResponseDto { //شناسه public long Id { get; set; } diff --git a/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommand.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommand.cs new file mode 100644 index 0000000..e14931d --- /dev/null +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommand.cs @@ -0,0 +1,9 @@ +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.CreateNewProductGalleries; +public record CreateNewProductGalleriesCommand : IRequest +{ + // + public long ProductImageId { get; init; } + // + public long ProductId { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommandHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommandHandler.cs similarity index 65% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommandHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommandHandler.cs index 2eac816..3c4bd09 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommandHandler.cs @@ -1,6 +1,6 @@ using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.CreateNewProductGallerys; -public class CreateNewProductGallerysCommandHandler : IRequestHandler +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.CreateNewProductGalleries; +public class CreateNewProductGallerysCommandHandler : IRequestHandler { private readonly IApplicationDbContext _context; @@ -9,11 +9,11 @@ public class CreateNewProductGallerysCommandHandler : IRequestHandler Handle(CreateNewProductGallerysCommand request, + public async Task Handle(CreateNewProductGalleriesCommand request, CancellationToken cancellationToken) { - var entity = request.Adapt(); - await _context.ProductGalleryss.AddAsync(entity, cancellationToken); + var entity = request.Adapt(); + await _context.ProductGalleries.AddAsync(entity, cancellationToken); entity.AddDomainEvent(new CreateNewProductGallerysEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return entity.Adapt(); diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommandValidator.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommandValidator.cs similarity index 68% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommandValidator.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommandValidator.cs index 270c200..cc12def 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesCommandValidator.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.CreateNewProductGallerys; -public class CreateNewProductGallerysCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.CreateNewProductGalleries; +public class CreateNewProductGallerysCommandValidator : AbstractValidator { public CreateNewProductGallerysCommandValidator() { @@ -10,7 +10,7 @@ public class CreateNewProductGallerysCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductGallerysCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductGalleriesCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysResponseDto.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesResponseDto.cs similarity index 50% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysResponseDto.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesResponseDto.cs index f4b67ab..be57b2c 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysResponseDto.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/CreateNewProductGalleries/CreateNewProductGalleriesResponseDto.cs @@ -1,4 +1,4 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.CreateNewProductGallerys; +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.CreateNewProductGalleries; public class CreateNewProductGallerysResponseDto { // diff --git a/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommand.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommand.cs new file mode 100644 index 0000000..281a5a9 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommand.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.DeleteProductGalleries; +public record DeleteProductGalleriesCommand : IRequest +{ + // + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommandHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommandHandler.cs similarity index 62% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommandHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommandHandler.cs index 266fe93..bdd38e5 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommandHandler.cs @@ -1,6 +1,6 @@ using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.DeleteProductGallerys; -public class DeleteProductGallerysCommandHandler : IRequestHandler +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.DeleteProductGalleries; +public class DeleteProductGallerysCommandHandler : IRequestHandler { private readonly IApplicationDbContext _context; @@ -9,12 +9,12 @@ public class DeleteProductGallerysCommandHandler : IRequestHandler Handle(DeleteProductGallerysCommand request, CancellationToken cancellationToken) + public async Task Handle(DeleteProductGalleriesCommand request, CancellationToken cancellationToken) { - var entity = await _context.ProductGalleryss - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductGallerys), request.Id); + var entity = await _context.ProductGalleries + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductGallery), request.Id); entity.IsDeleted = true; - _context.ProductGalleryss.Update(entity); + _context.ProductGalleries.Update(entity); entity.AddDomainEvent(new DeleteProductGallerysEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommandValidator.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommandValidator.cs similarity index 66% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommandValidator.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommandValidator.cs index 678a1b5..13f69e1 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/DeleteProductGalleries/DeleteProductGalleriesCommandValidator.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.DeleteProductGallerys; -public class DeleteProductGallerysCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.DeleteProductGalleries; +public class DeleteProductGallerysCommandValidator : AbstractValidator { public DeleteProductGallerysCommandValidator() { @@ -8,7 +8,7 @@ public class DeleteProductGallerysCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductGallerysCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductGalleriesCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommand.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommand.cs new file mode 100644 index 0000000..57746c0 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommand.cs @@ -0,0 +1,11 @@ +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.UpdateProductGalleries; +public record UpdateProductGalleriesCommand : IRequest +{ + // + public long Id { get; init; } + // + public long ProductImageId { get; init; } + // + public long ProductId { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommandHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommandHandler.cs similarity index 62% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommandHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommandHandler.cs index dba3b60..d19975c 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommandHandler.cs @@ -1,6 +1,6 @@ using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.UpdateProductGallerys; -public class UpdateProductGallerysCommandHandler : IRequestHandler +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.UpdateProductGalleries; +public class UpdateProductGallerysCommandHandler : IRequestHandler { private readonly IApplicationDbContext _context; @@ -9,12 +9,12 @@ public class UpdateProductGallerysCommandHandler : IRequestHandler Handle(UpdateProductGallerysCommand request, CancellationToken cancellationToken) + public async Task Handle(UpdateProductGalleriesCommand request, CancellationToken cancellationToken) { - var entity = await _context.ProductGalleryss - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductGallerys), request.Id); + var entity = await _context.ProductGalleries + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductGallery), request.Id); request.Adapt(entity); - _context.ProductGalleryss.Update(entity); + _context.ProductGalleries.Update(entity); entity.AddDomainEvent(new UpdateProductGallerysEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommandValidator.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommandValidator.cs similarity index 71% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommandValidator.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommandValidator.cs index a66c7ed..467aab0 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Commands/UpdateProductGalleries/UpdateProductGalleriesCommandValidator.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.UpdateProductGallerys; -public class UpdateProductGallerysCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.UpdateProductGalleries; +public class UpdateProductGallerysCommandValidator : AbstractValidator { public UpdateProductGallerysCommandValidator() { @@ -12,7 +12,7 @@ public class UpdateProductGallerysCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductGallerysCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductGalleriesCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/CreateNewProductGallerysEventHandlers/CreateNewProductGallerysEventHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/CreateNewProductGalleriesEventHandlers/CreateNewProductGalleriesEventHandler.cs similarity index 90% rename from src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/CreateNewProductGallerysEventHandlers/CreateNewProductGallerysEventHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/CreateNewProductGalleriesEventHandlers/CreateNewProductGalleriesEventHandler.cs index ad83500..d5517fa 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/CreateNewProductGallerysEventHandlers/CreateNewProductGallerysEventHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/CreateNewProductGalleriesEventHandlers/CreateNewProductGalleriesEventHandler.cs @@ -1,7 +1,7 @@ using CMSMicroservice.Domain.Events; using Microsoft.Extensions.Logging; -namespace CMSMicroservice.Application.ProductGallerysCQ.EventHandlers; +namespace CMSMicroservice.Application.ProductGalleriesCQ.EventHandlers; public class CreateNewProductGallerysEventHandler : INotificationHandler { diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/DeleteProductGallerysEventHandlers/DeleteProductGallerysEventHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/DeleteProductGalleriesEventHandlers/DeleteProductGalleriesEventHandler.cs similarity index 89% rename from src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/DeleteProductGallerysEventHandlers/DeleteProductGallerysEventHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/DeleteProductGalleriesEventHandlers/DeleteProductGalleriesEventHandler.cs index bbdd777..d0596ac 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/DeleteProductGallerysEventHandlers/DeleteProductGallerysEventHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/DeleteProductGalleriesEventHandlers/DeleteProductGalleriesEventHandler.cs @@ -1,7 +1,7 @@ using CMSMicroservice.Domain.Events; using Microsoft.Extensions.Logging; -namespace CMSMicroservice.Application.ProductGallerysCQ.EventHandlers; +namespace CMSMicroservice.Application.ProductGalleriesCQ.EventHandlers; public class DeleteProductGallerysEventHandler : INotificationHandler { diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/UpdateProductGallerysEventHandlers/UpdateProductGallerysEventHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/UpdateProductGalleriesEventHandlers/UpdateProductGalleriesEventHandler.cs similarity index 89% rename from src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/UpdateProductGallerysEventHandlers/UpdateProductGallerysEventHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/UpdateProductGalleriesEventHandlers/UpdateProductGalleriesEventHandler.cs index d04c98f..a6f0b0e 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/EventHandlers/UpdateProductGallerysEventHandlers/UpdateProductGallerysEventHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/EventHandlers/UpdateProductGalleriesEventHandlers/UpdateProductGalleriesEventHandler.cs @@ -1,7 +1,7 @@ using CMSMicroservice.Domain.Events; using Microsoft.Extensions.Logging; -namespace CMSMicroservice.Application.ProductGallerysCQ.EventHandlers; +namespace CMSMicroservice.Application.ProductGalleriesCQ.EventHandlers; public class UpdateProductGallerysEventHandler : INotificationHandler { diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQuery.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQuery.cs similarity index 70% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQuery.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQuery.cs index 34f3890..4dc165e 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQuery.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQuery.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetAllProductGallerysByFilter; -public record GetAllProductGallerysByFilterQuery : IRequest +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetAllProductGalleriesByFilter; +public record GetAllProductGalleriesByFilterQuery : IRequest { //موقعیت صفحه بندی public PaginationState? PaginationState { get; init; } diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQueryHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQueryHandler.cs similarity index 79% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQueryHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQueryHandler.cs index 261059b..62f3000 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQueryHandler.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetAllProductGallerysByFilter; -public class GetAllProductGallerysByFilterQueryHandler : IRequestHandler +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetAllProductGalleriesByFilter; +public class GetAllProductGallerysByFilterQueryHandler : IRequestHandler { private readonly IApplicationDbContext _context; @@ -8,9 +8,9 @@ public class GetAllProductGallerysByFilterQueryHandler : IRequestHandler Handle(GetAllProductGallerysByFilterQuery request, CancellationToken cancellationToken) + public async Task Handle(GetAllProductGalleriesByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.ProductGalleryss + var query = _context.ProductGalleries .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQueryValidator.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQueryValidator.cs similarity index 61% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQueryValidator.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQueryValidator.cs index 13985f8..edba0e2 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterQueryValidator.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterQueryValidator.cs @@ -1,12 +1,12 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetAllProductGallerysByFilter; -public class GetAllProductGallerysByFilterQueryValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetAllProductGalleriesByFilter; +public class GetAllProductGallerysByFilterQueryValidator : AbstractValidator { public GetAllProductGallerysByFilterQueryValidator() { } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductGallerysByFilterQuery)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductGalleriesByFilterQuery)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterResponseDto.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterResponseDto.cs similarity index 81% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterResponseDto.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterResponseDto.cs index 4fe4797..31f0a08 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetAllProductGallerysByFilter/GetAllProductGallerysByFilterResponseDto.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetAllProductGalleriesByFilter/GetAllProductGalleriesByFilterResponseDto.cs @@ -1,4 +1,4 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetAllProductGallerysByFilter; +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetAllProductGalleriesByFilter; public class GetAllProductGallerysByFilterResponseDto { //متادیتا diff --git a/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQuery.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQuery.cs new file mode 100644 index 0000000..b99a087 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQuery.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetProductGalleries; +public record GetProductGalleriesQuery : IRequest +{ + // + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQueryHandler.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQueryHandler.cs similarity index 70% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQueryHandler.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQueryHandler.cs index e2f13dc..7acede0 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQueryHandler.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetProductGallerys; -public class GetProductGallerysQueryHandler : IRequestHandler +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetProductGalleries; +public class GetProductGallerysQueryHandler : IRequestHandler { private readonly IApplicationDbContext _context; @@ -8,15 +8,15 @@ public class GetProductGallerysQueryHandler : IRequestHandler Handle(GetProductGallerysQuery request, + public async Task Handle(GetProductGalleriesQuery request, CancellationToken cancellationToken) { - var response = await _context.ProductGalleryss + var response = await _context.ProductGalleries .AsNoTracking() .Where(x => x.Id == request.Id) .ProjectToType() .FirstOrDefaultAsync(cancellationToken); - return response ?? throw new NotFoundException(nameof(ProductGallerys), request.Id); + return response ?? throw new NotFoundException(nameof(ProductGallery), request.Id); } } diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQueryValidator.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQueryValidator.cs similarity index 68% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQueryValidator.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQueryValidator.cs index d79dca4..0c6fcdf 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQueryValidator.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesQueryValidator.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetProductGallerys; -public class GetProductGallerysQueryValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetProductGalleries; +public class GetProductGallerysQueryValidator : AbstractValidator { public GetProductGallerysQueryValidator() { @@ -8,7 +8,7 @@ public class GetProductGallerysQueryValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductGallerysQuery)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductGalleriesQuery)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysResponseDto.cs b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesResponseDto.cs similarity index 68% rename from src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysResponseDto.cs rename to src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesResponseDto.cs index 85580dc..14f3525 100644 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysResponseDto.cs +++ b/src/CMSMicroservice.Application/ProductGalleriesCQ/Queries/GetProductGalleries/GetProductGalleriesResponseDto.cs @@ -1,4 +1,4 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetProductGallerys; +namespace CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetProductGalleries; public class GetProductGallerysResponseDto { // diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommand.cs b/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommand.cs deleted file mode 100644 index 3435e3e..0000000 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/CreateNewProductGallerys/CreateNewProductGallerysCommand.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.CreateNewProductGallerys; -public record CreateNewProductGallerysCommand : IRequest -{ - // - public long ProductImageId { get; init; } - // - public long ProductId { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommand.cs b/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommand.cs deleted file mode 100644 index 9b3c7d7..0000000 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/DeleteProductGallerys/DeleteProductGallerysCommand.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.DeleteProductGallerys; -public record DeleteProductGallerysCommand : IRequest -{ - // - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommand.cs b/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommand.cs deleted file mode 100644 index 1c2519d..0000000 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Commands/UpdateProductGallerys/UpdateProductGallerysCommand.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Commands.UpdateProductGallerys; -public record UpdateProductGallerysCommand : IRequest -{ - // - public long Id { get; init; } - // - public long ProductImageId { get; init; } - // - public long ProductId { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQuery.cs b/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQuery.cs deleted file mode 100644 index dd0feb2..0000000 --- a/src/CMSMicroservice.Application/ProductGallerysCQ/Queries/GetProductGallerys/GetProductGallerysQuery.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.ProductGallerysCQ.Queries.GetProductGallerys; -public record GetProductGallerysQuery : IRequest -{ - // - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductImagesCQ/Commands/CreateNewProductImages/CreateNewProductImagesCommandHandler.cs b/src/CMSMicroservice.Application/ProductImagesCQ/Commands/CreateNewProductImages/CreateNewProductImagesCommandHandler.cs index 74f4e75..804bf14 100644 --- a/src/CMSMicroservice.Application/ProductImagesCQ/Commands/CreateNewProductImages/CreateNewProductImagesCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductImagesCQ/Commands/CreateNewProductImages/CreateNewProductImagesCommandHandler.cs @@ -12,8 +12,8 @@ public class CreateNewProductImagesCommandHandler : IRequestHandler Handle(CreateNewProductImagesCommand request, CancellationToken cancellationToken) { - var entity = request.Adapt(); - await _context.ProductImagess.AddAsync(entity, cancellationToken); + var entity = request.Adapt(); + await _context.ProductImages.AddAsync(entity, cancellationToken); entity.AddDomainEvent(new CreateNewProductImagesEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return entity.Adapt(); diff --git a/src/CMSMicroservice.Application/ProductImagesCQ/Commands/DeleteProductImages/DeleteProductImagesCommandHandler.cs b/src/CMSMicroservice.Application/ProductImagesCQ/Commands/DeleteProductImages/DeleteProductImagesCommandHandler.cs index 15996ac..f82d62d 100644 --- a/src/CMSMicroservice.Application/ProductImagesCQ/Commands/DeleteProductImages/DeleteProductImagesCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductImagesCQ/Commands/DeleteProductImages/DeleteProductImagesCommandHandler.cs @@ -11,10 +11,10 @@ public class DeleteProductImagesCommandHandler : IRequestHandler Handle(DeleteProductImagesCommand request, CancellationToken cancellationToken) { - var entity = await _context.ProductImagess - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductImages), request.Id); + var entity = await _context.ProductImages + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductImage), request.Id); entity.IsDeleted = true; - _context.ProductImagess.Update(entity); + _context.ProductImages.Update(entity); entity.AddDomainEvent(new DeleteProductImagesEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/ProductImagesCQ/Commands/UpdateProductImages/UpdateProductImagesCommandHandler.cs b/src/CMSMicroservice.Application/ProductImagesCQ/Commands/UpdateProductImages/UpdateProductImagesCommandHandler.cs index 9b4f5dd..5233f72 100644 --- a/src/CMSMicroservice.Application/ProductImagesCQ/Commands/UpdateProductImages/UpdateProductImagesCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductImagesCQ/Commands/UpdateProductImages/UpdateProductImagesCommandHandler.cs @@ -11,10 +11,10 @@ public class UpdateProductImagesCommandHandler : IRequestHandler Handle(UpdateProductImagesCommand request, CancellationToken cancellationToken) { - var entity = await _context.ProductImagess - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductImages), request.Id); + var entity = await _context.ProductImages + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductImage), request.Id); request.Adapt(entity); - _context.ProductImagess.Update(entity); + _context.ProductImages.Update(entity); entity.AddDomainEvent(new UpdateProductImagesEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetAllProductImagesByFilter/GetAllProductImagesByFilterQueryHandler.cs b/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetAllProductImagesByFilter/GetAllProductImagesByFilterQueryHandler.cs index 9e76ce0..24232b5 100644 --- a/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetAllProductImagesByFilter/GetAllProductImagesByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetAllProductImagesByFilter/GetAllProductImagesByFilterQueryHandler.cs @@ -10,7 +10,7 @@ public class GetAllProductImagesByFilterQueryHandler : IRequestHandler Handle(GetAllProductImagesByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.ProductImagess + var query = _context.ProductImages .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); diff --git a/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetProductImages/GetProductImagesQueryHandler.cs b/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetProductImages/GetProductImagesQueryHandler.cs index 4090393..d0f8e9a 100644 --- a/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetProductImages/GetProductImagesQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductImagesCQ/Queries/GetProductImages/GetProductImagesQueryHandler.cs @@ -11,12 +11,12 @@ public class GetProductImagesQueryHandler : IRequestHandler Handle(GetProductImagesQuery request, CancellationToken cancellationToken) { - var response = await _context.ProductImagess + var response = await _context.ProductImages .AsNoTracking() .Where(x => x.Id == request.Id) .ProjectToType() .FirstOrDefaultAsync(cancellationToken); - return response ?? throw new NotFoundException(nameof(ProductImages), request.Id); + return response ?? throw new NotFoundException(nameof(ProductImage), request.Id); } } diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommand.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommand.cs similarity index 51% rename from src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommand.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommand.cs index 3d8aed8..75ab0ed 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommand.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommand.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Commands.CreateNewPruductTag; -public record CreateNewPruductTagCommand : IRequest +namespace CMSMicroservice.Application.ProductTagCQ.Commands.CreateNewProductTag; +public record CreateNewProductTagCommand : IRequest { //شناسه محصول public long ProductId { get; init; } diff --git a/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommandHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommandHandler.cs new file mode 100644 index 0000000..e03b210 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommandHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.ProductTagCQ.Commands.CreateNewProductTag; +public class CreateNewProductTagCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public CreateNewProductTagCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CreateNewProductTagCommand request, + CancellationToken cancellationToken) + { + var entity = request.Adapt(); + await _context.ProductTags.AddAsync(entity, cancellationToken); + entity.AddDomainEvent(new CreateNewProductTagEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return entity.Adapt(); + } +} + diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommandValidator.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommandValidator.cs similarity index 63% rename from src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommandValidator.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommandValidator.cs index 08f896f..662a580 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagCommandValidator.cs @@ -1,7 +1,7 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Commands.CreateNewPruductTag; -public class CreateNewPruductTagCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductTagCQ.Commands.CreateNewProductTag; +public class CreateNewProductTagCommandValidator : AbstractValidator { - public CreateNewPruductTagCommandValidator() + public CreateNewProductTagCommandValidator() { RuleFor(model => model.ProductId) .NotNull(); @@ -10,7 +10,7 @@ public class CreateNewPruductTagCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewPruductTagCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductTagCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagResponseDto.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagResponseDto.cs new file mode 100644 index 0000000..90f369b --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/CreateNewProductTag/CreateNewPruductTagResponseDto.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductTagCQ.Commands.CreateNewProductTag; +public class CreateNewProductTagResponseDto +{ + //شناسه + public long Id { get; set; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommand.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommand.cs new file mode 100644 index 0000000..bd84858 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommand.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductTagCQ.Commands.DeleteProductTag; +public record DeleteProductTagCommand : IRequest +{ + //شناسه + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommandHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommandHandler.cs new file mode 100644 index 0000000..6f2db60 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommandHandler.cs @@ -0,0 +1,23 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.ProductTagCQ.Commands.DeleteProductTag; +public class DeleteProductTagCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public DeleteProductTagCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(DeleteProductTagCommand request, CancellationToken cancellationToken) + { + var entity = await _context.ProductTags + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductTag), request.Id); + entity.IsDeleted = true; + _context.ProductTags.Update(entity); + entity.AddDomainEvent(new DeleteProductTagEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} + diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommandValidator.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommandValidator.cs similarity index 60% rename from src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommandValidator.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommandValidator.cs index 5ed1795..629f10b 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/DeleteProductTag/DeletePruductTagCommandValidator.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Commands.DeletePruductTag; -public class DeletePruductTagCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductTagCQ.Commands.DeleteProductTag; +public class DeleteProductTagCommandValidator : AbstractValidator { - public DeletePruductTagCommandValidator() + public DeleteProductTagCommandValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeletePruductTagCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductTagCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommand.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommand.cs similarity index 58% rename from src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommand.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommand.cs index c880f11..737c8df 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommand.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommand.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Commands.UpdatePruductTag; -public record UpdatePruductTagCommand : IRequest +namespace CMSMicroservice.Application.ProductTagCQ.Commands.UpdateProductTag; +public record UpdateProductTagCommand : IRequest { //شناسه public long Id { get; init; } diff --git a/src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommandHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommandHandler.cs new file mode 100644 index 0000000..aae90e7 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommandHandler.cs @@ -0,0 +1,23 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.ProductTagCQ.Commands.UpdateProductTag; +public class UpdateProductTagCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateProductTagCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateProductTagCommand request, CancellationToken cancellationToken) + { + var entity = await _context.ProductTags + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(ProductTag), request.Id); + request.Adapt(entity); + _context.ProductTags.Update(entity); + entity.AddDomainEvent(new UpdateProductTagEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} + diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommandValidator.cs b/src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommandValidator.cs similarity index 66% rename from src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommandValidator.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommandValidator.cs index 8dc83bb..885ce12 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Commands/UpdateProductTag/UpdatePruductTagCommandValidator.cs @@ -1,7 +1,7 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Commands.UpdatePruductTag; -public class UpdatePruductTagCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductTagCQ.Commands.UpdateProductTag; +public class UpdateProductTagCommandValidator : AbstractValidator { - public UpdatePruductTagCommandValidator() + public UpdateProductTagCommandValidator() { RuleFor(model => model.Id) .NotNull(); @@ -12,7 +12,7 @@ public class UpdatePruductTagCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdatePruductTagCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductTagCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/CreateNewProductTagEventHandlers/CreateNewPruductTagEventHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/CreateNewProductTagEventHandlers/CreateNewPruductTagEventHandler.cs new file mode 100644 index 0000000..c2c2878 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/CreateNewProductTagEventHandlers/CreateNewPruductTagEventHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ProductTagCQ.EventHandlers; + +public class CreateNewProductTagEventHandler : INotificationHandler +{ + private readonly ILogger _logger; + + public CreateNewProductTagEventHandler(ILogger logger) + { + _logger = logger; + } + + public Task Handle(CreateNewProductTagEvent notification, CancellationToken cancellationToken) + { + _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); + + return Task.CompletedTask; + } +} + diff --git a/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/DeleteProductTagEventHandlers/DeletePruductTagEventHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/DeleteProductTagEventHandlers/DeletePruductTagEventHandler.cs new file mode 100644 index 0000000..d370629 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/DeleteProductTagEventHandlers/DeletePruductTagEventHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ProductTagCQ.EventHandlers; + +public class DeleteProductTagEventHandler : INotificationHandler +{ + private readonly ILogger _logger; + + public DeleteProductTagEventHandler(ILogger logger) + { + _logger = logger; + } + + public Task Handle(DeleteProductTagEvent notification, CancellationToken cancellationToken) + { + _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); + + return Task.CompletedTask; + } +} + diff --git a/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/UpdateProductTagEventHandlers/UpdatePruductTagEventHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/UpdateProductTagEventHandlers/UpdatePruductTagEventHandler.cs new file mode 100644 index 0000000..293ffef --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/EventHandlers/UpdateProductTagEventHandlers/UpdatePruductTagEventHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ProductTagCQ.EventHandlers; + +public class UpdateProductTagEventHandler : INotificationHandler +{ + private readonly ILogger _logger; + + public UpdateProductTagEventHandler(ILogger logger) + { + _logger = logger; + } + + public Task Handle(UpdateProductTagEvent notification, CancellationToken cancellationToken) + { + _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); + + return Task.CompletedTask; + } +} + diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQuery.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQuery.cs similarity index 61% rename from src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQuery.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQuery.cs index a13b196..45084da 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQuery.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQuery.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetAllPruductTagByFilter; -public record GetAllPruductTagByFilterQuery : IRequest +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetAllProductTagByFilter; +public record GetAllProductTagByFilterQuery : IRequest { //موقعیت صفحه بندی public PaginationState? PaginationState { get; init; } //مرتب سازی بر اساس public string? SortBy { get; init; } //فیلتر - public GetAllPruductTagByFilterFilter? Filter { get; init; } + public GetAllProductTagByFilterFilter? Filter { get; init; } -}public class GetAllPruductTagByFilterFilter +}public class GetAllProductTagByFilterFilter { //شناسه public long? Id { get; set; } diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQueryHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQueryHandler.cs similarity index 60% rename from src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQueryHandler.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQueryHandler.cs index 52c16f2..6b7541a 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQueryHandler.cs @@ -1,16 +1,16 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetAllPruductTagByFilter; -public class GetAllPruductTagByFilterQueryHandler : IRequestHandler +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetAllProductTagByFilter; +public class GetAllProductTagByFilterQueryHandler : IRequestHandler { private readonly IApplicationDbContext _context; - public GetAllPruductTagByFilterQueryHandler(IApplicationDbContext context) + public GetAllProductTagByFilterQueryHandler(IApplicationDbContext context) { _context = context; } - public async Task Handle(GetAllPruductTagByFilterQuery request, CancellationToken cancellationToken) + public async Task Handle(GetAllProductTagByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.PruductTags + var query = _context.ProductTags .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); @@ -22,11 +22,11 @@ public class GetAllPruductTagByFilterQueryHandler : IRequestHandler request.Filter.TagId == null || x.TagId==request.Filter.TagId) ; } - return new GetAllPruductTagByFilterResponseDto + return new GetAllProductTagByFilterResponseDto { MetaData = await query.GetMetaData(request.PaginationState, cancellationToken), Models = await query.PaginatedListAsync(paginationState: request.PaginationState) - .ProjectToType().ToListAsync(cancellationToken) + .ProjectToType().ToListAsync(cancellationToken) }; } } diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQueryValidator.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQueryValidator.cs similarity index 56% rename from src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQueryValidator.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQueryValidator.cs index 31e9f49..c83b86b 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterQueryValidator.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterQueryValidator.cs @@ -1,12 +1,12 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetAllPruductTagByFilter; -public class GetAllPruductTagByFilterQueryValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetAllProductTagByFilter; +public class GetAllProductTagByFilterQueryValidator : AbstractValidator { - public GetAllPruductTagByFilterQueryValidator() + public GetAllProductTagByFilterQueryValidator() { } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllPruductTagByFilterQuery)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductTagByFilterQuery)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterResponseDto.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterResponseDto.cs similarity index 53% rename from src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterResponseDto.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterResponseDto.cs index 8de7698..32a2fa3 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetAllPruductTagByFilter/GetAllPruductTagByFilterResponseDto.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetAllProductTagByFilter/GetAllPruductTagByFilterResponseDto.cs @@ -1,12 +1,12 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetAllPruductTagByFilter; -public class GetAllPruductTagByFilterResponseDto +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetAllProductTagByFilter; +public class GetAllProductTagByFilterResponseDto { //متادیتا public MetaData MetaData { get; set; } //مدل خروجی - public List? Models { get; set; } + public List? Models { get; set; } -}public class GetAllPruductTagByFilterResponseModel +}public class GetAllProductTagByFilterResponseModel { //شناسه public long Id { get; set; } diff --git a/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQuery.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQuery.cs new file mode 100644 index 0000000..8bcdbf0 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQuery.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetProductTag; +public record GetProductTagQuery : IRequest +{ + //شناسه + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQueryHandler.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQueryHandler.cs new file mode 100644 index 0000000..c8192c9 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQueryHandler.cs @@ -0,0 +1,23 @@ +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetProductTag; +public class GetProductTagQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetProductTagQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetProductTagQuery request, + CancellationToken cancellationToken) + { + var response = await _context.ProductTags + .AsNoTracking() + .Where(x => x.Id == request.Id) + .ProjectToType() + .FirstOrDefaultAsync(cancellationToken); + + return response ?? throw new NotFoundException(nameof(ProductTag), request.Id); + } +} + diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQueryValidator.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQueryValidator.cs similarity index 62% rename from src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQueryValidator.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQueryValidator.cs index 655ff9d..d038233 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQueryValidator.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagQueryValidator.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetPruductTag; -public class GetPruductTagQueryValidator : AbstractValidator +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetProductTag; +public class GetProductTagQueryValidator : AbstractValidator { - public GetPruductTagQueryValidator() + public GetProductTagQueryValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetPruductTagQuery)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductTagQuery)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagResponseDto.cs b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagResponseDto.cs similarity index 62% rename from src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagResponseDto.cs rename to src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagResponseDto.cs index 54beeda..4813d06 100644 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagResponseDto.cs +++ b/src/CMSMicroservice.Application/ProductTagCQ/Queries/GetProductTag/GetPruductTagResponseDto.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetPruductTag; -public class GetPruductTagResponseDto +namespace CMSMicroservice.Application.ProductTagCQ.Queries.GetProductTag; +public class GetProductTagResponseDto { //شناسه public long Id { get; set; } diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommand.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommand.cs new file mode 100644 index 0000000..0ba6b4f --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommand.cs @@ -0,0 +1,64 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.BulkUpdateProductPrices; + +/// +/// به‌روزرسانی دسته‌ای قیمت محصولات +/// +public record BulkUpdateProductPricesCommand : IRequest +{ + /// + /// لیست محصولات و قیمت‌های جدید + /// + public List Products { get; init; } = new(); +} + +/// +/// مدل به‌روزرسانی قیمت یک محصول +/// +public class ProductPriceUpdate +{ + /// + /// شناسه محصول + /// + public long ProductId { get; set; } + + /// + /// قیمت جدید (ریال) + /// + public long NewPrice { get; set; } + + /// + /// درصد تخفیف جدید (اختیاری) + /// + public int? NewDiscount { get; set; } + + /// + /// درصد تخفیف باشگاه جدید (اختیاری) + /// + public int? NewClubDiscountPercent { get; set; } +} + +/// +/// پاسخ به‌روزرسانی دسته‌ای قیمت +/// +public class BulkUpdateProductPricesResponseDto +{ + /// + /// تعداد محصولات به‌روزرسانی شده + /// + public int UpdatedCount { get; set; } + + /// + /// تعداد محصولات ناموفق + /// + public int FailedCount { get; set; } + + /// + /// جزئیات خطاها + /// + public List Errors { get; set; } = new(); + + /// + /// آیا همه موفق بودند + /// + public bool IsSuccess => FailedCount == 0; +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommandHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommandHandler.cs new file mode 100644 index 0000000..46527cf --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommandHandler.cs @@ -0,0 +1,77 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.BulkUpdateProductPrices; + +public class BulkUpdateProductPricesCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public BulkUpdateProductPricesCommandHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(BulkUpdateProductPricesCommand request, CancellationToken cancellationToken) + { + var response = new BulkUpdateProductPricesResponseDto(); + var productIds = request.Products.Select(p => p.ProductId).ToList(); + + // دریافت محصولات از دیتابیس + var products = await _context.Products + .Where(p => productIds.Contains(p.Id)) + .ToListAsync(cancellationToken); + + var productDict = products.ToDictionary(p => p.Id); + + foreach (var update in request.Products) + { + try + { + if (!productDict.TryGetValue(update.ProductId, out var product)) + { + response.FailedCount++; + response.Errors.Add($"محصول با شناسه {update.ProductId} یافت نشد"); + continue; + } + + // به‌روزرسانی قیمت + product.Price = update.NewPrice; + + // به‌روزرسانی تخفیف (اگر ارسال شده باشد) + if (update.NewDiscount.HasValue) + { + product.Discount = update.NewDiscount.Value; + } + + // به‌روزرسانی تخفیف باشگاه (اگر ارسال شده باشد) + if (update.NewClubDiscountPercent.HasValue) + { + product.ClubDiscountPercent = update.NewClubDiscountPercent.Value; + } + + response.UpdatedCount++; + + _logger.LogInformation( + "Product {ProductId} price updated to {NewPrice} (Discount: {Discount}%, ClubDiscount: {ClubDiscount}%)", + product.Id, product.Price, product.Discount, product.ClubDiscountPercent); + } + catch (Exception ex) + { + response.FailedCount++; + response.Errors.Add($"خطا در به‌روزرسانی محصول {update.ProductId}: {ex.Message}"); + _logger.LogError(ex, "Error updating product {ProductId} price", update.ProductId); + } + } + + if (response.UpdatedCount > 0) + { + await _context.SaveChangesAsync(cancellationToken); + _logger.LogInformation("Bulk price update completed: {UpdatedCount} succeeded, {FailedCount} failed", + response.UpdatedCount, response.FailedCount); + } + + return response; + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommandValidator.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommandValidator.cs new file mode 100644 index 0000000..2bb5728 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductPrices/BulkUpdateProductPricesCommandValidator.cs @@ -0,0 +1,30 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.BulkUpdateProductPrices; + +public class BulkUpdateProductPricesCommandValidator : AbstractValidator +{ + public BulkUpdateProductPricesCommandValidator() + { + RuleFor(x => x.Products) + .NotEmpty().WithMessage("لیست محصولات نمی‌تواند خالی باشد") + .Must(x => x.Count <= 100).WithMessage("حداکثر 100 محصول در هر بار قابل به‌روزرسانی است"); + + RuleForEach(x => x.Products).ChildRules(product => + { + product.RuleFor(p => p.ProductId) + .GreaterThan(0).WithMessage("شناسه محصول باید بزرگتر از 0 باشد"); + + product.RuleFor(p => p.NewPrice) + .GreaterThanOrEqualTo(0).WithMessage("قیمت نمی‌تواند منفی باشد"); + + product.RuleFor(p => p.NewDiscount) + .InclusiveBetween(0, 100) + .When(p => p.NewDiscount.HasValue) + .WithMessage("درصد تخفیف باید بین 0 تا 100 باشد"); + + product.RuleFor(p => p.NewClubDiscountPercent) + .InclusiveBetween(0, 100) + .When(p => p.NewClubDiscountPercent.HasValue) + .WithMessage("درصد تخفیف باشگاه باید بین 0 تا 100 باشد"); + }); + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommand.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommand.cs new file mode 100644 index 0000000..9219808 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommand.cs @@ -0,0 +1,80 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.BulkUpdateProductStock; + +/// +/// به‌روزرسانی دسته‌ای موجودی محصولات +/// +public record BulkUpdateProductStockCommand : IRequest +{ + /// + /// لیست محصولات و موجودی‌های جدید + /// + public List Products { get; init; } = new(); + + /// + /// نوع به‌روزرسانی + /// + public StockUpdateType UpdateType { get; init; } = StockUpdateType.Set; +} + +/// +/// نوع به‌روزرسانی موجودی +/// +public enum StockUpdateType +{ + /// + /// تنظیم مقدار مطلق + /// + Set = 1, + + /// + /// اضافه کردن به موجودی فعلی + /// + Add = 2, + + /// + /// کم کردن از موجودی فعلی + /// + Subtract = 3 +} + +/// +/// مدل به‌روزرسانی موجودی یک محصول +/// +public class ProductStockUpdate +{ + /// + /// شناسه محصول + /// + public long ProductId { get; set; } + + /// + /// مقدار جدید/تغییر موجودی + /// + public int Quantity { get; set; } +} + +/// +/// پاسخ به‌روزرسانی دسته‌ای موجودی +/// +public class BulkUpdateProductStockResponseDto +{ + /// + /// تعداد محصولات به‌روزرسانی شده + /// + public int UpdatedCount { get; set; } + + /// + /// تعداد محصولات ناموفق + /// + public int FailedCount { get; set; } + + /// + /// جزئیات خطاها + /// + public List Errors { get; set; } = new(); + + /// + /// آیا همه موفق بودند + /// + public bool IsSuccess => FailedCount == 0; +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommandHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommandHandler.cs new file mode 100644 index 0000000..123b760 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommandHandler.cs @@ -0,0 +1,88 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.BulkUpdateProductStock; + +public class BulkUpdateProductStockCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public BulkUpdateProductStockCommandHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(BulkUpdateProductStockCommand request, CancellationToken cancellationToken) + { + var response = new BulkUpdateProductStockResponseDto(); + var productIds = request.Products.Select(p => p.ProductId).ToList(); + + // دریافت محصولات از دیتابیس + var products = await _context.Products + .Where(p => productIds.Contains(p.Id)) + .ToListAsync(cancellationToken); + + var productDict = products.ToDictionary(p => p.Id); + + foreach (var update in request.Products) + { + try + { + if (!productDict.TryGetValue(update.ProductId, out var product)) + { + response.FailedCount++; + response.Errors.Add($"محصول با شناسه {update.ProductId} یافت نشد"); + continue; + } + + var oldStock = product.RemainingCount; + + // به‌روزرسانی موجودی بر اساس نوع + switch (request.UpdateType) + { + case StockUpdateType.Set: + product.RemainingCount = update.Quantity; + break; + + case StockUpdateType.Add: + product.RemainingCount += update.Quantity; + break; + + case StockUpdateType.Subtract: + product.RemainingCount -= update.Quantity; + // جلوگیری از موجودی منفی + if (product.RemainingCount < 0) + { + response.FailedCount++; + response.Errors.Add($"محصول {update.ProductId}: موجودی منفی شد (موجودی فعلی: {oldStock}, کم کردن: {update.Quantity})"); + product.RemainingCount = oldStock; // بازگرداندن مقدار قبلی + continue; + } + break; + } + + response.UpdatedCount++; + + _logger.LogInformation( + "Product {ProductId} stock updated from {OldStock} to {NewStock} (Type: {UpdateType})", + product.Id, oldStock, product.RemainingCount, request.UpdateType); + } + catch (Exception ex) + { + response.FailedCount++; + response.Errors.Add($"خطا در به‌روزرسانی محصول {update.ProductId}: {ex.Message}"); + _logger.LogError(ex, "Error updating product {ProductId} stock", update.ProductId); + } + } + + if (response.UpdatedCount > 0) + { + await _context.SaveChangesAsync(cancellationToken); + _logger.LogInformation("Bulk stock update completed: {UpdatedCount} succeeded, {FailedCount} failed", + response.UpdatedCount, response.FailedCount); + } + + return response; + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommandValidator.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommandValidator.cs new file mode 100644 index 0000000..18e28bb --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/BulkUpdateProductStock/BulkUpdateProductStockCommandValidator.cs @@ -0,0 +1,22 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.BulkUpdateProductStock; + +public class BulkUpdateProductStockCommandValidator : AbstractValidator +{ + public BulkUpdateProductStockCommandValidator() + { + RuleFor(x => x.Products) + .NotEmpty().WithMessage("لیست محصولات نمی‌تواند خالی باشد") + .Must(x => x.Count <= 100).WithMessage("حداکثر 100 محصول در هر بار قابل به‌روزرسانی است"); + + RuleForEach(x => x.Products).ChildRules(product => + { + product.RuleFor(p => p.ProductId) + .GreaterThan(0).WithMessage("شناسه محصول باید بزرگتر از 0 باشد"); + + // برای Set mode، مقدار نمی‌تواند منفی باشد (چک در Handler انجام می‌شود) + product.RuleFor(p => p.Quantity) + .GreaterThanOrEqualTo(-10000) + .WithMessage("مقدار موجودی نامعتبر است"); + }); + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs index d2cdad3..4e38c2e 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs @@ -13,8 +13,8 @@ public class CreateNewProductsCommandHandler : IRequestHandler Handle(CreateNewProductsCommand request, CancellationToken cancellationToken) { - var entity = request.Adapt(); - await _context.Productss.AddAsync(entity, cancellationToken); + var entity = request.Adapt(); + await _context.Products.AddAsync(entity, cancellationToken); await _context.SaveChangesAsync(cancellationToken); // ثبت دسته‌بندی‌های محصول (در صورت ارسال) @@ -27,12 +27,12 @@ public class CreateNewProductsCommandHandler : IRequestHandler Handle(DeleteProductsCommand request, CancellationToken cancellationToken) { - var entity = await _context.Productss - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Products), request.Id); + var entity = await _context.Products + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Product), request.Id); entity.IsDeleted = true; - _context.Productss.Update(entity); + _context.Products.Update(entity); entity.AddDomainEvent(new DeleteProductsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommand.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommand.cs new file mode 100644 index 0000000..bceadd7 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommand.cs @@ -0,0 +1,49 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.ToggleProductStatus; + +/// +/// فعال/غیرفعال کردن دسته‌ای محصولات +/// (با تنظیم موجودی به 0 برای غیرفعال کردن) +/// +public record ToggleProductStatusCommand : IRequest +{ + /// + /// لیست شناسه محصولات + /// + public List ProductIds { get; init; } = new(); + + /// + /// فعال کردن یا غیرفعال کردن + /// + public bool Enable { get; init; } + + /// + /// موجودی پیش‌فرض برای فعال‌سازی (پیش‌فرض: 1) + /// + public int DefaultStock { get; init; } = 1; +} + +/// +/// پاسخ فعال/غیرفعال کردن دسته‌ای +/// +public class ToggleProductStatusResponseDto +{ + /// + /// تعداد محصولات به‌روزرسانی شده + /// + public int UpdatedCount { get; set; } + + /// + /// تعداد محصولات ناموفق + /// + public int FailedCount { get; set; } + + /// + /// جزئیات خطاها + /// + public List Errors { get; set; } = new(); + + /// + /// آیا همه موفق بودند + /// + public bool IsSuccess => FailedCount == 0; +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommandHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommandHandler.cs new file mode 100644 index 0000000..1b5b5cd --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommandHandler.cs @@ -0,0 +1,82 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.ToggleProductStatus; + +public class ToggleProductStatusCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public ToggleProductStatusCommandHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(ToggleProductStatusCommand request, CancellationToken cancellationToken) + { + var response = new ToggleProductStatusResponseDto(); + + // دریافت محصولات از دیتابیس + var products = await _context.Products + .Where(p => request.ProductIds.Contains(p.Id)) + .ToListAsync(cancellationToken); + + if (products.Count == 0) + { + response.Errors.Add("هیچ محصولی با شناسه‌های داده شده یافت نشد"); + return response; + } + + foreach (var product in products) + { + try + { + if (request.Enable) + { + // فعال‌سازی: اگر موجودی 0 است، آن را به مقدار پیش‌فرض تنظیم کن + if (product.RemainingCount == 0) + { + product.RemainingCount = request.DefaultStock; + _logger.LogInformation( + "Product {ProductId} enabled with stock {Stock}", + product.Id, request.DefaultStock); + } + else + { + _logger.LogInformation( + "Product {ProductId} already has stock {Stock}, no change needed", + product.Id, product.RemainingCount); + } + } + else + { + // غیرفعال‌سازی: موجودی را به 0 تنظیم کن + var oldStock = product.RemainingCount; + product.RemainingCount = 0; + _logger.LogInformation( + "Product {ProductId} disabled (stock changed from {OldStock} to 0)", + product.Id, oldStock); + } + + response.UpdatedCount++; + } + catch (Exception ex) + { + response.FailedCount++; + response.Errors.Add($"خطا در به‌روزرسانی محصول {product.Id}: {ex.Message}"); + _logger.LogError(ex, "Error toggling product {ProductId} status", product.Id); + } + } + + if (response.UpdatedCount > 0) + { + await _context.SaveChangesAsync(cancellationToken); + _logger.LogInformation( + "Toggle product status completed: {UpdatedCount} succeeded, {FailedCount} failed (Enable: {Enable})", + response.UpdatedCount, response.FailedCount, request.Enable); + } + + return response; + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommandValidator.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommandValidator.cs new file mode 100644 index 0000000..22f6c2b --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/ToggleProductStatus/ToggleProductStatusCommandValidator.cs @@ -0,0 +1,16 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.ToggleProductStatus; + +public class ToggleProductStatusCommandValidator : AbstractValidator +{ + public ToggleProductStatusCommandValidator() + { + RuleFor(x => x.ProductIds) + .NotEmpty().WithMessage("لیست محصولات نمی‌تواند خالی باشد") + .Must(x => x.Count <= 100).WithMessage("حداکثر 100 محصول در هر بار قابل به‌روزرسانی است"); + + RuleFor(x => x.DefaultStock) + .GreaterThanOrEqualTo(0) + .When(x => x.Enable) + .WithMessage("موجودی پیش‌فرض نمی‌تواند منفی باشد"); + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommand.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommand.cs new file mode 100644 index 0000000..69c55e0 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommand.cs @@ -0,0 +1,36 @@ +using MediatR; + +namespace CMSMicroservice.Application.ProductsCQ.Commands.UpdateProductBulk; + +/// +/// دستور به‌روزرسانی گروهی محصولات +/// Admin می‌تواند چندین محصول را همزمان ویرایش کند +/// +public class UpdateProductBulkCommand : IRequest +{ + /// + /// لیست شناسه محصولات برای به‌روزرسانی + /// + public List ProductIds { get; set; } = new(); + + /// + /// قیمت جدید (اختیاری - اگر null باشد تغییر نمی‌کند) + /// + public long? NewPrice { get; set; } + + /// + /// درصد افزایش/کاهش قیمت (اختیاری) + /// مثلاً: 10 = افزایش 10%، -15 = کاهش 15% + /// + public decimal? PriceChangePercent { get; set; } + + /// + /// موجودی (اختیاری) + /// + public int? Stock { get; set; } + + /// + /// افزودن مقدار به موجودی (اختیاری) + /// + public int? StockIncrement { get; set; } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommandHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommandHandler.cs new file mode 100644 index 0000000..f5539fd --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommandHandler.cs @@ -0,0 +1,92 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ProductsCQ.Commands.UpdateProductBulk; + +public class UpdateProductBulkCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public UpdateProductBulkCommandHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(UpdateProductBulkCommand request, CancellationToken cancellationToken) + { + var response = new UpdateProductBulkResponseDto + { + TotalRequested = request.ProductIds.Count + }; + + var products = await _context.Products + .Where(x => request.ProductIds.Contains(x.Id) && !x.IsDeleted) + .ToListAsync(cancellationToken); + + if (products.Count == 0) + { + response.Errors.Add("هیچ محصولی با شناسه‌های داده شده یافت نشد"); + return response; + } + + foreach (var product in products) + { + try + { + // تغییر قیمت + if (request.NewPrice.HasValue) + { + product.Price = request.NewPrice.Value; + } + else if (request.PriceChangePercent.HasValue) + { + var changeAmount = (long)(product.Price * (request.PriceChangePercent.Value / 100)); + product.Price += changeAmount; + + // اطمینان از مثبت بودن قیمت + if (product.Price < 0) + product.Price = 0; + } + + // تغییر موجودی + if (request.Stock.HasValue) + { + product.RemainingCount = request.Stock.Value; + } + else if (request.StockIncrement.HasValue) + { + product.RemainingCount += request.StockIncrement.Value; + + // اطمینان از غیرمنفی بودن موجودی + if (product.RemainingCount < 0) + product.RemainingCount = 0; + } + + response.UpdatedProductIds.Add(product.Id); + response.SuccessCount++; + } + catch (Exception ex) + { + response.Errors.Add($"خطا در به‌روزرسانی محصول {product.Id}: {ex.Message}"); + response.FailedCount++; + _logger.LogError(ex, "Error updating product {ProductId}", product.Id); + } + } + + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Bulk update completed. Success: {Success}, Failed: {Failed}", + response.SuccessCount, + response.FailedCount + ); + + return response; + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommandValidator.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommandValidator.cs new file mode 100644 index 0000000..0186da0 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkCommandValidator.cs @@ -0,0 +1,40 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.ProductsCQ.Commands.UpdateProductBulk; + +public class UpdateProductBulkCommandValidator : AbstractValidator +{ + public UpdateProductBulkCommandValidator() + { + RuleFor(x => x.ProductIds) + .NotEmpty().WithMessage("حداقل یک محصول باید انتخاب شود") + .Must(x => x.Count <= 100).WithMessage("حداکثر 100 محصول را می‌توان همزمان به‌روزرسانی کرد"); + + RuleFor(x => x.NewPrice) + .GreaterThan(0).WithMessage("قیمت باید بزرگتر از صفر باشد") + .LessThanOrEqualTo(1_000_000_000).WithMessage("قیمت نامعتبر است") + .When(x => x.NewPrice.HasValue); + + RuleFor(x => x.PriceChangePercent) + .GreaterThanOrEqualTo(-100).WithMessage("درصد تخفیف نمی‌تواند بیشتر از 100% باشد") + .LessThanOrEqualTo(1000).WithMessage("درصد افزایش نامعتبر است") + .When(x => x.PriceChangePercent.HasValue); + + RuleFor(x => x.Stock) + .GreaterThanOrEqualTo(0).WithMessage("موجودی نمی‌تواند منفی باشد") + .When(x => x.Stock.HasValue); + + RuleFor(x => x) + .Must(x => x.NewPrice.HasValue || x.PriceChangePercent.HasValue || + x.Stock.HasValue || x.StockIncrement.HasValue) + .WithMessage("حداقل یک فیلد برای به‌روزرسانی باید مشخص شود"); + + RuleFor(x => x) + .Must(x => !(x.NewPrice.HasValue && x.PriceChangePercent.HasValue)) + .WithMessage("نمی‌توان همزمان قیمت جدید و درصد تغییر قیمت را مشخص کرد"); + + RuleFor(x => x) + .Must(x => !(x.Stock.HasValue && x.StockIncrement.HasValue)) + .WithMessage("نمی‌توان همزمان موجودی جدید و افزایش موجودی را مشخص کرد"); + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkResponseDto.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkResponseDto.cs new file mode 100644 index 0000000..73c5bed --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProductBulk/UpdateProductBulkResponseDto.cs @@ -0,0 +1,10 @@ +namespace CMSMicroservice.Application.ProductsCQ.Commands.UpdateProductBulk; + +public class UpdateProductBulkResponseDto +{ + public int TotalRequested { get; set; } + public int SuccessCount { get; set; } + public int FailedCount { get; set; } + public List UpdatedProductIds { get; set; } = new(); + public List Errors { get; set; } = new(); +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandHandler.cs index 5883a7a..ddac8ee 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandHandler.cs @@ -15,12 +15,12 @@ public class UpdateProductsCommandHandler : IRequestHandler Handle(UpdateProductsCommand request, CancellationToken cancellationToken) { - var entity = await _context.Productss + var entity = await _context.Products .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) - ?? throw new NotFoundException(nameof(Products), request.Id); + ?? throw new NotFoundException(nameof(Product), request.Id); request.Adapt(entity); - _context.Productss.Update(entity); + _context.Products.Update(entity); // به‌روزرسانی دسته‌بندی‌های محصول در صورت ارسال CategoryIds if (request.CategoryIds is not null) @@ -30,7 +30,7 @@ public class UpdateProductsCommandHandler : IRequestHandler x.ProductId == entity.Id) .ToListAsync(cancellationToken); @@ -43,17 +43,17 @@ public class UpdateProductsCommandHandler : IRequestHandler 0) { - _context.PruductCategorys.RemoveRange(toRemove); + _context.ProductCategories.RemoveRange(toRemove); } } diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetAllProductsByFilter/GetAllProductsByFilterQueryHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetAllProductsByFilter/GetAllProductsByFilterQueryHandler.cs index e95e137..e45a7fb 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetAllProductsByFilter/GetAllProductsByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetAllProductsByFilter/GetAllProductsByFilterQueryHandler.cs @@ -10,7 +10,7 @@ public class GetAllProductsByFilterQueryHandler : IRequestHandler Handle(GetAllProductsByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.Productss + var query = _context.Products .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); @@ -25,7 +25,7 @@ public class GetAllProductsByFilterQueryHandler : IRequestHandler request.Filter.Price == null || x.Price == request.Filter.Price) .Where(x => request.Filter.Discount == null || x.Discount == request.Filter.Discount) .Where(x => request.Filter.Rate == null || x.Rate == request.Filter.Rate) - .Where(x => request.Filter.CategoryId == null || x.PruductCategorys.Any(pc => pc.CategoryId == request.Filter.CategoryId)) + .Where(x => request.Filter.CategoryId == null || x.ProductCategories.Any(pc => pc.CategoryId == request.Filter.CategoryId)) .Where(x => request.Filter.ImagePath == null || x.ImagePath.Contains(request.Filter.ImagePath)) .Where(x => request.Filter.ThumbnailPath == null || x.ThumbnailPath.Contains(request.Filter.ThumbnailPath)) .Where(x => request.Filter.SaleCount == null || x.SaleCount == request.Filter.SaleCount) @@ -52,7 +52,7 @@ public class GetAllProductsByFilterQueryHandler : IRequestHandler pc.CategoryId) .ToList() }) diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQuery.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQuery.cs new file mode 100644 index 0000000..1b3a08e --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQuery.cs @@ -0,0 +1,54 @@ +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetLowStockProducts; + +/// +/// دریافت محصولات کم موجودی +/// +public record GetLowStockProductsQuery : IRequest +{ + /// + /// آستانه موجودی (پیش‌فرض: 10) + /// + public int Threshold { get; init; } = 10; + + /// + /// شماره صفحه (پیش‌فرض: 1) + /// + public int PageIndex { get; init; } = 1; + + /// + /// تعداد در هر صفحه (پیش‌فرض: 20) + /// + public int PageSize { get; init; } = 20; + + /// + /// فقط محصولات انحصاری باشگاه (اختیاری) + /// + public bool? IsClubExclusive { get; init; } +} + +/// +/// پاسخ لیست محصولات کم موجودی +/// +public class GetLowStockProductsResponseDto +{ + public MetaData MetaData { get; set; } = new(); + public List Products { get; set; } = new(); +} + +/// +/// اطلاعات محصول کم موجودی +/// +public class LowStockProductDto +{ + public long Id { get; set; } + public string Title { get; set; } = string.Empty; + public long Price { get; set; } + public int Discount { get; set; } + public int RemainingCount { get; set; } + public int SaleCount { get; set; } + public bool IsClubExclusive { get; set; } + public string ImagePath { get; set; } = string.Empty; + public string ThumbnailPath { get; set; } = string.Empty; + public DateTime Created { get; set; } + public DateTime? LastModified { get; set; } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQueryHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQueryHandler.cs new file mode 100644 index 0000000..8d768ff --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQueryHandler.cs @@ -0,0 +1,70 @@ +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetLowStockProducts; + +public class GetLowStockProductsQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetLowStockProductsQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(GetLowStockProductsQuery request, CancellationToken cancellationToken) + { + // Query اصلی: محصولاتی که موجودی کمتر یا مساوی آستانه دارند + var query = _context.Products + .Where(p => p.RemainingCount <= request.Threshold); + + // فیلتر محصولات انحصاری باشگاه (اگر مشخص شده باشد) + if (request.IsClubExclusive.HasValue) + { + query = query.Where(p => p.IsClubExclusive == request.IsClubExclusive.Value); + } + + // مرتب‌سازی بر اساس موجودی (کمترین موجودی اول) + query = query.OrderBy(p => p.RemainingCount) + .ThenByDescending(p => p.SaleCount); // محصولات پرفروش اولویت بیشتری دارند + + // شمارش کل + var totalCount = await query.CountAsync(cancellationToken); + + // Pagination + var products = await query + .Skip((request.PageIndex - 1) * request.PageSize) + .Take(request.PageSize) + .Select(p => new LowStockProductDto + { + Id = p.Id, + Title = p.Title, + Price = p.Price, + Discount = p.Discount, + RemainingCount = p.RemainingCount, + SaleCount = p.SaleCount, + IsClubExclusive = p.IsClubExclusive, + ImagePath = p.ImagePath, + ThumbnailPath = p.ThumbnailPath, + Created = p.Created, + LastModified = p.LastModified + }) + .ToListAsync(cancellationToken); + + _logger.LogInformation( + "Found {Count} low stock products (threshold: {Threshold}, page: {Page})", + totalCount, request.Threshold, request.PageIndex); + + return new GetLowStockProductsResponseDto + { + MetaData = new MetaData + { + CurrentPage = request.PageIndex, + PageSize = request.PageSize, + TotalCount = totalCount + }, + Products = products + }; + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQueryValidator.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQueryValidator.cs new file mode 100644 index 0000000..d1e3b12 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetLowStockProducts/GetLowStockProductsQueryValidator.cs @@ -0,0 +1,16 @@ +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetLowStockProducts; + +public class GetLowStockProductsQueryValidator : AbstractValidator +{ + public GetLowStockProductsQueryValidator() + { + RuleFor(x => x.Threshold) + .GreaterThanOrEqualTo(0).WithMessage("آستانه موجودی نمی‌تواند منفی باشد"); + + RuleFor(x => x.PageIndex) + .GreaterThan(0).WithMessage("شماره صفحه باید بزرگتر از 0 باشد"); + + RuleFor(x => x.PageSize) + .InclusiveBetween(1, 100).WithMessage("تعداد در هر صفحه باید بین 1 تا 100 باشد"); + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs index 542d0b6..c936a0e 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProducts/GetProductsQueryHandler.cs @@ -11,7 +11,7 @@ public class GetProductsQueryHandler : IRequestHandler Handle(GetProductsQuery request, CancellationToken cancellationToken) { - var response = await _context.Productss + var response = await _context.Products .AsNoTracking() .Where(x => x.Id == request.Id) .Select(x => new GetProductsResponseDto @@ -29,12 +29,12 @@ public class GetProductsQueryHandler : IRequestHandler pc.CategoryId) .ToList() }) .FirstOrDefaultAsync(cancellationToken); - return response ?? throw new NotFoundException(nameof(Products), request.Id); + return response ?? throw new NotFoundException(nameof(Product), request.Id); } } diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryQuery.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryQuery.cs new file mode 100644 index 0000000..7e14827 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryQuery.cs @@ -0,0 +1,16 @@ +using CMSMicroservice.Application.Common.Models; +using MediatR; + +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByCategory; + +/// +/// کوئری دریافت محصولات بر اساس دسته‌بندی +/// +public class GetProductsByCategoryQuery : IRequest +{ + public long CategoryId { get; set; } + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 20; + public bool OnlyActive { get; set; } = true; + public bool OnlyInStock { get; set; } = false; +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryQueryHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryQueryHandler.cs new file mode 100644 index 0000000..35744ab --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryQueryHandler.cs @@ -0,0 +1,74 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByCategory; + +public class GetProductsByCategoryQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetProductsByCategoryQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(GetProductsByCategoryQuery request, CancellationToken cancellationToken) + { + var query = _context.Products + .Where(x => !x.IsDeleted) + .Where(x => x.ProductCategories.Any(pc => pc.CategoryId == request.CategoryId && !pc.IsDeleted)); + + if (request.OnlyInStock) + { + query = query.Where(x => x.RemainingCount > 0); + } + + var totalCount = await query.CountAsync(cancellationToken); + + var products = await query + .OrderByDescending(x => x.Created) + .Skip((request.PageNumber - 1) * request.PageSize) + .Take(request.PageSize) + .Select(x => new ProductListDto + { + Id = x.Id, + Name = x.Title, + Description = x.Description, + Price = x.Price, + Stock = x.RemainingCount, + IsActive = !x.IsDeleted, + ImageUrl = x.ImagePath, + Created = x.Created + }) + .ToListAsync(cancellationToken); + + var metaData = new MetaData + { + TotalCount = totalCount, + PageSize = request.PageSize, + CurrentPage = request.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasNext = request.PageNumber < (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasPrevious = request.PageNumber > 1 + }; + + _logger.LogInformation( + "Retrieved {Count} products for category {CategoryId}", + products.Count, + request.CategoryId + ); + + return new GetProductsByCategoryResponseDto + { + MetaData = metaData, + Products = products + }; + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryResponseDto.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryResponseDto.cs new file mode 100644 index 0000000..d346fda --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByCategory/GetProductsByCategoryResponseDto.cs @@ -0,0 +1,21 @@ +using CMSMicroservice.Application.Common.Models; + +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByCategory; + +public class GetProductsByCategoryResponseDto +{ + public MetaData MetaData { get; set; } = new(); + public List Products { get; set; } = new(); +} + +public class ProductListDto +{ + public long Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public long Price { get; set; } + public int Stock { get; set; } + public bool IsActive { get; set; } + public string? ImageUrl { get; set; } + public DateTime Created { get; set; } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagQuery.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagQuery.cs new file mode 100644 index 0000000..50368db --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagQuery.cs @@ -0,0 +1,16 @@ +using CMSMicroservice.Application.Common.Models; +using MediatR; + +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByTag; + +/// +/// کوئری دریافت محصولات بر اساس تگ +/// +public class GetProductsByTagQuery : IRequest +{ + public long TagId { get; set; } + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 20; + public bool OnlyActive { get; set; } = true; + public bool OnlyInStock { get; set; } = false; +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagQueryHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagQueryHandler.cs new file mode 100644 index 0000000..acda699 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagQueryHandler.cs @@ -0,0 +1,75 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByCategory; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByTag; + +public class GetProductsByTagQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetProductsByTagQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(GetProductsByTagQuery request, CancellationToken cancellationToken) + { + var query = _context.Products + .Where(x => !x.IsDeleted) + .Where(x => x.ProductTags.Any(pt => pt.TagId == request.TagId && !pt.IsDeleted)); + + if (request.OnlyInStock) + { + query = query.Where(x => x.RemainingCount > 0); + } + + var totalCount = await query.CountAsync(cancellationToken); + + var products = await query + .OrderByDescending(x => x.Created) + .Skip((request.PageNumber - 1) * request.PageSize) + .Take(request.PageSize) + .Select(x => new ProductListDto + { + Id = x.Id, + Name = x.Title, + Description = x.Description, + Price = x.Price, + Stock = x.RemainingCount, + IsActive = !x.IsDeleted, + ImageUrl = x.ImagePath, + Created = x.Created + }) + .ToListAsync(cancellationToken); + + var metaData = new MetaData + { + TotalCount = totalCount, + PageSize = request.PageSize, + CurrentPage = request.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasNext = request.PageNumber < (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasPrevious = request.PageNumber > 1 + }; + + _logger.LogInformation( + "Retrieved {Count} products for tag {TagId}", + products.Count, + request.TagId + ); + + return new GetProductsByTagResponseDto + { + MetaData = metaData, + Products = products + }; + } +} diff --git a/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagResponseDto.cs b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagResponseDto.cs new file mode 100644 index 0000000..c2f7633 --- /dev/null +++ b/src/CMSMicroservice.Application/ProductsCQ/Queries/GetProductsByTag/GetProductsByTagResponseDto.cs @@ -0,0 +1,10 @@ +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByCategory; + +namespace CMSMicroservice.Application.ProductsCQ.Queries.GetProductsByTag; + +public class GetProductsByTagResponseDto +{ + public MetaData MetaData { get; set; } = new(); + public List Products { get; set; } = new(); +} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommand.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommand.cs deleted file mode 100644 index 30f9c8b..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommand.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.CreateNewPruductCategory; -public record CreateNewPruductCategoryCommand : IRequest -{ - //شناسه محصول - public long ProductId { get; init; } - //شناسه دسته بندی - public long CategoryId { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommandHandler.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommandHandler.cs deleted file mode 100644 index fea7cca..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryCommandHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.CreateNewPruductCategory; -public class CreateNewPruductCategoryCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public CreateNewPruductCategoryCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(CreateNewPruductCategoryCommand request, - CancellationToken cancellationToken) - { - var entity = request.Adapt(); - await _context.PruductCategorys.AddAsync(entity, cancellationToken); - entity.AddDomainEvent(new CreateNewPruductCategoryEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return entity.Adapt(); - } -} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryResponseDto.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryResponseDto.cs deleted file mode 100644 index 3ae52b0..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/CreateNewPruductCategory/CreateNewPruductCategoryResponseDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.CreateNewPruductCategory; -public class CreateNewPruductCategoryResponseDto -{ - //شناسه - public long Id { get; set; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommand.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommand.cs deleted file mode 100644 index b1446e0..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommand.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.DeletePruductCategory; -public record DeletePruductCategoryCommand : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommandHandler.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommandHandler.cs deleted file mode 100644 index e93487a..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/DeletePruductCategory/DeletePruductCategoryCommandHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.DeletePruductCategory; -public class DeletePruductCategoryCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public DeletePruductCategoryCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(DeletePruductCategoryCommand request, CancellationToken cancellationToken) - { - var entity = await _context.PruductCategorys - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(PruductCategory), request.Id); - entity.IsDeleted = true; - _context.PruductCategorys.Update(entity); - entity.AddDomainEvent(new DeletePruductCategoryEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return Unit.Value; - } -} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommandHandler.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommandHandler.cs deleted file mode 100644 index f6ae54a..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Commands/UpdatePruductCategory/UpdatePruductCategoryCommandHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.PruductCategoryCQ.Commands.UpdatePruductCategory; -public class UpdatePruductCategoryCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public UpdatePruductCategoryCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(UpdatePruductCategoryCommand request, CancellationToken cancellationToken) - { - var entity = await _context.PruductCategorys - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(PruductCategory), request.Id); - request.Adapt(entity); - _context.PruductCategorys.Update(entity); - entity.AddDomainEvent(new UpdatePruductCategoryEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return Unit.Value; - } -} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/CreateNewPruductCategoryEventHandlers/CreateNewPruductCategoryEventHandler.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/CreateNewPruductCategoryEventHandlers/CreateNewPruductCategoryEventHandler.cs deleted file mode 100644 index 9fa2fd5..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/EventHandlers/CreateNewPruductCategoryEventHandlers/CreateNewPruductCategoryEventHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.PruductCategoryCQ.EventHandlers; - -public class CreateNewPruductCategoryEventHandler : INotificationHandler -{ - private readonly ILogger< - CreateNewPruductCategoryEventHandler> _logger; - - public CreateNewPruductCategoryEventHandler(ILogger logger) - { - _logger = logger; - } - - public Task Handle(CreateNewPruductCategoryEvent notification, CancellationToken cancellationToken) - { - _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); - - return Task.CompletedTask; - } -} diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQuery.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQuery.cs deleted file mode 100644 index fef2914..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQuery.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetPruductCategory; -public record GetPruductCategoryQuery : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQueryHandler.cs b/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQueryHandler.cs deleted file mode 100644 index d36c484..0000000 --- a/src/CMSMicroservice.Application/PruductCategoryCQ/Queries/GetPruductCategory/GetPruductCategoryQueryHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace CMSMicroservice.Application.PruductCategoryCQ.Queries.GetPruductCategory; -public class GetPruductCategoryQueryHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public GetPruductCategoryQueryHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(GetPruductCategoryQuery request, - CancellationToken cancellationToken) - { - var response = await _context.PruductCategorys - .AsNoTracking() - .Where(x => x.Id == request.Id) - .ProjectToType() - .FirstOrDefaultAsync(cancellationToken); - - return response ?? throw new NotFoundException(nameof(PruductCategory), request.Id); - } -} diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommandHandler.cs b/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommandHandler.cs deleted file mode 100644 index 5773d52..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagCommandHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.PruductTagCQ.Commands.CreateNewPruductTag; -public class CreateNewPruductTagCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public CreateNewPruductTagCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(CreateNewPruductTagCommand request, - CancellationToken cancellationToken) - { - var entity = request.Adapt(); - await _context.PruductTags.AddAsync(entity, cancellationToken); - entity.AddDomainEvent(new CreateNewPruductTagEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return entity.Adapt(); - } -} - diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagResponseDto.cs b/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagResponseDto.cs deleted file mode 100644 index bd44e80..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/CreateNewPruductTag/CreateNewPruductTagResponseDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Commands.CreateNewPruductTag; -public class CreateNewPruductTagResponseDto -{ - //شناسه - public long Id { get; set; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommand.cs b/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommand.cs deleted file mode 100644 index 5783b3d..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommand.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Commands.DeletePruductTag; -public record DeletePruductTagCommand : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommandHandler.cs b/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommandHandler.cs deleted file mode 100644 index 0a1028b..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/DeletePruductTag/DeletePruductTagCommandHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.PruductTagCQ.Commands.DeletePruductTag; -public class DeletePruductTagCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public DeletePruductTagCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(DeletePruductTagCommand request, CancellationToken cancellationToken) - { - var entity = await _context.PruductTags - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(PruductTag), request.Id); - entity.IsDeleted = true; - _context.PruductTags.Update(entity); - entity.AddDomainEvent(new DeletePruductTagEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return Unit.Value; - } -} - diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommandHandler.cs b/src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommandHandler.cs deleted file mode 100644 index 2ca6a6d..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/Commands/UpdatePruductTag/UpdatePruductTagCommandHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.PruductTagCQ.Commands.UpdatePruductTag; -public class UpdatePruductTagCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public UpdatePruductTagCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(UpdatePruductTagCommand request, CancellationToken cancellationToken) - { - var entity = await _context.PruductTags - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(PruductTag), request.Id); - request.Adapt(entity); - _context.PruductTags.Update(entity); - entity.AddDomainEvent(new UpdatePruductTagEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return Unit.Value; - } -} - diff --git a/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/CreateNewPruductTagEventHandlers/CreateNewPruductTagEventHandler.cs b/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/CreateNewPruductTagEventHandlers/CreateNewPruductTagEventHandler.cs deleted file mode 100644 index 8eb2e0f..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/CreateNewPruductTagEventHandlers/CreateNewPruductTagEventHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.PruductTagCQ.EventHandlers; - -public class CreateNewPruductTagEventHandler : INotificationHandler -{ - private readonly ILogger _logger; - - public CreateNewPruductTagEventHandler(ILogger logger) - { - _logger = logger; - } - - public Task Handle(CreateNewPruductTagEvent notification, CancellationToken cancellationToken) - { - _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); - - return Task.CompletedTask; - } -} - diff --git a/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/DeletePruductTagEventHandlers/DeletePruductTagEventHandler.cs b/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/DeletePruductTagEventHandlers/DeletePruductTagEventHandler.cs deleted file mode 100644 index 5093f96..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/DeletePruductTagEventHandlers/DeletePruductTagEventHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.PruductTagCQ.EventHandlers; - -public class DeletePruductTagEventHandler : INotificationHandler -{ - private readonly ILogger _logger; - - public DeletePruductTagEventHandler(ILogger logger) - { - _logger = logger; - } - - public Task Handle(DeletePruductTagEvent notification, CancellationToken cancellationToken) - { - _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); - - return Task.CompletedTask; - } -} - diff --git a/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/UpdatePruductTagEventHandlers/UpdatePruductTagEventHandler.cs b/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/UpdatePruductTagEventHandlers/UpdatePruductTagEventHandler.cs deleted file mode 100644 index 7971901..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/EventHandlers/UpdatePruductTagEventHandlers/UpdatePruductTagEventHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.PruductTagCQ.EventHandlers; - -public class UpdatePruductTagEventHandler : INotificationHandler -{ - private readonly ILogger _logger; - - public UpdatePruductTagEventHandler(ILogger logger) - { - _logger = logger; - } - - public Task Handle(UpdatePruductTagEvent notification, CancellationToken cancellationToken) - { - _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); - - return Task.CompletedTask; - } -} - diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQuery.cs b/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQuery.cs deleted file mode 100644 index 0036486..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQuery.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetPruductTag; -public record GetPruductTagQuery : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQueryHandler.cs b/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQueryHandler.cs deleted file mode 100644 index aaa15f1..0000000 --- a/src/CMSMicroservice.Application/PruductTagCQ/Queries/GetPruductTag/GetPruductTagQueryHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace CMSMicroservice.Application.PruductTagCQ.Queries.GetPruductTag; -public class GetPruductTagQueryHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public GetPruductTagQueryHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(GetPruductTagQuery request, - CancellationToken cancellationToken) - { - var response = await _context.PruductTags - .AsNoTracking() - .Where(x => x.Id == request.Id) - .ProjectToType() - .FirstOrDefaultAsync(cancellationToken); - - return response ?? throw new NotFoundException(nameof(PruductTag), request.Id); - } -} - diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommand.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommand.cs new file mode 100644 index 0000000..e75a941 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommand.cs @@ -0,0 +1,51 @@ +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.CreatePublicMessage; + +/// +/// دستور ایجاد پیام عمومی +/// Admin می‌تواند پیام عمومی برای نمایش در داشبورد کاربران ایجاد کند +/// +public class CreatePublicMessageCommand : IRequest +{ + /// + /// عنوان پیام (حداکثر 200 کاراکتر) + /// + public string Title { get; set; } = string.Empty; + + /// + /// محتوای پیام (حداکثر 2000 کاراکتر) + /// + public string Content { get; set; } = string.Empty; + + /// + /// نوع پیام + /// + public MessageType Type { get; set; } + + /// + /// اولویت پیام + /// + public MessagePriority Priority { get; set; } + + /// + /// تاریخ شروع نمایش + /// + public DateTime StartsAt { get; set; } + + /// + /// تاریخ پایان نمایش + /// + public DateTime ExpiresAt { get; set; } + + /// + /// لینک اختیاری + /// + public string? LinkUrl { get; set; } + + /// + /// متن دکمه لینک + /// + public string? LinkText { get; set; } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommandHandler.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommandHandler.cs new file mode 100644 index 0000000..56a4157 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommandHandler.cs @@ -0,0 +1,67 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities.Message; +using MediatR; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.CreatePublicMessage; + +public class CreatePublicMessageCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public CreatePublicMessageCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle(CreatePublicMessageCommand request, CancellationToken cancellationToken) + { + // 1. بررسی Admin + var currentUserId = _currentUser.UserId; + if (string.IsNullOrEmpty(currentUserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + if (!long.TryParse(currentUserId, out var createdByUserId)) + { + throw new UnauthorizedAccessException("شناسه کاربر نامعتبر است"); + } + + // 2. ایجاد PublicMessage + var message = new PublicMessage + { + Title = request.Title.Trim(), + Content = request.Content.Trim(), + Type = request.Type, + Priority = request.Priority, + IsActive = true, + StartsAt = request.StartsAt, + ExpiresAt = request.ExpiresAt, + CreatedByUserId = createdByUserId, + ViewCount = 0, + LinkUrl = request.LinkUrl?.Trim(), + LinkText = request.LinkText?.Trim() + }; + + _context.PublicMessages.Add(message); + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Public message created successfully. Id: {Id}, Title: {Title}, Type: {Type}, CreatedBy: {CreatedBy}", + message.Id, + message.Title, + message.Type, + createdByUserId + ); + + return message.Id; + } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommandValidator.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommandValidator.cs new file mode 100644 index 0000000..0183a9b --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/CreatePublicMessage/CreatePublicMessageCommandValidator.cs @@ -0,0 +1,39 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.CreatePublicMessage; + +public class CreatePublicMessageCommandValidator : AbstractValidator +{ + public CreatePublicMessageCommandValidator() + { + RuleFor(x => x.Title) + .NotEmpty().WithMessage("عنوان پیام الزامی است") + .MaximumLength(200).WithMessage("عنوان نمی‌تواند بیشتر از 200 کاراکتر باشد"); + + RuleFor(x => x.Content) + .NotEmpty().WithMessage("محتوای پیام الزامی است") + .MaximumLength(2000).WithMessage("محتوا نمی‌تواند بیشتر از 2000 کاراکتر باشد"); + + RuleFor(x => x.Type) + .IsInEnum().WithMessage("نوع پیام نامعتبر است"); + + RuleFor(x => x.Priority) + .IsInEnum().WithMessage("اولویت پیام نامعتبر است"); + + RuleFor(x => x.StartsAt) + .NotEmpty().WithMessage("تاریخ شروع الزامی است") + .LessThan(x => x.ExpiresAt).WithMessage("تاریخ شروع باید قبل از تاریخ پایان باشد"); + + RuleFor(x => x.ExpiresAt) + .NotEmpty().WithMessage("تاریخ پایان الزامی است") + .GreaterThan(DateTime.UtcNow).WithMessage("تاریخ پایان باید در آینده باشد"); + + RuleFor(x => x.LinkUrl) + .MaximumLength(500).WithMessage("لینک نمی‌تواند بیشتر از 500 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.LinkUrl)); + + RuleFor(x => x.LinkText) + .MaximumLength(100).WithMessage("متن لینک نمی‌تواند بیشتر از 100 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.LinkText)); + } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/DeletePublicMessage/DeletePublicMessageCommand.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/DeletePublicMessage/DeletePublicMessageCommand.cs new file mode 100644 index 0000000..bc0b7ff --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/DeletePublicMessage/DeletePublicMessageCommand.cs @@ -0,0 +1,15 @@ +using MediatR; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.DeletePublicMessage; + +/// +/// دستور حذف (soft delete) پیام عمومی +/// Admin می‌تواند پیام را حذف کند +/// +public class DeletePublicMessageCommand : IRequest +{ + /// + /// شناسه پیام + /// + public long Id { get; set; } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/DeletePublicMessage/DeletePublicMessageCommandHandler.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/DeletePublicMessage/DeletePublicMessageCommandHandler.cs new file mode 100644 index 0000000..9d436a5 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/DeletePublicMessage/DeletePublicMessageCommandHandler.cs @@ -0,0 +1,60 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.DeletePublicMessage; + +public class DeletePublicMessageCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public DeletePublicMessageCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle(DeletePublicMessageCommand request, CancellationToken cancellationToken) + { + // 1. بررسی Admin + var currentUserId = _currentUser.UserId; + if (string.IsNullOrEmpty(currentUserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + if (!long.TryParse(currentUserId, out var userId)) + { + throw new UnauthorizedAccessException("شناسه کاربر نامعتبر است"); + } + + // 2. بررسی وجود پیام + var message = await _context.PublicMessages + .FirstOrDefaultAsync(x => x.Id == request.Id && !x.IsDeleted, cancellationToken); + + if (message == null) + { + throw new KeyNotFoundException($"پیام با شناسه {request.Id} یافت نشد"); + } + + // 3. Soft Delete + message.IsDeleted = true; + + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Public message deleted successfully. Id: {Id}, DeletedBy: {DeletedBy}", + message.Id, + userId + ); + + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommand.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommand.cs new file mode 100644 index 0000000..29d4283 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommand.cs @@ -0,0 +1,61 @@ +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.UpdatePublicMessage; + +/// +/// دستور ویرایش پیام عمومی +/// Admin می‌تواند پیام‌های منقضی نشده را ویرایش کند +/// +public class UpdatePublicMessageCommand : IRequest +{ + /// + /// شناسه پیام + /// + public long Id { get; set; } + + /// + /// عنوان پیام (حداکثر 200 کاراکتر) + /// + public string Title { get; set; } = string.Empty; + + /// + /// محتوای پیام (حداکثر 2000 کاراکتر) + /// + public string Content { get; set; } = string.Empty; + + /// + /// نوع پیام + /// + public MessageType Type { get; set; } + + /// + /// اولویت پیام + /// + public MessagePriority Priority { get; set; } + + /// + /// وضعیت فعال/غیرفعال + /// + public bool IsActive { get; set; } + + /// + /// تاریخ شروع نمایش + /// + public DateTime StartsAt { get; set; } + + /// + /// تاریخ پایان نمایش + /// + public DateTime ExpiresAt { get; set; } + + /// + /// لینک اختیاری + /// + public string? LinkUrl { get; set; } + + /// + /// متن دکمه لینک + /// + public string? LinkText { get; set; } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommandHandler.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommandHandler.cs new file mode 100644 index 0000000..fca9121 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommandHandler.cs @@ -0,0 +1,68 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.UpdatePublicMessage; + +public class UpdatePublicMessageCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ICurrentUserService _currentUser; + private readonly ILogger _logger; + + public UpdatePublicMessageCommandHandler( + IApplicationDbContext context, + ICurrentUserService currentUser, + ILogger logger) + { + _context = context; + _currentUser = currentUser; + _logger = logger; + } + + public async Task Handle(UpdatePublicMessageCommand request, CancellationToken cancellationToken) + { + // 1. بررسی Admin + var currentUserId = _currentUser.UserId; + if (string.IsNullOrEmpty(currentUserId)) + { + throw new UnauthorizedAccessException("کاربر احراز هویت نشده است"); + } + + if (!long.TryParse(currentUserId, out var userId)) + { + throw new UnauthorizedAccessException("شناسه کاربر نامعتبر است"); + } + + // 2. بررسی وجود پیام + var message = await _context.PublicMessages + .FirstOrDefaultAsync(x => x.Id == request.Id && !x.IsDeleted, cancellationToken); + + if (message == null) + { + throw new KeyNotFoundException($"پیام با شناسه {request.Id} یافت نشد"); + } + + // 3. به‌روزرسانی پیام + message.Title = request.Title.Trim(); + message.Content = request.Content.Trim(); + message.Type = request.Type; + message.Priority = request.Priority; + message.IsActive = request.IsActive; + message.StartsAt = request.StartsAt; + message.ExpiresAt = request.ExpiresAt; + message.LinkUrl = request.LinkUrl?.Trim(); + message.LinkText = request.LinkText?.Trim(); + + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "Public message updated successfully. Id: {Id}, UpdatedBy: {UpdatedBy}", + message.Id, + userId + ); + + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommandValidator.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommandValidator.cs new file mode 100644 index 0000000..52cb780 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Commands/UpdatePublicMessage/UpdatePublicMessageCommandValidator.cs @@ -0,0 +1,41 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.PublicMessageCQ.Commands.UpdatePublicMessage; + +public class UpdatePublicMessageCommandValidator : AbstractValidator +{ + public UpdatePublicMessageCommandValidator() + { + RuleFor(x => x.Id) + .GreaterThan(0).WithMessage("شناسه پیام نامعتبر است"); + + RuleFor(x => x.Title) + .NotEmpty().WithMessage("عنوان پیام الزامی است") + .MaximumLength(200).WithMessage("عنوان نمی‌تواند بیشتر از 200 کاراکتر باشد"); + + RuleFor(x => x.Content) + .NotEmpty().WithMessage("محتوای پیام الزامی است") + .MaximumLength(2000).WithMessage("محتوا نمی‌تواند بیشتر از 2000 کاراکتر باشد"); + + RuleFor(x => x.Type) + .IsInEnum().WithMessage("نوع پیام نامعتبر است"); + + RuleFor(x => x.Priority) + .IsInEnum().WithMessage("اولویت پیام نامعتبر است"); + + RuleFor(x => x.StartsAt) + .NotEmpty().WithMessage("تاریخ شروع الزامی است") + .LessThan(x => x.ExpiresAt).WithMessage("تاریخ شروع باید قبل از تاریخ پایان باشد"); + + RuleFor(x => x.ExpiresAt) + .NotEmpty().WithMessage("تاریخ پایان الزامی است"); + + RuleFor(x => x.LinkUrl) + .MaximumLength(500).WithMessage("لینک نمی‌تواند بیشتر از 500 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.LinkUrl)); + + RuleFor(x => x.LinkText) + .MaximumLength(100).WithMessage("متن لینک نمی‌تواند بیشتر از 100 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.LinkText)); + } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/GetActiveMessagesQuery.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/GetActiveMessagesQuery.cs new file mode 100644 index 0000000..8530e8a --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/GetActiveMessagesQuery.cs @@ -0,0 +1,13 @@ +using MediatR; + +namespace CMSMicroservice.Application.PublicMessageCQ.Queries.GetActiveMessages; + +/// +/// کوئری دریافت پیام‌های فعال +/// برای نمایش در داشبورد کاربران +/// +public class GetActiveMessagesQuery : IRequest> +{ + // فیلتر اختیاری: فقط پیام‌های با اولویت خاص + public int? MinPriority { get; set; } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/GetActiveMessagesQueryHandler.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/GetActiveMessagesQueryHandler.cs new file mode 100644 index 0000000..305b73e --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/GetActiveMessagesQueryHandler.cs @@ -0,0 +1,91 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.PublicMessageCQ.Queries.GetActiveMessages; + +public class GetActiveMessagesQueryHandler : IRequestHandler> +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetActiveMessagesQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task> Handle(GetActiveMessagesQuery request, CancellationToken cancellationToken) + { + var now = DateTime.UtcNow; + + var query = _context.PublicMessages + .Where(x => !x.IsDeleted + && x.IsActive + && x.StartsAt <= now + && x.ExpiresAt >= now); + + // فیلتر اختیاری اولویت + if (request.MinPriority.HasValue) + { + query = query.Where(x => (int)x.Priority >= request.MinPriority.Value); + } + + var messages = await query + .OrderByDescending(x => x.Priority) + .ThenByDescending(x => x.Created) + .Select(x => new PublicMessageDto + { + Id = x.Id, + Title = x.Title, + Content = x.Content, + Type = x.Type, + TypeName = GetTypeName(x.Type), + Priority = x.Priority, + PriorityName = GetPriorityName(x.Priority), + StartsAt = x.StartsAt, + ExpiresAt = x.ExpiresAt, + LinkUrl = x.LinkUrl, + LinkText = x.LinkText, + Created = x.Created + }) + .ToListAsync(cancellationToken); + + _logger.LogInformation( + "Retrieved {Count} active messages", + messages.Count + ); + + return messages; + } + + private static string GetTypeName(MessageType type) + { + return type switch + { + MessageType.Announcement => "اطلاعیه", + MessageType.News => "اخبار", + MessageType.Warning => "هشدار", + MessageType.Promotion => "تبلیغات", + MessageType.SystemUpdate => "به‌روزرسانی سیستم", + MessageType.Event => "رویداد", + _ => "نامشخص" + }; + } + + private static string GetPriorityName(MessagePriority priority) + { + return priority switch + { + MessagePriority.Low => "کم", + MessagePriority.Medium => "متوسط", + MessagePriority.High => "بالا", + MessagePriority.Urgent => "فوری", + _ => "نامشخص" + }; + } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/PublicMessageDto.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/PublicMessageDto.cs new file mode 100644 index 0000000..ffe35cd --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetActiveMessages/PublicMessageDto.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Enums; + +namespace CMSMicroservice.Application.PublicMessageCQ.Queries.GetActiveMessages; + +/// +/// DTO پیام عمومی برای نمایش به کاربران +/// +public class PublicMessageDto +{ + public long Id { get; set; } + public string Title { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public MessageType Type { get; set; } + public string TypeName { get; set; } = string.Empty; + public MessagePriority Priority { get; set; } + public string PriorityName { get; set; } = string.Empty; + public DateTime StartsAt { get; set; } + public DateTime ExpiresAt { get; set; } + public string? LinkUrl { get; set; } + public string? LinkText { get; set; } + public DateTime Created { get; set; } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/AdminPublicMessageDto.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/AdminPublicMessageDto.cs new file mode 100644 index 0000000..cd2a9d0 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/AdminPublicMessageDto.cs @@ -0,0 +1,27 @@ +using CMSMicroservice.Domain.Enums; + +namespace CMSMicroservice.Application.PublicMessageCQ.Queries.GetAllMessages; + +/// +/// DTO پیام عمومی برای Admin (با اطلاعات بیشتر) +/// +public class AdminPublicMessageDto +{ + public long Id { get; set; } + public string Title { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public MessageType Type { get; set; } + public string TypeName { get; set; } = string.Empty; + public MessagePriority Priority { get; set; } + public string PriorityName { get; set; } = string.Empty; + public bool IsActive { get; set; } + public DateTime StartsAt { get; set; } + public DateTime ExpiresAt { get; set; } + public long CreatedByUserId { get; set; } + public int ViewCount { get; set; } + public string? LinkUrl { get; set; } + public string? LinkText { get; set; } + public DateTime Created { get; set; } + public DateTime? LastModified { get; set; } + public bool IsExpired { get; set; } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesQuery.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesQuery.cs new file mode 100644 index 0000000..4dbc063 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesQuery.cs @@ -0,0 +1,24 @@ +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.PublicMessageCQ.Queries.GetAllMessages; + +/// +/// کوئری دریافت همه پیام‌ها (Admin) +/// با فیلترها و صفحه‌بندی +/// +public class GetAllMessagesQuery : IRequest +{ + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 10; + + // فیلترها + public bool? IsActive { get; set; } + public MessageType? Type { get; set; } + public MessagePriority? Priority { get; set; } + public DateTime? StartDate { get; set; } + public DateTime? EndDate { get; set; } + public string? SearchTerm { get; set; } + public bool OrderByDescending { get; set; } = true; +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesQueryHandler.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesQueryHandler.cs new file mode 100644 index 0000000..4c64b3a --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesQueryHandler.cs @@ -0,0 +1,146 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.PublicMessageCQ.Queries.GetAllMessages; + +public class GetAllMessagesQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetAllMessagesQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(GetAllMessagesQuery request, CancellationToken cancellationToken) + { + var now = DateTime.UtcNow; + + // Query پایه + var query = _context.PublicMessages + .Where(x => !x.IsDeleted); + + // فیلترها + if (request.IsActive.HasValue) + { + query = query.Where(x => x.IsActive == request.IsActive.Value); + } + + if (request.Type.HasValue) + { + query = query.Where(x => x.Type == request.Type.Value); + } + + if (request.Priority.HasValue) + { + query = query.Where(x => x.Priority == request.Priority.Value); + } + + if (request.StartDate.HasValue) + { + query = query.Where(x => x.Created >= request.StartDate.Value); + } + + if (request.EndDate.HasValue) + { + query = query.Where(x => x.Created <= request.EndDate.Value); + } + + if (!string.IsNullOrEmpty(request.SearchTerm)) + { + var searchTerm = request.SearchTerm.ToLower(); + query = query.Where(x => x.Title.ToLower().Contains(searchTerm) + || x.Content.ToLower().Contains(searchTerm)); + } + + // تعداد کل + var totalCount = await query.CountAsync(cancellationToken); + + // مرتب‌سازی + query = request.OrderByDescending + ? query.OrderByDescending(x => x.Created) + : query.OrderBy(x => x.Created); + + // صفحه‌بندی + var messages = await query + .Skip((request.PageNumber - 1) * request.PageSize) + .Take(request.PageSize) + .Select(x => new AdminPublicMessageDto + { + Id = x.Id, + Title = x.Title, + Content = x.Content, + Type = x.Type, + TypeName = GetTypeName(x.Type), + Priority = x.Priority, + PriorityName = GetPriorityName(x.Priority), + IsActive = x.IsActive, + StartsAt = x.StartsAt, + ExpiresAt = x.ExpiresAt, + CreatedByUserId = x.CreatedByUserId, + ViewCount = x.ViewCount, + LinkUrl = x.LinkUrl, + LinkText = x.LinkText, + Created = x.Created, + LastModified = x.LastModified, + IsExpired = x.ExpiresAt < now + }) + .ToListAsync(cancellationToken); + + var metaData = new MetaData + { + TotalCount = totalCount, + PageSize = request.PageSize, + CurrentPage = request.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasNext = request.PageNumber < (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasPrevious = request.PageNumber > 1 + }; + + _logger.LogInformation( + "Retrieved {Count} messages. Total: {Total}", + messages.Count, + totalCount + ); + + return new GetAllMessagesResponseDto + { + MetaData = metaData, + Messages = messages + }; + } + + private static string GetTypeName(MessageType type) + { + return type switch + { + MessageType.Announcement => "اطلاعیه", + MessageType.News => "اخبار", + MessageType.Warning => "هشدار", + MessageType.Promotion => "تبلیغات", + MessageType.SystemUpdate => "به‌روزرسانی سیستم", + MessageType.Event => "رویداد", + _ => "نامشخص" + }; + } + + private static string GetPriorityName(MessagePriority priority) + { + return priority switch + { + MessagePriority.Low => "کم", + MessagePriority.Medium => "متوسط", + MessagePriority.High => "بالا", + MessagePriority.Urgent => "فوری", + _ => "نامشخص" + }; + } +} diff --git a/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesResponseDto.cs b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesResponseDto.cs new file mode 100644 index 0000000..715e483 --- /dev/null +++ b/src/CMSMicroservice.Application/PublicMessageCQ/Queries/GetAllMessages/GetAllMessagesResponseDto.cs @@ -0,0 +1,13 @@ +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Application.PublicMessageCQ.Queries.GetActiveMessages; + +namespace CMSMicroservice.Application.PublicMessageCQ.Queries.GetAllMessages; + +/// +/// Response DTO برای لیست پیام‌ها با متادیتا +/// +public class GetAllMessagesResponseDto +{ + public MetaData MetaData { get; set; } = new(); + public List Messages { get; set; } = new(); +} diff --git a/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommand.cs b/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommand.cs new file mode 100644 index 0000000..2c67462 --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommand.cs @@ -0,0 +1,10 @@ +namespace CMSMicroservice.Application.TagCQ.Commands.AssignTagToProduct; + +public record AssignTagToProductCommand : IRequest +{ + /// شناسه محصول + public long ProductId { get; init; } + + /// شناسه تگ + public long TagId { get; init; } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommandHandler.cs b/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommandHandler.cs new file mode 100644 index 0000000..6c2a76d --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommandHandler.cs @@ -0,0 +1,57 @@ +using CMSMicroservice.Application.Common.Exceptions; +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.TagCQ.Commands.AssignTagToProduct; + +public class AssignTagToProductCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public AssignTagToProductCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(AssignTagToProductCommand request, CancellationToken cancellationToken) + { + // بررسی وجود محصول + var product = await _context.Products + .FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken); + + if (product == null) + { + throw new NotFoundException(nameof(Product), request.ProductId); + } + + // بررسی وجود تگ + var tag = await _context.Tags + .FirstOrDefaultAsync(t => t.Id == request.TagId, cancellationToken); + + if (tag == null) + { + throw new NotFoundException(nameof(Tag), request.TagId); + } + + // بررسی اینکه قبلاً اختصاص داده نشده باشد + var existingProductTag = await _context.ProductTags + .FirstOrDefaultAsync(pt => pt.ProductId == request.ProductId && pt.TagId == request.TagId, cancellationToken); + + if (existingProductTag != null) + { + throw new BadRequestException("این تگ قبلاً به این محصول اختصاص داده شده است"); + } + + var productTag = new ProductTag + { + ProductId = request.ProductId, + TagId = request.TagId + }; + + _context.ProductTags.Add(productTag); + await _context.SaveChangesAsync(cancellationToken); + + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommandValidator.cs b/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommandValidator.cs new file mode 100644 index 0000000..1b6d9ca --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Commands/AssignTagToProduct/AssignTagToProductCommandValidator.cs @@ -0,0 +1,13 @@ +namespace CMSMicroservice.Application.TagCQ.Commands.AssignTagToProduct; + +public class AssignTagToProductCommandValidator : AbstractValidator +{ + public AssignTagToProductCommandValidator() + { + RuleFor(x => x.ProductId) + .GreaterThan(0).WithMessage("شناسه محصول نامعتبر است"); + + RuleFor(x => x.TagId) + .GreaterThan(0).WithMessage("شناسه تگ نامعتبر است"); + } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommand.cs b/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommand.cs new file mode 100644 index 0000000..cdfe7a4 --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommand.cs @@ -0,0 +1,19 @@ +namespace CMSMicroservice.Application.TagCQ.Commands.CreateTag; + +public record CreateTagCommand : IRequest +{ + /// نام لاتین تگ + public string Name { get; init; } + + /// عنوان فارسی تگ + public string Title { get; init; } + + /// توضیحات + public string? Description { get; init; } + + /// ترتیب نمایش + public int SortOrder { get; init; } + + /// وضعیت فعال/غیرفعال + public bool IsActive { get; init; } = true; +} diff --git a/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommandHandler.cs b/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommandHandler.cs new file mode 100644 index 0000000..40e33de --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommandHandler.cs @@ -0,0 +1,42 @@ +using CMSMicroservice.Application.Common.Exceptions; +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.TagCQ.Commands.CreateTag; + +public class CreateTagCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public CreateTagCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CreateTagCommand request, CancellationToken cancellationToken) + { + // بررسی تکراری نبودن نام + var existingTag = await _context.Tags + .FirstOrDefaultAsync(t => t.Name == request.Name, cancellationToken); + + if (existingTag != null) + { + throw new BadRequestException($"تگ با نام '{request.Name}' قبلاً ثبت شده است"); + } + + var tag = new Tag + { + Name = request.Name, + Title = request.Title, + Description = request.Description, + SortOrder = request.SortOrder, + IsActive = request.IsActive + }; + + _context.Tags.Add(tag); + await _context.SaveChangesAsync(cancellationToken); + + return tag.Id; + } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommandValidator.cs b/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommandValidator.cs new file mode 100644 index 0000000..b84d222 --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Commands/CreateTag/CreateTagCommandValidator.cs @@ -0,0 +1,23 @@ +namespace CMSMicroservice.Application.TagCQ.Commands.CreateTag; + +public class CreateTagCommandValidator : AbstractValidator +{ + public CreateTagCommandValidator() + { + RuleFor(x => x.Name) + .NotEmpty().WithMessage("نام تگ الزامی است") + .MaximumLength(100).WithMessage("نام تگ نباید بیشتر از 100 کاراکتر باشد") + .Matches("^[a-zA-Z0-9_-]+$").WithMessage("نام تگ فقط باید شامل حروف انگلیسی، اعداد، خط تیره و زیرخط باشد"); + + RuleFor(x => x.Title) + .NotEmpty().WithMessage("عنوان تگ الزامی است") + .MaximumLength(200).WithMessage("عنوان تگ نباید بیشتر از 200 کاراکتر باشد"); + + RuleFor(x => x.Description) + .MaximumLength(500).When(x => !string.IsNullOrEmpty(x.Description)) + .WithMessage("توضیحات نباید بیشتر از 500 کاراکتر باشد"); + + RuleFor(x => x.SortOrder) + .GreaterThanOrEqualTo(0).WithMessage("ترتیب نمایش نمی‌تواند منفی باشد"); + } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsQuery.cs b/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsQuery.cs new file mode 100644 index 0000000..910ca52 --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsQuery.cs @@ -0,0 +1,16 @@ +using CMSMicroservice.Application.Common.Models; +using MediatR; + +namespace CMSMicroservice.Application.TagCQ.Queries.GetAllTags; + +/// +/// کوئری دریافت همه تگ‌ها با فیلتر و صفحه‌بندی +/// +public class GetAllTagsQuery : IRequest +{ + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 20; + public bool? IsActive { get; set; } + public string? SearchTerm { get; set; } + public bool OrderByDescending { get; set; } = false; +} diff --git a/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsQueryHandler.cs b/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsQueryHandler.cs new file mode 100644 index 0000000..cc3a2f3 --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsQueryHandler.cs @@ -0,0 +1,82 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.TagCQ.Queries.GetAllTags; + +public class GetAllTagsQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private readonly ILogger _logger; + + public GetAllTagsQueryHandler( + IApplicationDbContext context, + ILogger logger) + { + _context = context; + _logger = logger; + } + + public async Task Handle(GetAllTagsQuery request, CancellationToken cancellationToken) + { + var query = _context.Tags + .Where(x => !x.IsDeleted); + + // فیلترها + if (request.IsActive.HasValue) + { + query = query.Where(x => x.IsActive == request.IsActive.Value); + } + + if (!string.IsNullOrEmpty(request.SearchTerm)) + { + var searchTerm = request.SearchTerm.ToLower(); + query = query.Where(x => x.Name.ToLower().Contains(searchTerm) + || x.Title.ToLower().Contains(searchTerm)); + } + + var totalCount = await query.CountAsync(cancellationToken); + + // مرتب‌سازی + query = request.OrderByDescending + ? query.OrderByDescending(x => x.SortOrder).ThenByDescending(x => x.Created) + : query.OrderBy(x => x.SortOrder).ThenBy(x => x.Created); + + // صفحه‌بندی + var tags = await query + .Skip((request.PageNumber - 1) * request.PageSize) + .Take(request.PageSize) + .Select(x => new TagDto + { + Id = x.Id, + Name = x.Name, + Title = x.Title, + Description = x.Description, + IsActive = x.IsActive, + SortOrder = x.SortOrder, + ProductCount = x.ProductTags.Count(p => !p.IsDeleted), + Created = x.Created + }) + .ToListAsync(cancellationToken); + + var metaData = new MetaData + { + TotalCount = totalCount, + PageSize = request.PageSize, + CurrentPage = request.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasNext = request.PageNumber < (int)Math.Ceiling(totalCount / (double)request.PageSize), + HasPrevious = request.PageNumber > 1 + }; + + _logger.LogInformation("Retrieved {Count} tags. Total: {Total}", tags.Count, totalCount); + + return new GetAllTagsResponseDto + { + MetaData = metaData, + Tags = tags + }; + } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsResponseDto.cs b/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsResponseDto.cs new file mode 100644 index 0000000..0ee2b51 --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Queries/GetAllTags/GetAllTagsResponseDto.cs @@ -0,0 +1,21 @@ +using CMSMicroservice.Application.Common.Models; + +namespace CMSMicroservice.Application.TagCQ.Queries.GetAllTags; + +public class GetAllTagsResponseDto +{ + public MetaData MetaData { get; set; } = new(); + public List Tags { get; set; } = new(); +} + +public class TagDto +{ + public long Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public string? Description { get; set; } + public bool IsActive { get; set; } + public int SortOrder { get; set; } + public int ProductCount { get; set; } + public DateTime Created { get; set; } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Queries/GetProductsByTag/GetProductsByTagQuery.cs b/src/CMSMicroservice.Application/TagCQ/Queries/GetProductsByTag/GetProductsByTagQuery.cs new file mode 100644 index 0000000..e808e65 --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Queries/GetProductsByTag/GetProductsByTagQuery.cs @@ -0,0 +1,17 @@ +namespace CMSMicroservice.Application.TagCQ.Queries.GetProductsByTag; + +public record GetProductsByTagQuery : IRequest> +{ + /// شناسه تگ + public long TagId { get; init; } +} + +public class ProductSimpleDto +{ + public long Id { get; set; } + public string Title { get; set; } + public long Price { get; set; } + public int Inventory { get; set; } + public bool IsActive { get; set; } + public string? ImagePath { get; set; } +} diff --git a/src/CMSMicroservice.Application/TagCQ/Queries/GetProductsByTag/GetProductsByTagQueryHandler.cs b/src/CMSMicroservice.Application/TagCQ/Queries/GetProductsByTag/GetProductsByTagQueryHandler.cs new file mode 100644 index 0000000..89a772d --- /dev/null +++ b/src/CMSMicroservice.Application/TagCQ/Queries/GetProductsByTag/GetProductsByTagQueryHandler.cs @@ -0,0 +1,44 @@ +using CMSMicroservice.Application.Common.Exceptions; +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.TagCQ.Queries.GetProductsByTag; + +public class GetProductsByTagQueryHandler : IRequestHandler> +{ + private readonly IApplicationDbContext _context; + + public GetProductsByTagQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task> Handle(GetProductsByTagQuery request, CancellationToken cancellationToken) + { + // بررسی وجود تگ + var tagExists = await _context.Tags + .AnyAsync(t => t.Id == request.TagId, cancellationToken); + + if (!tagExists) + { + throw new NotFoundException(nameof(Tag), request.TagId); + } + + var products = await _context.ProductTags + .Where(pt => pt.TagId == request.TagId) + .Include(pt => pt.Product) + .Select(pt => new ProductSimpleDto + { + Id = pt.Product.Id, + Title = pt.Product.Title, + Price = pt.Product.Price, + Inventory = pt.Product.RemainingCount, + IsActive = true, // Product entity doesn't have IsActive field + ImagePath = pt.Product.ImagePath + }) + .ToListAsync(cancellationToken); + + return products; + } +} diff --git a/src/CMSMicroservice.Application/TransactionsCQ/Commands/CreateNewTransactions/CreateNewTransactionsCommandHandler.cs b/src/CMSMicroservice.Application/TransactionsCQ/Commands/CreateNewTransactions/CreateNewTransactionsCommandHandler.cs index 802e222..21e5e9a 100644 --- a/src/CMSMicroservice.Application/TransactionsCQ/Commands/CreateNewTransactions/CreateNewTransactionsCommandHandler.cs +++ b/src/CMSMicroservice.Application/TransactionsCQ/Commands/CreateNewTransactions/CreateNewTransactionsCommandHandler.cs @@ -12,8 +12,8 @@ public class CreateNewTransactionsCommandHandler : IRequestHandler Handle(CreateNewTransactionsCommand request, CancellationToken cancellationToken) { - var entity = request.Adapt(); - await _context.Transactionss.AddAsync(entity, cancellationToken); + var entity = request.Adapt(); + await _context.Transactions.AddAsync(entity, cancellationToken); entity.AddDomainEvent(new CreateNewTransactionsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return entity.Adapt(); diff --git a/src/CMSMicroservice.Application/TransactionsCQ/Commands/DeleteTransactions/DeleteTransactionsCommandHandler.cs b/src/CMSMicroservice.Application/TransactionsCQ/Commands/DeleteTransactions/DeleteTransactionsCommandHandler.cs index 080fab5..c87f95c 100644 --- a/src/CMSMicroservice.Application/TransactionsCQ/Commands/DeleteTransactions/DeleteTransactionsCommandHandler.cs +++ b/src/CMSMicroservice.Application/TransactionsCQ/Commands/DeleteTransactions/DeleteTransactionsCommandHandler.cs @@ -11,10 +11,10 @@ public class DeleteTransactionsCommandHandler : IRequestHandler Handle(DeleteTransactionsCommand request, CancellationToken cancellationToken) { - var entity = await _context.Transactionss - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Transactions), request.Id); + var entity = await _context.Transactions + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Transaction), request.Id); entity.IsDeleted = true; - _context.Transactionss.Update(entity); + _context.Transactions.Update(entity); entity.AddDomainEvent(new DeleteTransactionsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/TransactionsCQ/Commands/RefundTransaction/RefundTransactionCommandHandler.cs b/src/CMSMicroservice.Application/TransactionsCQ/Commands/RefundTransaction/RefundTransactionCommandHandler.cs index d188c77..92078dc 100644 --- a/src/CMSMicroservice.Application/TransactionsCQ/Commands/RefundTransaction/RefundTransactionCommandHandler.cs +++ b/src/CMSMicroservice.Application/TransactionsCQ/Commands/RefundTransaction/RefundTransactionCommandHandler.cs @@ -15,12 +15,12 @@ public class RefundTransactionCommandHandler : IRequestHandler Handle(RefundTransactionCommand request, CancellationToken cancellationToken) { // پیدا کردن تراکنش اصلی - var originalTransaction = await _context.Transactionss + var originalTransaction = await _context.Transactions .FirstOrDefaultAsync(t => t.Id == request.TransactionId, cancellationToken); if (originalTransaction == null) { - throw new NotFoundException(nameof(Transactions), request.TransactionId); + throw new NotFoundException(nameof(Transaction), request.TransactionId); } // چک کردن که تراکنش Success باشد @@ -38,7 +38,7 @@ public class RefundTransactionCommandHandler : IRequestHandler Handle(UpdateTransactionsCommand request, CancellationToken cancellationToken) { - var entity = await _context.Transactionss - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Transactions), request.Id); + var entity = await _context.Transactions + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Transaction), request.Id); request.Adapt(entity); - _context.Transactionss.Update(entity); + _context.Transactions.Update(entity); entity.AddDomainEvent(new UpdateTransactionsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/TransactionsCQ/Commands/VerifyTransaction/VerifyTransactionCommandHandler.cs b/src/CMSMicroservice.Application/TransactionsCQ/Commands/VerifyTransaction/VerifyTransactionCommandHandler.cs index 929975b..bbe3c53 100644 --- a/src/CMSMicroservice.Application/TransactionsCQ/Commands/VerifyTransaction/VerifyTransactionCommandHandler.cs +++ b/src/CMSMicroservice.Application/TransactionsCQ/Commands/VerifyTransaction/VerifyTransactionCommandHandler.cs @@ -15,12 +15,12 @@ public class VerifyTransactionCommandHandler : IRequestHandler Handle(VerifyTransactionCommand request, CancellationToken cancellationToken) { // پیدا کردن تراکنش - var transaction = await _context.Transactionss + var transaction = await _context.Transactions .FirstOrDefaultAsync(t => t.Id == request.TransactionId, cancellationToken); if (transaction == null) { - throw new NotFoundException(nameof(Transactions), request.TransactionId); + throw new NotFoundException(nameof(Transaction), request.TransactionId); } // چک کردن که تراکنش در وضعیت Pending باشد diff --git a/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetAllTransactionsByFilter/GetAllTransactionsByFilterQueryHandler.cs b/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetAllTransactionsByFilter/GetAllTransactionsByFilterQueryHandler.cs index f0d391c..968eafb 100644 --- a/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetAllTransactionsByFilter/GetAllTransactionsByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetAllTransactionsByFilter/GetAllTransactionsByFilterQueryHandler.cs @@ -10,7 +10,7 @@ public class GetAllTransactionsByFilterQueryHandler : IRequestHandler Handle(GetAllTransactionsByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.Transactionss + var query = _context.Transactions .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); diff --git a/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetTransactions/GetTransactionsQueryHandler.cs b/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetTransactions/GetTransactionsQueryHandler.cs index 94feba5..f24eb22 100644 --- a/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetTransactions/GetTransactionsQueryHandler.cs +++ b/src/CMSMicroservice.Application/TransactionsCQ/Queries/GetTransactions/GetTransactionsQueryHandler.cs @@ -11,12 +11,12 @@ public class GetTransactionsQueryHandler : IRequestHandler Handle(GetTransactionsQuery request, CancellationToken cancellationToken) { - var response = await _context.Transactionss + var response = await _context.Transactions .AsNoTracking() .Where(x => x.Id == request.Id) .ProjectToType() .FirstOrDefaultAsync(cancellationToken); - return response ?? throw new NotFoundException(nameof(Transactions), request.Id); + return response ?? throw new NotFoundException(nameof(Transaction), request.Id); } } diff --git a/src/CMSMicroservice.Application/UserAddressCQ/Commands/CreateNewUserAddress/CreateNewUserAddressCommandHandler.cs b/src/CMSMicroservice.Application/UserAddressCQ/Commands/CreateNewUserAddress/CreateNewUserAddressCommandHandler.cs index 67f3107..ef93122 100644 --- a/src/CMSMicroservice.Application/UserAddressCQ/Commands/CreateNewUserAddress/CreateNewUserAddressCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserAddressCQ/Commands/CreateNewUserAddress/CreateNewUserAddressCommandHandler.cs @@ -13,9 +13,9 @@ public class CreateNewUserAddressCommandHandler : IRequestHandler(); - if (!await _context.UserAddresss.AnyAsync(x => x.UserId == request.UserId, cancellationToken: cancellationToken)) + if (!await _context.UserAddresses.AnyAsync(x => x.UserId == request.UserId, cancellationToken: cancellationToken)) entity.IsDefault = true; - await _context.UserAddresss.AddAsync(entity, cancellationToken); + await _context.UserAddresses.AddAsync(entity, cancellationToken); entity.AddDomainEvent(new CreateNewUserAddressEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return entity.Adapt(); diff --git a/src/CMSMicroservice.Application/UserAddressCQ/Commands/DeleteUserAddress/DeleteUserAddressCommandHandler.cs b/src/CMSMicroservice.Application/UserAddressCQ/Commands/DeleteUserAddress/DeleteUserAddressCommandHandler.cs index b691a95..5deb62f 100644 --- a/src/CMSMicroservice.Application/UserAddressCQ/Commands/DeleteUserAddress/DeleteUserAddressCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserAddressCQ/Commands/DeleteUserAddress/DeleteUserAddressCommandHandler.cs @@ -11,10 +11,10 @@ public class DeleteUserAddressCommandHandler : IRequestHandler Handle(DeleteUserAddressCommand request, CancellationToken cancellationToken) { - var entity = await _context.UserAddresss + var entity = await _context.UserAddresses .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserAddress), request.Id); entity.IsDeleted = true; - _context.UserAddresss.Update(entity); + _context.UserAddresses.Update(entity); entity.AddDomainEvent(new DeleteUserAddressEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/UserAddressCQ/Commands/SetAddressAsDefault/SetAddressAsDefaultCommandHandler.cs b/src/CMSMicroservice.Application/UserAddressCQ/Commands/SetAddressAsDefault/SetAddressAsDefaultCommandHandler.cs index 33335ae..d3ed798 100644 --- a/src/CMSMicroservice.Application/UserAddressCQ/Commands/SetAddressAsDefault/SetAddressAsDefaultCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserAddressCQ/Commands/SetAddressAsDefault/SetAddressAsDefaultCommandHandler.cs @@ -11,17 +11,17 @@ public class SetAddressAsDefaultCommandHandler : IRequestHandler Handle(SetAddressAsDefaultCommand request, CancellationToken cancellationToken) { - var entity = await _context.UserAddresss + var entity = await _context.UserAddresses .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserAddress), request.Id); - var entities = await _context.UserAddresss + var entities = await _context.UserAddresses .Where(x => x.UserId == entity.UserId) .ToListAsync(cancellationToken); entities.ForEach(x => x.IsDefault = false); await _context.SaveChangesAsync(cancellationToken); entity.IsDefault = true; - _context.UserAddresss.Update(entity); + _context.UserAddresses.Update(entity); entity.AddDomainEvent(new SetAddressAsDefaultEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/UserAddressCQ/Commands/UpdateUserAddress/UpdateUserAddressCommandHandler.cs b/src/CMSMicroservice.Application/UserAddressCQ/Commands/UpdateUserAddress/UpdateUserAddressCommandHandler.cs index e8b8ec1..b9d0650 100644 --- a/src/CMSMicroservice.Application/UserAddressCQ/Commands/UpdateUserAddress/UpdateUserAddressCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserAddressCQ/Commands/UpdateUserAddress/UpdateUserAddressCommandHandler.cs @@ -11,10 +11,10 @@ public class UpdateUserAddressCommandHandler : IRequestHandler Handle(UpdateUserAddressCommand request, CancellationToken cancellationToken) { - var entity = await _context.UserAddresss + var entity = await _context.UserAddresses .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserAddress), request.Id); request.Adapt(entity); - _context.UserAddresss.Update(entity); + _context.UserAddresses.Update(entity); entity.AddDomainEvent(new UpdateUserAddressEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetAllUserAddressByFilter/GetAllUserAddressByFilterQueryHandler.cs b/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetAllUserAddressByFilter/GetAllUserAddressByFilterQueryHandler.cs index a304c8c..80bd05b 100644 --- a/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetAllUserAddressByFilter/GetAllUserAddressByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetAllUserAddressByFilter/GetAllUserAddressByFilterQueryHandler.cs @@ -10,7 +10,7 @@ public class GetAllUserAddressByFilterQueryHandler : IRequestHandler Handle(GetAllUserAddressByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.UserAddresss + var query = _context.UserAddresses .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); diff --git a/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetUserAddress/GetUserAddressQueryHandler.cs b/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetUserAddress/GetUserAddressQueryHandler.cs index 4147345..93736f0 100644 --- a/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetUserAddress/GetUserAddressQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserAddressCQ/Queries/GetUserAddress/GetUserAddressQueryHandler.cs @@ -11,7 +11,7 @@ public class GetUserAddressQueryHandler : IRequestHandler Handle(GetUserAddressQuery request, CancellationToken cancellationToken) { - var response = await _context.UserAddresss + var response = await _context.UserAddresses .AsNoTracking() .Where(x => x.Id == request.Id) .ProjectToType() diff --git a/src/CMSMicroservice.Application/UserCQ/Commands/MigrateNetworkParentId/MigrateNetworkParentIdCommandHandler.cs b/src/CMSMicroservice.Application/UserCQ/Commands/MigrateNetworkParentId/MigrateNetworkParentIdCommandHandler.cs index e5b6aab..8d1e716 100644 --- a/src/CMSMicroservice.Application/UserCQ/Commands/MigrateNetworkParentId/MigrateNetworkParentIdCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserCQ/Commands/MigrateNetworkParentId/MigrateNetworkParentIdCommandHandler.cs @@ -21,119 +21,17 @@ public class MigrateNetworkParentIdCommandHandler : IRequestHandler Handle(MigrateNetworkParentIdCommand request, CancellationToken cancellationToken) { - _logger.LogInformation("=== Starting Manual ParentId → NetworkParentId Migration ==="); + _logger.LogInformation("=== ParentId Migration No Longer Needed (ParentId Removed) ==="); - var errors = new List(); - - // Step 1: Check if already migrated - var alreadyMigrated = await _context.Users - .Where(u => u.ParentId != null && u.NetworkParentId != null) - .AnyAsync(cancellationToken); - - if (alreadyMigrated) - { - _logger.LogWarning("⚠️ Migration already completed!"); - return new MigrateNetworkParentIdResult - { - Success = false, - Message = "Migration already completed. All users with ParentId have NetworkParentId." - }; - } - - // Step 2: Find users to migrate - var usersToMigrate = await _context.Users - .Where(u => u.ParentId != null && u.NetworkParentId == null) - .OrderBy(u => u.Id) - .ToListAsync(cancellationToken); - - if (usersToMigrate.Count == 0) - { - return new MigrateNetworkParentIdResult - { - Success = true, - Message = "No users to migrate. All done!" - }; - } - - // Step 3: Group by ParentId - var parentGroups = usersToMigrate.GroupBy(u => u.ParentId); - - int migratedCount = 0; - int skippedCount = 0; - - foreach (var group in parentGroups) - { - var parentId = group.Key; - var children = group.OrderBy(u => u.Id).ToList(); - - if (children.Count > 2) - { - var warning = $"Parent {parentId} has {children.Count} children! Taking first 2 only."; - _logger.LogWarning(warning); - errors.Add(warning); - - skippedCount += (children.Count - 2); - children = children.Take(2).ToList(); - } - - // Assign NetworkParentId and LegPosition - for (int i = 0; i < children.Count && i < 2; i++) - { - var child = children[i]; - child.NetworkParentId = parentId; - child.LegPosition = i == 0 ? NetworkLeg.Left : NetworkLeg.Right; - migratedCount++; - } - } - - // Step 4: Save changes - await _context.SaveChangesAsync(cancellationToken); - - _logger.LogInformation("✅ Migration Completed! Migrated={Migrated}, Skipped={Skipped}", - migratedCount, skippedCount); - - // Step 5: Validate - await ValidateAsync(errors, cancellationToken); - + // ParentId has been removed from User entity + // This migration is no longer necessary return new MigrateNetworkParentIdResult { Success = true, - MigratedCount = migratedCount, - SkippedCount = skippedCount, - ValidationErrors = errors, - Message = $"Migration completed successfully. Migrated: {migratedCount}, Skipped: {skippedCount}" + Message = "ParentId field has been removed. This migration is obsolete.", + MigratedCount = 0, + SkippedCount = 0, + ValidationErrors = new List() }; } - - private async Task ValidateAsync(List errors, CancellationToken cancellationToken) - { - // Check orphaned nodes - var orphanedUsers = await _context.Users - .Where(u => u.NetworkParentId != null && - !_context.Users.Any(p => p.Id == u.NetworkParentId)) - .Select(u => u.Id) - .ToListAsync(cancellationToken); - - if (orphanedUsers.Any()) - { - var error = $"Found {orphanedUsers.Count} orphaned users: {string.Join(", ", orphanedUsers)}"; - _logger.LogError(error); - errors.Add(error); - } - - // Check binary tree violation - var parentsWithTooManyChildren = await _context.Users - .Where(u => u.NetworkParentId != null) - .GroupBy(u => u.NetworkParentId) - .Select(g => new { ParentId = g.Key, Count = g.Count() }) - .Where(x => x.Count > 2) - .ToListAsync(cancellationToken); - - if (parentsWithTooManyChildren.Any()) - { - var error = $"Binary tree violation! {parentsWithTooManyChildren.Count} parents have >2 children"; - _logger.LogError(error); - errors.Add(error); - } - } } diff --git a/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQuery.cs b/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQuery.cs index af569c5..c379453 100644 --- a/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQuery.cs +++ b/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQuery.cs @@ -22,8 +22,8 @@ public record GetAllUserByFilterQuery : IRequest public string? NationalCode { get; set; } //آدرس آواتار public string? AvatarPath { get; set; } - //شناسه والد - public long? ParentId { get; set; } + //شناسه والد در شبکه + public long? NetworkParentId { get; set; } //کد ارجاع public string? ReferralCode { get; set; } //موبایل فعال شده؟ diff --git a/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQueryHandler.cs b/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQueryHandler.cs index 883805f..9e56ac9 100644 --- a/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterQueryHandler.cs @@ -25,7 +25,7 @@ public class GetAllUserByFilterQueryHandler : IRequestHandler request.Filter.AvatarPath == null || x.AvatarPath.Contains(request.Filter.AvatarPath)) .Where(x => request.Filter.ReferralCode == null || x.ReferralCode == request.Filter.ReferralCode) .Where(x => request.Filter.IsMobileVerified == null || x.IsMobileVerified == request.Filter.IsMobileVerified) - .Where(x => request.Filter.ParentId == null || x.ParentId == request.Filter.ParentId) + .Where(x => request.Filter.NetworkParentId == null || x.NetworkParentId == request.Filter.NetworkParentId) .Where(x => request.Filter.SmsNotifications == null || x.SmsNotifications == request.Filter.SmsNotifications) .Where(x => request.Filter.EmailNotifications == null || x.EmailNotifications == request.Filter.EmailNotifications) .Where(x => request.Filter.PushNotifications == null || x.PushNotifications == request.Filter.PushNotifications) diff --git a/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterResponseDto.cs b/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterResponseDto.cs index 2e34e2f..617fcba 100644 --- a/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterResponseDto.cs +++ b/src/CMSMicroservice.Application/UserCQ/Queries/GetAllUserByFilter/GetAllUserByFilterResponseDto.cs @@ -20,8 +20,8 @@ public class GetAllUserByFilterResponseDto public string? NationalCode { get; set; } //آدرس آواتار public string? AvatarPath { get; set; } - //شناسه والد - public long? ParentId { get; set; } + //شناسه والد در شبکه + public long? NetworkParentId { get; set; } //کد ارجاع public string ReferralCode { get; set; } //موبایل فعال شده؟ diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Commands/ClearCart/ClearCartCommandHandler.cs b/src/CMSMicroservice.Application/UserCartsCQ/Commands/ClearCart/ClearCartCommandHandler.cs index a6f0e47..36aecaa 100644 --- a/src/CMSMicroservice.Application/UserCartsCQ/Commands/ClearCart/ClearCartCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserCartsCQ/Commands/ClearCart/ClearCartCommandHandler.cs @@ -14,7 +14,7 @@ public class ClearCartCommandHandler : IRequestHandler Handle(ClearCartCommand request, CancellationToken cancellationToken) { // پیدا کردن تمام آیتم‌های سبد خرید کاربر - var cartItems = await _context.UserCartss + var cartItems = await _context.UserCarts .Where(c => c.UserId == request.UserId) .ToListAsync(cancellationToken); @@ -31,7 +31,7 @@ public class ClearCartCommandHandler : IRequestHandler Handle(CreateNewUserCartsCommand request, CancellationToken cancellationToken) { - var entity = request.Adapt(); - var existingUserCart = await _context.UserCartss + var entity = request.Adapt(); + var existingUserCart = await _context.UserCarts .FirstOrDefaultAsync(x => x.UserId == entity.UserId && x.ProductId == entity.ProductId && !x.IsDeleted, cancellationToken); if (existingUserCart != null) { existingUserCart.Count += entity.Count; - _context.UserCartss.Update(existingUserCart); + _context.UserCarts.Update(existingUserCart); existingUserCart.AddDomainEvent(new UpdateUserCartsEvent(existingUserCart)); await _context.SaveChangesAsync(cancellationToken); return existingUserCart.Adapt(); } - await _context.UserCartss.AddAsync(entity, cancellationToken); + await _context.UserCarts.AddAsync(entity, cancellationToken); entity.AddDomainEvent(new CreateNewUserCartsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return entity.Adapt(); diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Commands/DeleteUserCarts/DeleteUserCartsCommandHandler.cs b/src/CMSMicroservice.Application/UserCartsCQ/Commands/DeleteUserCarts/DeleteUserCartsCommandHandler.cs index c04c848..83b3f7c 100644 --- a/src/CMSMicroservice.Application/UserCartsCQ/Commands/DeleteUserCarts/DeleteUserCartsCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserCartsCQ/Commands/DeleteUserCarts/DeleteUserCartsCommandHandler.cs @@ -11,10 +11,10 @@ public class DeleteUserCartsCommandHandler : IRequestHandler Handle(DeleteUserCartsCommand request, CancellationToken cancellationToken) { - var entity = await _context.UserCartss - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserCarts), request.Id); + var entity = await _context.UserCarts + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserCart), request.Id); entity.IsDeleted = true; - _context.UserCartss.Update(entity); + _context.UserCarts.Update(entity); entity.AddDomainEvent(new DeleteUserCartsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommand.cs b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommand.cs new file mode 100644 index 0000000..fdac4d0 --- /dev/null +++ b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommand.cs @@ -0,0 +1,23 @@ +namespace CMSMicroservice.Application.UserCartsCQ.Commands.MergeCart; + +/// +/// Command برای ادغام سبد خرید مهمان با سبد خرید کاربر بعد از ورود +/// +public record MergeCartCommand : IRequest +{ + /// + /// شناسه کاربر (بعد از Login) + /// + public long UserId { get; init; } + + /// + /// لیست محصولات سبد مهمان + /// + public List GuestCartItems { get; init; } = new(); +} + +public class GuestCartItem +{ + public long ProductId { get; set; } + public int Count { get; set; } +} diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommandHandler.cs b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommandHandler.cs new file mode 100644 index 0000000..7acf2ef --- /dev/null +++ b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommandHandler.cs @@ -0,0 +1,97 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.UserCartsCQ.Commands.MergeCart; + +public class MergeCartCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public MergeCartCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(MergeCartCommand request, CancellationToken cancellationToken) + { + // بررسی وجود کاربر + var user = await _context.Users + .FirstOrDefaultAsync(u => u.Id == request.UserId, cancellationToken); + + if (user == null) + { + return new MergeCartResponseDto + { + Success = false, + Message = "کاربر یافت نشد" + }; + } + + // دریافت سبد فعلی کاربر + var existingCartItems = await _context.UserCarts + .Where(c => c.UserId == request.UserId && !c.IsDeleted) + .ToListAsync(cancellationToken); + + int mergedCount = 0; + + // ادغام آیتم‌های مهمان با سبد کاربر + foreach (var guestItem in request.GuestCartItems) + { + // بررسی موجود بودن محصول + var product = await _context.Products + .FirstOrDefaultAsync(p => p.Id == guestItem.ProductId && !p.IsDeleted, cancellationToken); + + if (product == null) + continue; // محصول پیدا نشد یا حذف شده + + // بررسی موجودی + if (product.RemainingCount < guestItem.Count) + continue; // موجودی کافی نیست + + // چک کردن آیا این محصول قبلاً در سبد کاربر هست + var existingItem = existingCartItems.FirstOrDefault(c => c.ProductId == guestItem.ProductId); + + if (existingItem != null) + { + // آیتم موجود است → افزایش تعداد + existingItem.Count += guestItem.Count; + + // محدود کردن به موجودی + if (existingItem.Count > product.RemainingCount) + existingItem.Count = product.RemainingCount; + + _context.UserCarts.Update(existingItem); + } + else + { + // آیتم جدید → اضافه کردن به سبد + var newCartItem = new UserCart + { + UserId = request.UserId, + ProductId = guestItem.ProductId, + Count = Math.Min(guestItem.Count, product.RemainingCount) + }; + + await _context.UserCarts.AddAsync(newCartItem, cancellationToken); + } + + mergedCount++; + } + + await _context.SaveChangesAsync(cancellationToken); + + // محاسبه تعداد کل آیتم‌های سبد بعد از ادغام + var totalItems = await _context.UserCarts + .Where(c => c.UserId == request.UserId && !c.IsDeleted) + .CountAsync(cancellationToken); + + return new MergeCartResponseDto + { + Success = true, + Message = $"{mergedCount} محصول با موفقیت به سبد خرید اضافه شد", + MergedItemsCount = mergedCount, + TotalCartItems = totalItems + }; + } +} diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommandValidator.cs b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommandValidator.cs new file mode 100644 index 0000000..cb2c2a9 --- /dev/null +++ b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartCommandValidator.cs @@ -0,0 +1,31 @@ +using FluentValidation; + +namespace CMSMicroservice.Application.UserCartsCQ.Commands.MergeCart; + +public class MergeCartCommandValidator : AbstractValidator +{ + public MergeCartCommandValidator() + { + RuleFor(x => x.UserId) + .GreaterThan(0) + .WithMessage("شناسه کاربر نامعتبر است"); + + RuleFor(x => x.GuestCartItems) + .NotNull() + .WithMessage("لیست آیتم‌های سبد خرید نباید خالی باشد"); + + RuleForEach(x => x.GuestCartItems) + .ChildRules(item => + { + item.RuleFor(i => i.ProductId) + .GreaterThan(0) + .WithMessage("شناسه محصول نامعتبر است"); + + item.RuleFor(i => i.Count) + .GreaterThan(0) + .WithMessage("تعداد باید بیشتر از صفر باشد") + .LessThanOrEqualTo(100) + .WithMessage("حداکثر تعداد مجاز 100 عدد است"); + }); + } +} diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartResponseDto.cs b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartResponseDto.cs new file mode 100644 index 0000000..e81b19e --- /dev/null +++ b/src/CMSMicroservice.Application/UserCartsCQ/Commands/MergeCart/MergeCartResponseDto.cs @@ -0,0 +1,9 @@ +namespace CMSMicroservice.Application.UserCartsCQ.Commands.MergeCart; + +public class MergeCartResponseDto +{ + public bool Success { get; set; } + public string Message { get; set; } + public int MergedItemsCount { get; set; } + public int TotalCartItems { get; set; } +} diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Commands/UpdateUserCarts/UpdateUserCartsCommandHandler.cs b/src/CMSMicroservice.Application/UserCartsCQ/Commands/UpdateUserCarts/UpdateUserCartsCommandHandler.cs index 80ce89b..f754d59 100644 --- a/src/CMSMicroservice.Application/UserCartsCQ/Commands/UpdateUserCarts/UpdateUserCartsCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserCartsCQ/Commands/UpdateUserCarts/UpdateUserCartsCommandHandler.cs @@ -18,10 +18,10 @@ public class UpdateUserCartsCommandHandler : IRequestHandler(), cancellationToken); } - var entity = await _context.UserCartss - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserCarts), request.Id); + var entity = await _context.UserCarts + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserCart), request.Id); request.Adapt(entity); - _context.UserCartss.Update(entity); + _context.UserCarts.Update(entity); entity.AddDomainEvent(new UpdateUserCartsEvent(entity)); await _context.SaveChangesAsync(cancellationToken); return Unit.Value; diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetAllUserCartsByFilter/GetAllUserCartsByFilterQueryHandler.cs b/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetAllUserCartsByFilter/GetAllUserCartsByFilterQueryHandler.cs index 7a44fd6..2fe5778 100644 --- a/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetAllUserCartsByFilter/GetAllUserCartsByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetAllUserCartsByFilter/GetAllUserCartsByFilterQueryHandler.cs @@ -10,7 +10,7 @@ public class GetAllUserCartsByFilterQueryHandler : IRequestHandler Handle(GetAllUserCartsByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.UserCartss.Include(i=>i.Product) + var query = _context.UserCarts.Include(i=>i.Product) .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() .AsQueryable(); diff --git a/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetUserCarts/GetUserCartsQueryHandler.cs b/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetUserCarts/GetUserCartsQueryHandler.cs index 5d43c5b..27473f2 100644 --- a/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetUserCarts/GetUserCartsQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserCartsCQ/Queries/GetUserCarts/GetUserCartsQueryHandler.cs @@ -11,12 +11,12 @@ public class GetUserCartsQueryHandler : IRequestHandler Handle(GetUserCartsQuery request, CancellationToken cancellationToken) { - var response = await _context.UserCartss + var response = await _context.UserCarts .AsNoTracking() .Where(x => x.Id == request.Id) .ProjectToType() .FirstOrDefaultAsync(cancellationToken); - return response ?? throw new NotFoundException(nameof(UserCarts), request.Id); + return response ?? throw new NotFoundException(nameof(UserCart), request.Id); } } diff --git a/src/CMSMicroservice.Application/UserOrderCQ/Commands/CancelOrder/CancelOrderCommandHandler.cs b/src/CMSMicroservice.Application/UserOrderCQ/Commands/CancelOrder/CancelOrderCommandHandler.cs index 208b2be..45fdc9d 100644 --- a/src/CMSMicroservice.Application/UserOrderCQ/Commands/CancelOrder/CancelOrderCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserOrderCQ/Commands/CancelOrder/CancelOrderCommandHandler.cs @@ -45,7 +45,7 @@ public class CancelOrderCommandHandler : IRequestHandler { private readonly IApplicationDbContext _context; + private readonly ILogger _logger; - public SubmitShopBuyOrderCommandHandler(IApplicationDbContext context) + public SubmitShopBuyOrderCommandHandler( + IApplicationDbContext context, + ILogger logger) { _context = context; + _logger = logger; } public async Task Handle(SubmitShopBuyOrderCommand request, CancellationToken cancellationToken) { var user = await _context.Users - .Include(i => i.UserAddresss) + .Include(i => i.UserAddresses) .Include(i => i.UserWallets) .ThenInclude(i => i.UserWalletChangeLogs) - .Include(i => i.UserCartss) + .Include(i => i.UserCarts) .ThenInclude(i => i.Product) .FirstOrDefaultAsync(w => w.Id == request.UserId, cancellationToken: cancellationToken); - if (user.UserCartss.Count == 0) + if (user.UserCarts.Count == 0) throw new NotFoundException("UserCart", request.UserId); - if (user.UserCartss.Sum(s => s.Count * s.Product.Price) != request.TotalAmount) + if (user.UserCarts.Sum(s => s.Count * s.Product.Price) != request.TotalAmount) throw new Exception("مبلغ سفارش با مجموع سبد خرید مطابقت ندارد."); @@ -37,7 +43,7 @@ public class if (userWallet.Balance<=0 || userWallet.Balance f.IsDefault).Id, + UserAddressId = user.UserAddresses.First(f => f.IsDefault).Id, TransactionId = newTransaction.Id, // سفارش فروشگاهی فیزیکی است، پس در ابتدا در انتظار ارسال است DeliveryStatus = DeliveryStatus.Pending }; await _context.UserOrders.AddAsync(newOrder, cancellationToken); await _context.SaveChangesAsync(cancellationToken); - var factorDetailsList = user.UserCartss.Select(s => new FactorDetails() + + // محاسبه و ثبت VAT (اگر فعال باشد) + var vatCreated = await CalculateAndSaveVAT(newOrder.Id, request.TotalAmount, cancellationToken); + if (vatCreated) + { + newOrder.HasVAT = true; + await _context.SaveChangesAsync(cancellationToken); + } + + var factorDetailsList = user.UserCarts.Select(s => new FactorDetails() { ProductId = s.ProductId, Count = s.Count, UnitPrice = s.Product.Price, OrderId = newOrder.Id }); - await _context.FactorDetailss.AddRangeAsync(factorDetailsList, cancellationToken); - user.UserCartss.Clear(); + await _context.FactorDetails.AddRangeAsync(factorDetailsList, cancellationToken); + user.UserCarts.Clear(); await _context.SaveChangesAsync(cancellationToken); var finalResult = new SubmitShopBuyOrderResponseDto() { @@ -94,4 +109,66 @@ public class }; return finalResult; } + + private async Task CalculateAndSaveVAT(long orderId, long orderAmount, CancellationToken cancellationToken) + { + try + { + // بررسی فعال بودن VAT + var vatEnabledConfig = await _context.SystemConfigurations + .FirstOrDefaultAsync(x => x.Scope == ConfigurationScope.VAT && x.Key == "IsEnabled", cancellationToken); + + if (vatEnabledConfig == null || !bool.TryParse(vatEnabledConfig.Value, out var isEnabled) || !isEnabled) + { + _logger.LogInformation("VAT is disabled. Skipping VAT calculation for order {OrderId}", orderId); + return false; + } + + // دریافت نرخ VAT + var vatRateConfig = await _context.SystemConfigurations + .FirstOrDefaultAsync(x => x.Scope == ConfigurationScope.VAT && x.Key == "Rate", cancellationToken); + + if (vatRateConfig == null || !decimal.TryParse(vatRateConfig.Value, out var vatRate)) + { + _logger.LogWarning("VAT Rate configuration not found or invalid. Using default 0.09"); + vatRate = 0.09m; + } + + // محاسبه مالیات + var vatAmount = (long)(orderAmount * vatRate); + var totalAmount = orderAmount + vatAmount; + + // ثبت VAT + var orderVAT = new OrderVAT + { + OrderId = orderId, + VATRate = vatRate, + BaseAmount = orderAmount, + VATAmount = vatAmount, + TotalAmount = totalAmount, + IsPaid = true, + PaidAt = DateTime.UtcNow + }; + + await _context.OrderVATs.AddAsync(orderVAT, cancellationToken); + await _context.SaveChangesAsync(cancellationToken); + + _logger.LogInformation( + "VAT calculated and saved for order {OrderId}. Rate: {Rate}%, Base: {Base}, VAT: {VAT}, Total: {Total}", + orderId, + vatRate * 100, + orderAmount, + vatAmount, + totalAmount + ); + + return true; + } + catch (Exception ex) + { + _logger.LogError(ex, "Error calculating VAT for order {OrderId}", orderId); + // عدم محاسبه VAT نباید مانع ثبت سفارش شود + return false; + } + } } diff --git a/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQueryHandler.cs b/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQueryHandler.cs index dde2b87..e55b0f3 100644 --- a/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetAllUserOrderByFilter/GetAllUserOrderByFilterQueryHandler.cs @@ -13,7 +13,7 @@ public class GetAllUserOrderByFilterQueryHandler : IRequestHandler i.UserAddress) .Include(i => i.User) - .Include(i => i.FactorDetailss) + .Include(i => i.FactorDetails) .ThenInclude(t => t.Product) .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() @@ -48,7 +48,7 @@ public class GetAllUserOrderByFilterQueryHandler : IRequestHandler new GetAllUserOrderByFilterResponseModelFactorDetail + FactorDetails = x.FactorDetails.Select(fd => new GetAllUserOrderByFilterResponseModelFactorDetail { ProductId = fd.ProductId, ProductTitle = fd.Product.Title, diff --git a/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderQueryHandler.cs b/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderQueryHandler.cs index eabf3d6..3fadd9d 100644 --- a/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserOrderCQ/Queries/GetUserOrder/GetUserOrderQueryHandler.cs @@ -14,7 +14,7 @@ public class GetUserOrderQueryHandler : IRequestHandler i.UserAddress) .Include(i => i.User) - .Include(i => i.FactorDetailss) + .Include(i => i.FactorDetails) .ThenInclude(t => t.Product) .AsNoTracking() .Where(x => x.Id == request.Id) @@ -30,7 +30,7 @@ public class GetUserOrderQueryHandler : IRequestHandler new GetUserOrderResponseFactorDetail + FactorDetails = x.FactorDetails.Select(fd => new GetUserOrderResponseFactorDetail { ProductId = fd.ProductId, ProductTitle = fd.Product.Title, diff --git a/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs b/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs index defcb1e..a03c784 100644 --- a/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs +++ b/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs @@ -87,7 +87,7 @@ public class VerifyDiscountWalletChargeCommandHandler ); // 4. ثبت Transaction - var transaction = new Transactions + var transaction = new Transaction { Amount = request.Amount, Description = $"شارژ کیف پول تخفیفی - کاربر {user.Id}", @@ -97,7 +97,7 @@ public class VerifyDiscountWalletChargeCommandHandler Type = TransactionType.DiscountWalletCharge }; - _context.Transactionss.Add(transaction); + _context.Transactions.Add(transaction); await _context.SaveChangesAsync(cancellationToken); _logger.LogInformation( diff --git a/src/CMSMicroservice.Domain/Entities/Category.cs b/src/CMSMicroservice.Domain/Entities/Category.cs index d8936a6..0dae4a7 100644 --- a/src/CMSMicroservice.Domain/Entities/Category.cs +++ b/src/CMSMicroservice.Domain/Entities/Category.cs @@ -19,7 +19,7 @@ public class Category : BaseAuditableEntity //ترتیب نمایش public int SortOrder { get; set; } //Category Collection Navigation Reference - public virtual ICollection Categorys { get; set; } - //PruductCategory Collection Navigation Reference - public virtual ICollection PruductCategorys { get; set; } + public virtual ICollection Categories { get; set; } + //ProductCategory Collection Navigation Reference + public virtual ICollection ProductCategories { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/Club/ClubMembership.cs b/src/CMSMicroservice.Domain/Entities/Club/ClubMembership.cs index bb27a39..66af6b7 100644 --- a/src/CMSMicroservice.Domain/Entities/Club/ClubMembership.cs +++ b/src/CMSMicroservice.Domain/Entities/Club/ClubMembership.cs @@ -30,6 +30,12 @@ public class ClubMembership : BaseAuditableEntity /// public long InitialContribution { get; set; } + /// + /// ارزش هدیه حق عضویت باشگاه (25,200,000 تومان) + /// این مبلغ از کیف پول کاربر کم نمی‌شود و صرفاً هدیه است + /// + public long GiftValue { get; set; } + /// /// مجموع درآمد کارمزد تاکنون (ریال) /// diff --git a/src/CMSMicroservice.Domain/Entities/DayaLoanContract.cs b/src/CMSMicroservice.Domain/Entities/DayaLoanContract.cs index 44991a5..39dd7bc 100644 --- a/src/CMSMicroservice.Domain/Entities/DayaLoanContract.cs +++ b/src/CMSMicroservice.Domain/Entities/DayaLoanContract.cs @@ -55,5 +55,5 @@ public class DayaLoanContract : BaseAuditableEntity /// /// Transaction Navigation Property /// - public virtual Transactions? Transaction { get; set; } + public virtual Transaction? Transaction { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountCategory.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountCategory.cs new file mode 100644 index 0000000..48afcfa --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountCategory.cs @@ -0,0 +1,59 @@ +namespace CMSMicroservice.Domain.Entities.DiscountShop; + +/// +/// دسته‌بندی محصولات فروشگاه تخفیفی +/// +public class DiscountCategory : BaseAuditableEntity +{ + /// + /// نام لاتین (برای URL) + /// + public string Name { get; set; } + + /// + /// عنوان فارسی + /// + public string Title { get; set; } + + /// + /// توضیحات دسته‌بندی + /// + public string? Description { get; set; } + + /// + /// آدرس تصویر دسته‌بندی + /// + public string? ImagePath { get; set; } + + /// + /// شناسه دسته‌بندی والد (برای ساختار درختی) + /// + public long? ParentCategoryId { get; set; } + + /// + /// مرتب‌سازی + /// + public int SortOrder { get; set; } + + /// + /// وضعیت فعال/غیرفعال + /// + public bool IsActive { get; set; } + + // ============= Navigation Properties ============= + + /// + /// دسته‌بندی والد + /// + public virtual DiscountCategory? ParentCategory { get; set; } + + /// + /// دسته‌بندی‌های فرزند + /// + public virtual ICollection ChildCategories { get; set; } + + /// + /// محصولات این دسته‌بندی + /// + public virtual ICollection ProductCategories { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountOrder.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountOrder.cs new file mode 100644 index 0000000..1328477 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountOrder.cs @@ -0,0 +1,97 @@ +using CMSMicroservice.Domain.Enums; + +namespace CMSMicroservice.Domain.Entities.DiscountShop; + +/// +/// سفارش از فروشگاه تخفیفی +/// در این سفارش، پرداخت به صورت ترکیبی است: +/// - بخشی از DiscountBalance کاربر کسر می‌شود (محدود به MaxDiscountPercent) +/// - مابقی از درگاه پرداخت پرداخت می‌شود +/// +public class DiscountOrder : BaseAuditableEntity +{ + /// + /// شناسه کاربر + /// + public long UserId { get; set; } + + /// + /// مبلغ کل سفارش (قیمت تمام محصولات) + /// + public long TotalAmount { get; set; } + + /// + /// مبلغ کسر شده از DiscountBalance + /// این مبلغ محدود به MaxDiscountPercent هر محصول است + /// + public long DiscountBalanceUsed { get; set; } + + /// + /// مبلغ پرداخت شده از درگاه (IPG) + /// PayableAmount = TotalAmount - DiscountBalanceUsed + /// + public long GatewayAmountPaid { get; set; } + + /// + /// مالیات بر ارزش افزوده (VAT) - 9% + /// محاسبه روی TotalAmount + /// + public long VatAmount { get; set; } + + /// + /// وضعیت پرداخت + /// + public PaymentStatus PaymentStatus { get; set; } + + /// + /// تاریخ پرداخت + /// + public DateTime? PaymentDate { get; set; } + + /// + /// شناسه تراکنش (Transaction از درگاه پرداخت) + /// + public long? TransactionId { get; set; } + + /// + /// شناسه آدرس تحویل + /// + public long UserAddressId { get; set; } + + /// + /// وضعیت ارسال + /// + public DeliveryStatus DeliveryStatus { get; set; } + + /// + /// کد رهگیری مرسوله + /// + public string? TrackingCode { get; set; } + + /// + /// توضیحات وضعیت ارسال + /// + public string? DeliveryDescription { get; set; } + + // ============= Navigation Properties ============= + + /// + /// کاربر + /// + public virtual User User { get; set; } + + /// + /// تراکنش پرداخت از درگاه + /// + public virtual Transaction? Transaction { get; set; } + + /// + /// آدرس تحویل + /// + public virtual UserAddress UserAddress { get; set; } + + /// + /// جزئیات سفارش (محصولات) + /// + public virtual ICollection OrderDetails { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountOrderDetail.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountOrderDetail.cs new file mode 100644 index 0000000..251f9c0 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountOrderDetail.cs @@ -0,0 +1,59 @@ +namespace CMSMicroservice.Domain.Entities.DiscountShop; + +/// +/// جزئیات سفارش فروشگاه تخفیفی +/// هر ردیف یک محصول و تعداد آن را نشان می‌دهد +/// +public class DiscountOrderDetail : BaseAuditableEntity +{ + /// + /// شناسه سفارش + /// + public long DiscountOrderId { get; set; } + + /// + /// شناسه محصول + /// + public long ProductId { get; set; } + + /// + /// تعداد + /// + public int Count { get; set; } + + /// + /// قیمت واحد (هنگام خرید) + /// قیمت ممکن است در آینده تغییر کند، پس در زمان خرید ذخیره می‌شود + /// + public long UnitPrice { get; set; } + + /// + /// درصد تخفیف استفاده شده از DiscountBalance + /// این درصد محدود به MaxDiscountPercent محصول است + /// + public int DiscountPercentUsed { get; set; } + + /// + /// مبلغ تخفیف استفاده شده برای این محصول + /// DiscountAmount = (UnitPrice × Count) × (DiscountPercentUsed / 100) + /// + public long DiscountAmount { get; set; } + + /// + /// مبلغ نهایی پرداختی برای این محصول + /// FinalPrice = (UnitPrice × Count) - DiscountAmount + /// + public long FinalPrice { get; set; } + + // ============= Navigation Properties ============= + + /// + /// سفارش + /// + public virtual DiscountOrder DiscountOrder { get; set; } + + /// + /// محصول + /// + public virtual DiscountProduct Product { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProduct.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProduct.cs new file mode 100644 index 0000000..5985d1b --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProduct.cs @@ -0,0 +1,86 @@ +namespace CMSMicroservice.Domain.Entities.DiscountShop; + +/// +/// محصول فروشگاه تخفیفی باشگاه +/// در این فروشگاه کاربر با ترکیب DiscountBalance و پرداخت واقعی خرید می‌کند +/// +public class DiscountProduct : BaseAuditableEntity +{ + /// + /// عنوان محصول + /// + public string Title { get; set; } + + /// + /// توضیحات مختصر + /// + public string ShortInfomation { get; set; } + + /// + /// توضیحات کامل + /// + public string FullInformation { get; set; } + + /// + /// قیمت اصلی محصول (ریال) + /// + public long Price { get; set; } + + /// + /// حداکثر درصد تخفیفی که از DiscountBalance قابل استفاده است (0 تا 100) + /// مثال: 30 یعنی حداکثر 30% از قیمت را می‌توان با DiscountBalance پرداخت کرد + /// + public int MaxDiscountPercent { get; set; } + + /// + /// امتیاز محصول (0 تا 5) + /// + public int Rate { get; set; } + + /// + /// آدرس تصویر اصلی + /// + public string ImagePath { get; set; } + + /// + /// آدرس تصویر کوچک (Thumbnail) + /// + public string ThumbnailPath { get; set; } + + /// + /// تعداد فروش + /// + public int SaleCount { get; set; } + + /// + /// تعداد بازدید + /// + public int ViewCount { get; set; } + + /// + /// موجودی انبار + /// + public int RemainingCount { get; set; } + + /// + /// وضعیت فعال/غیرفعال + /// + public bool IsActive { get; set; } + + // ============= Navigation Properties ============= + + /// + /// سبدهای خریدی که این محصول در آن‌ها است + /// + public virtual ICollection ShoppingCarts { get; set; } + + /// + /// جزئیات سفارشات شامل این محصول + /// + public virtual ICollection OrderDetails { get; set; } + + /// + /// دسته‌بندی‌های این محصول + /// + public virtual ICollection ProductCategories { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProductCategory.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProductCategory.cs new file mode 100644 index 0000000..bec0b4d --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProductCategory.cs @@ -0,0 +1,29 @@ +namespace CMSMicroservice.Domain.Entities.DiscountShop; + +/// +/// جدول رابطه چند به چند بین محصول و دسته‌بندی +/// +public class DiscountProductCategory : BaseAuditableEntity +{ + /// + /// شناسه محصول + /// + public long ProductId { get; set; } + + /// + /// شناسه دسته‌بندی + /// + public long CategoryId { get; set; } + + // ============= Navigation Properties ============= + + /// + /// محصول + /// + public virtual DiscountProduct Product { get; set; } + + /// + /// دسته‌بندی + /// + public virtual DiscountCategory Category { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountShoppingCart.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountShoppingCart.cs new file mode 100644 index 0000000..b5f32f3 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountShoppingCart.cs @@ -0,0 +1,35 @@ +namespace CMSMicroservice.Domain.Entities.DiscountShop; + +/// +/// سبد خرید فروشگاه تخفیفی +/// هر کاربر می‌تواند چندین محصول در سبد داشته باشد +/// +public class DiscountShoppingCart : BaseAuditableEntity +{ + /// + /// شناسه کاربر + /// + public long UserId { get; set; } + + /// + /// شناسه محصول + /// + public long ProductId { get; set; } + + /// + /// تعداد + /// + public int Count { get; set; } + + // ============= Navigation Properties ============= + + /// + /// کاربر + /// + public virtual User User { get; set; } + + /// + /// محصول + /// + public virtual DiscountProduct Product { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/FactorDetails.cs b/src/CMSMicroservice.Domain/Entities/FactorDetails.cs index f191184..42799b4 100644 --- a/src/CMSMicroservice.Domain/Entities/FactorDetails.cs +++ b/src/CMSMicroservice.Domain/Entities/FactorDetails.cs @@ -4,7 +4,7 @@ public class FactorDetails : BaseAuditableEntity { public long ProductId { get; set; } //Product Navigation Property - public virtual Products Product { get; set; } + public virtual Product Product { get; set; } public int Count { get; set; } public long UnitPrice { get; set; } public int UnitDiscount { get; set; } diff --git a/src/CMSMicroservice.Domain/Entities/Message/PublicMessage.cs b/src/CMSMicroservice.Domain/Entities/Message/PublicMessage.cs new file mode 100644 index 0000000..cd516d6 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/Message/PublicMessage.cs @@ -0,0 +1,66 @@ +using CMSMicroservice.Domain.Common; +using CMSMicroservice.Domain.Enums; + +namespace CMSMicroservice.Domain.Entities.Message; + +/// +/// پیام‌های عمومی سیستم +/// Admin می‌تواند پیام‌های عمومی برای نمایش در داشبورد کاربران ارسال کند +/// +public class PublicMessage : BaseAuditableEntity +{ + /// + /// عنوان پیام (حداکثر 200 کاراکتر) + /// + public string Title { get; set; } = string.Empty; + + /// + /// محتوای پیام (حداکثر 2000 کاراکتر) + /// + public string Content { get; set; } = string.Empty; + + /// + /// نوع پیام (Announcement, News, Warning, Promotion, SystemUpdate, Event) + /// + public MessageType Type { get; set; } + + /// + /// اولویت پیام (Low, Medium, High, Urgent) + /// + public MessagePriority Priority { get; set; } + + /// + /// وضعیت فعال/غیرفعال + /// + public bool IsActive { get; set; } + + /// + /// تاریخ شروع نمایش پیام + /// + public DateTime StartsAt { get; set; } + + /// + /// تاریخ پایان نمایش پیام + /// + public DateTime ExpiresAt { get; set; } + + /// + /// شناسه Admin ایجادکننده + /// + public long CreatedByUserId { get; set; } + + /// + /// تعداد بازدید (اختیاری - برای آمار) + /// + public int ViewCount { get; set; } + + /// + /// لینک اختیاری (برای اطلاعات بیشتر) + /// + public string? LinkUrl { get; set; } + + /// + /// متن دکمه لینک (مثلاً "اطلاعات بیشتر") + /// + public string? LinkText { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/Order/OrderVAT.cs b/src/CMSMicroservice.Domain/Entities/Order/OrderVAT.cs new file mode 100644 index 0000000..4ccc304 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/Order/OrderVAT.cs @@ -0,0 +1,55 @@ +using CMSMicroservice.Domain.Common; + +namespace CMSMicroservice.Domain.Entities.Order; + +/// +/// مالیات بر ارزش افزوده (VAT) سفارش +/// محاسبه و ثبت مالیات ۹٪ برای سفارشات +/// +public class OrderVAT : BaseAuditableEntity +{ + /// + /// شناسه سفارش + /// + public long OrderId { get; set; } + + /// + /// UserOrder Navigation Property + /// + public virtual UserOrder Order { get; set; } = null!; + + /// + /// نرخ مالیات (معمولاً ۹٪ = 0.09) + /// + public decimal VATRate { get; set; } + + /// + /// مبلغ پایه (قبل از مالیات) + /// + public long BaseAmount { get; set; } + + /// + /// مبلغ مالیات محاسبه شده + /// + public long VATAmount { get; set; } + + /// + /// مبلغ کل (پایه + مالیات) + /// + public long TotalAmount { get; set; } + + /// + /// آیا مالیات پرداخت شده است + /// + public bool IsPaid { get; set; } + + /// + /// تاریخ پرداخت مالیات + /// + public DateTime? PaidAt { get; set; } + + /// + /// یادداشت (اختیاری) + /// + public string? Note { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/Payment/ManualPayment.cs b/src/CMSMicroservice.Domain/Entities/Payment/ManualPayment.cs new file mode 100644 index 0000000..4fd2f8d --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/Payment/ManualPayment.cs @@ -0,0 +1,75 @@ +using CMSMicroservice.Domain.Enums; + +namespace CMSMicroservice.Domain.Entities.Payment; + +/// +/// پرداخت دستی توسط Admin/SuperAdmin +/// برای موارد خاص: واریز نقدی، تسویه حساب، اصلاح خطا +/// +public class ManualPayment : BaseAuditableEntity +{ + /// + /// شناسه کاربری که پرداخت برای او ثبت می‌شود + /// + public long UserId { get; set; } + + /// + /// User Navigation Property + /// + public virtual User User { get; set; } = null!; + + /// + /// مبلغ تراکنش (ریال) + /// + public long Amount { get; set; } + + /// + /// نوع تراکنش دستی + /// + public ManualPaymentType Type { get; set; } + + /// + /// توضیحات (اجباری) + /// + public string Description { get; set; } = string.Empty; + + /// + /// شماره مرجع یا شماره فیش (اختیاری) + /// + public string? ReferenceNumber { get; set; } + + /// + /// وضعیت تایید + /// + public ManualPaymentStatus Status { get; set; } = ManualPaymentStatus.Pending; + + /// + /// شناسه Admin که درخواست را ثبت کرده + /// + public long RequestedBy { get; set; } + + /// + /// شناسه SuperAdmin که تایید/رد کرده (nullable) + /// + public long? ApprovedBy { get; set; } + + /// + /// تاریخ تایید/رد + /// + public DateTime? ApprovedAt { get; set; } + + /// + /// دلیل رد (در صورت رد شدن) + /// + public string? RejectionReason { get; set; } + + /// + /// شناسه تراکنش ایجاد شده (بعد از تایید) + /// + public long? TransactionId { get; set; } + + /// + /// Transaction Navigation Property + /// + public virtual Transaction? Transaction { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/Product.cs b/src/CMSMicroservice.Domain/Entities/Product.cs new file mode 100644 index 0000000..a6c5d8b --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/Product.cs @@ -0,0 +1,42 @@ +namespace CMSMicroservice.Domain.Entities; +//محصول +public class Product : BaseAuditableEntity +{ + public string Title { get; set; } + public string Description { get; set; } + public string ShortInfomation { get; set; } + public string FullInformation { get; set; } + public long Price { get; set; } + public int Discount { get; set; } + public int Rate { get; set; } + public string ImagePath { get; set; } + public string ThumbnailPath { get; set; } + public int SaleCount { get; set; } + public int ViewCount { get; set; } + public int RemainingCount { get; set; } + + // ============= Club Shop Fields ============= + + /// + /// آیا این محصول فقط در فروشگاه باشگاه موجود است + /// + public bool IsClubExclusive { get; set; } + + /// + /// درصد تخفیف باشگاه (0 تا 100) + /// + public int ClubDiscountPercent { get; set; } + + // ============= Navigation Properties ============= + + //UserCarts Collection Navigation Reference + public virtual ICollection UserCarts { get; set; } + //ProductGalleries Collection Navigation Reference + public virtual ICollection ProductGalleries { get; set; } + //FactorDetails Collection Navigation Reference + public virtual ICollection FactorDetails { get; set; } + //ProductCategory Collection Navigation Reference + public virtual ICollection ProductCategories { get; set; } + //ProductTag Collection Navigation Reference + public virtual ICollection ProductTags { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/PruductCategory.cs b/src/CMSMicroservice.Domain/Entities/ProductCategory.cs similarity index 76% rename from src/CMSMicroservice.Domain/Entities/PruductCategory.cs rename to src/CMSMicroservice.Domain/Entities/ProductCategory.cs index 22e8ca5..df923ea 100644 --- a/src/CMSMicroservice.Domain/Entities/PruductCategory.cs +++ b/src/CMSMicroservice.Domain/Entities/ProductCategory.cs @@ -1,11 +1,11 @@ namespace CMSMicroservice.Domain.Entities; //دسته بندی -public class PruductCategory : BaseAuditableEntity +public class ProductCategory : BaseAuditableEntity { //شناسه محصول public long ProductId { get; set; } //Product Navigation Property - public virtual Products Product { get; set; } + public virtual Product Product { get; set; } //شناسه دسته بندی public long CategoryId { get; set; } //Category Navigation Property diff --git a/src/CMSMicroservice.Domain/Entities/ProductGallerys.cs b/src/CMSMicroservice.Domain/Entities/ProductGalleries.cs similarity index 63% rename from src/CMSMicroservice.Domain/Entities/ProductGallerys.cs rename to src/CMSMicroservice.Domain/Entities/ProductGalleries.cs index 64dc71b..b1bd0a7 100644 --- a/src/CMSMicroservice.Domain/Entities/ProductGallerys.cs +++ b/src/CMSMicroservice.Domain/Entities/ProductGalleries.cs @@ -1,10 +1,10 @@ namespace CMSMicroservice.Domain.Entities; -//توکن Otp -public class ProductGallerys : BaseAuditableEntity +//گالری تصاویر محصول +public class ProductGalleries : BaseAuditableEntity { public long ProductImageId { get; set; } //ProductImage Navigation Property - public virtual ProductImages ProductImage { get; set; } + public virtual ProductImage ProductImage { get; set; } public long ProductId { get; set; } //Product Navigation Property public virtual Products Product { get; set; } diff --git a/src/CMSMicroservice.Domain/Entities/ProductGallery.cs b/src/CMSMicroservice.Domain/Entities/ProductGallery.cs new file mode 100644 index 0000000..7f1e5b9 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/ProductGallery.cs @@ -0,0 +1,11 @@ +namespace CMSMicroservice.Domain.Entities; +//گالری تصاویر محصول +public class ProductGallery : BaseAuditableEntity +{ + public long ProductImageId { get; set; } + //ProductImage Navigation Property + public virtual ProductImage ProductImage { get; set; } + public long ProductId { get; set; } + //Product Navigation Property + public virtual Product Product { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/ProductImage.cs b/src/CMSMicroservice.Domain/Entities/ProductImage.cs new file mode 100644 index 0000000..b674b97 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/ProductImage.cs @@ -0,0 +1,10 @@ +namespace CMSMicroservice.Domain.Entities; +//تصاویر محصول +public class ProductImage : BaseAuditableEntity +{ + public string Title { get; set; } + public string ImagePath { get; set; } + public string ImageThumbnailPath { get; set; } + //ProductGalleries Collection Navigation Reference + public virtual ICollection ProductGalleries { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Entities/ProductImages.cs b/src/CMSMicroservice.Domain/Entities/ProductImages.cs index f0bc80f..bc56e57 100644 --- a/src/CMSMicroservice.Domain/Entities/ProductImages.cs +++ b/src/CMSMicroservice.Domain/Entities/ProductImages.cs @@ -5,6 +5,6 @@ public class ProductImages : BaseAuditableEntity public string Title { get; set; } public string ImagePath { get; set; } public string ImageThumbnailPath { get; set; } - //ProductGallerys Collection Navigation Reference - public virtual ICollection ProductGalleryss { get; set; } + //ProductGalleries Collection Navigation Reference + public virtual ICollection ProductGalleries { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/PruductTag.cs b/src/CMSMicroservice.Domain/Entities/ProductTag.cs similarity index 75% rename from src/CMSMicroservice.Domain/Entities/PruductTag.cs rename to src/CMSMicroservice.Domain/Entities/ProductTag.cs index 429a02b..43d8c31 100644 --- a/src/CMSMicroservice.Domain/Entities/PruductTag.cs +++ b/src/CMSMicroservice.Domain/Entities/ProductTag.cs @@ -1,11 +1,11 @@ namespace CMSMicroservice.Domain.Entities; //برچسب محصول -public class PruductTag : BaseAuditableEntity +public class ProductTag : BaseAuditableEntity { //شناسه محصول public long ProductId { get; set; } //Product Navigation Property - public virtual Products Product { get; set; } + public virtual Product Product { get; set; } //شناسه تگ public long TagId { get; set; } //Tag Navigation Property diff --git a/src/CMSMicroservice.Domain/Entities/Products.cs b/src/CMSMicroservice.Domain/Entities/Products.cs index 3a6ba93..24b9d5e 100644 --- a/src/CMSMicroservice.Domain/Entities/Products.cs +++ b/src/CMSMicroservice.Domain/Entities/Products.cs @@ -30,13 +30,13 @@ public class Products : BaseAuditableEntity // ============= Navigation Properties ============= //UserCarts Collection Navigation Reference - public virtual ICollection UserCartss { get; set; } - //ProductGallerys Collection Navigation Reference - public virtual ICollection ProductGalleryss { get; set; } + public virtual ICollection UserCarts { get; set; } + //ProductGalleries Collection Navigation Reference + public virtual ICollection ProductGalleries { get; set; } //FactorDetails Collection Navigation Reference - public virtual ICollection FactorDetailss { get; set; } - //PruductCategory Collection Navigation Reference - public virtual ICollection PruductCategorys { get; set; } - //PruductTag Collection Navigation Reference - public virtual ICollection PruductTags { get; set; } + public virtual ICollection FactorDetails { get; set; } + //ProductCategory Collection Navigation Reference + public virtual ICollection ProductCategories { get; set; } + //ProductTag Collection Navigation Reference + public virtual ICollection ProductTags { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/Tag.cs b/src/CMSMicroservice.Domain/Entities/Tag.cs index 70fa6d4..63757ee 100644 --- a/src/CMSMicroservice.Domain/Entities/Tag.cs +++ b/src/CMSMicroservice.Domain/Entities/Tag.cs @@ -13,5 +13,5 @@ public class Tag : BaseAuditableEntity //ترتیب نمایش public int SortOrder { get; set; } //PruductTag Collection Navigation Reference - public virtual ICollection PruductTags { get; set; } + public virtual ICollection ProductTags { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/Transactions.cs b/src/CMSMicroservice.Domain/Entities/Transaction.cs similarity index 87% rename from src/CMSMicroservice.Domain/Entities/Transactions.cs rename to src/CMSMicroservice.Domain/Entities/Transaction.cs index bed6f9e..0b79812 100644 --- a/src/CMSMicroservice.Domain/Entities/Transactions.cs +++ b/src/CMSMicroservice.Domain/Entities/Transaction.cs @@ -1,8 +1,8 @@ using CMSMicroservice.Domain.Enums; namespace CMSMicroservice.Domain.Entities; -//آدرس کاربر -public class Transactions : BaseAuditableEntity +//تراکنش +public class Transaction : BaseAuditableEntity { public long Amount { get; set; } public string Description { get; set; } diff --git a/src/CMSMicroservice.Domain/Entities/User.cs b/src/CMSMicroservice.Domain/Entities/User.cs index 071df85..3ceb0fd 100644 --- a/src/CMSMicroservice.Domain/Entities/User.cs +++ b/src/CMSMicroservice.Domain/Entities/User.cs @@ -14,10 +14,6 @@ public class User : BaseAuditableEntity public string? NationalCode { get; set; } //آدرس آواتار public string? AvatarPath { get; set; } - //شناسه والد - public long? ParentId { get; set; } - //User Navigation Property - public virtual User? Parent { get; set; } //کد ارجاع public string ReferralCode { get; set; } //موبایل فعال شده؟ @@ -74,13 +70,11 @@ public class User : BaseAuditableEntity // ============= Navigation Properties ============= //UserAddress Collection Navigation Reference - public virtual ICollection UserAddresss { get; set; } + public virtual ICollection UserAddresses { get; set; } //UserRole Collection Navigation Reference public virtual ICollection UserRoles { get; set; } //UserCarts Collection Navigation Reference - public virtual ICollection UserCartss { get; set; } - //User Collection Navigation Reference - public virtual ICollection Users { get; set; } + public virtual ICollection UserCarts { get; set; } //UserContract Collection Navigation Reference public virtual ICollection UserContracts { get; set; } //UserOrder Collection Navigation Reference @@ -99,4 +93,8 @@ public class User : BaseAuditableEntity public virtual ICollection? CommissionPayouts { get; set; } //DayaLoanContract Collection Navigation Reference public virtual ICollection? DayaLoanContracts { get; set; } + //DiscountShoppingCart Collection Navigation Reference (سبد خرید فروشگاه تخفیفی) + public virtual ICollection? DiscountShoppingCarts { get; set; } + //DiscountOrder Collection Navigation Reference (سفارشات فروشگاه تخفیفی) + public virtual ICollection? DiscountOrders { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/UserCarts.cs b/src/CMSMicroservice.Domain/Entities/UserCart.cs similarity index 68% rename from src/CMSMicroservice.Domain/Entities/UserCarts.cs rename to src/CMSMicroservice.Domain/Entities/UserCart.cs index 694e6da..c244316 100644 --- a/src/CMSMicroservice.Domain/Entities/UserCarts.cs +++ b/src/CMSMicroservice.Domain/Entities/UserCart.cs @@ -1,10 +1,10 @@ namespace CMSMicroservice.Domain.Entities; -//آدرس کاربر -public class UserCarts : BaseAuditableEntity +//سبد خرید کاربر +public class UserCart : BaseAuditableEntity { public long ProductId { get; set; } //Product Navigation Property - public virtual Products Product { get; set; } + public virtual Product Product { get; set; } public long UserId { get; set; } //User Navigation Property public virtual User User { get; set; } diff --git a/src/CMSMicroservice.Domain/Entities/UserOrder.cs b/src/CMSMicroservice.Domain/Entities/UserOrder.cs index c8a7a63..2d77eb8 100644 --- a/src/CMSMicroservice.Domain/Entities/UserOrder.cs +++ b/src/CMSMicroservice.Domain/Entities/UserOrder.cs @@ -1,6 +1,5 @@ using CMSMicroservice.Domain.Enums; - -using CMSMicroservice.Domain.Enums; +using CMSMicroservice.Domain.Entities.Order; namespace CMSMicroservice.Domain.Entities; //سفارش کاربر @@ -15,7 +14,7 @@ public class UserOrder : BaseAuditableEntity //شناسه تراکنش public long? TransactionId { get; set; } //Transaction Navigation Property - public virtual Transactions? Transaction { get; set; } + public virtual Transaction? Transaction { get; set; } //وضعیت پرداخت public PaymentStatus PaymentStatus { get; set; } //تاریخ پرداخت @@ -35,6 +34,17 @@ public class UserOrder : BaseAuditableEntity public string? TrackingCode { get; set; } // توضیحات وضعیت ارسال / نکات پستی public string? DeliveryDescription { get; set; } + + /// + /// آیا این سفارش شامل مالیات است + /// + public bool HasVAT { get; set; } + + /// + /// OrderVAT Navigation Property (اطلاعات مالیات) + /// + public virtual OrderVAT? OrderVAT { get; set; } + //FactorDetails Collection Navigation Reference - public virtual ICollection FactorDetailss { get; set; } + public virtual ICollection FactorDetails { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/UserPackagePurchase.cs b/src/CMSMicroservice.Domain/Entities/UserPackagePurchase.cs new file mode 100644 index 0000000..0e9801a --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/UserPackagePurchase.cs @@ -0,0 +1,63 @@ +namespace CMSMicroservice.Domain.Entities; + +/// +/// خرید پکیج توسط کاربر +/// این جدول پشتیبانی از خرید چندین پکیج توسط یک کاربر را فراهم می‌کند +/// +public class UserPackagePurchase : BaseAuditableEntity +{ + /// + /// شناسه کاربر + /// + public long UserId { get; set; } + + /// + /// User Navigation Property + /// + public virtual User User { get; set; } + + /// + /// شناسه پکیج + /// + public long PackageId { get; set; } + + /// + /// Package Navigation Property + /// + public virtual Package Package { get; set; } + + /// + /// نحوه خرید پکیج (دایا، خرید مستقیم) + /// + public PackagePurchaseMethod PurchaseMethod { get; set; } + + /// + /// تاریخ خرید + /// + public DateTime PurchasedAt { get; set; } + + /// + /// مبلغ پرداختی (ریال) + /// + public long Amount { get; set; } + + /// + /// شناسه سفارش مرتبط (اختیاری) + /// + public long? OrderId { get; set; } + + /// + /// UserOrder Navigation Property + /// + public virtual UserOrder? Order { get; set; } + + /// + /// شناسه تراکنش مرتبط (اختیاری) + /// + public long? TransactionId { get; set; } + + /// + /// Transaction Navigation Property + /// + public virtual Transaction? Transaction { get; set; } +} diff --git a/src/CMSMicroservice.Domain/Enums/ConfigurationScope.cs b/src/CMSMicroservice.Domain/Enums/ConfigurationScope.cs index bbce21e..71b7127 100644 --- a/src/CMSMicroservice.Domain/Enums/ConfigurationScope.cs +++ b/src/CMSMicroservice.Domain/Enums/ConfigurationScope.cs @@ -23,5 +23,10 @@ public enum ConfigurationScope /// /// تنظیمات کمیسیون /// - Commission = 3 + Commission = 3, + + /// + /// تنظیمات مالیات بر ارزش افزوده + /// + VAT = 4 } diff --git a/src/CMSMicroservice.Domain/Enums/ManualPaymentStatus.cs b/src/CMSMicroservice.Domain/Enums/ManualPaymentStatus.cs new file mode 100644 index 0000000..609fd1a --- /dev/null +++ b/src/CMSMicroservice.Domain/Enums/ManualPaymentStatus.cs @@ -0,0 +1,27 @@ +namespace CMSMicroservice.Domain.Enums; + +/// +/// وضعیت پرداخت دستی +/// +public enum ManualPaymentStatus +{ + /// + /// در انتظار تایید SuperAdmin + /// + Pending = 0, + + /// + /// تایید شده و اعمال شده + /// + Approved = 1, + + /// + /// رد شده + /// + Rejected = 2, + + /// + /// لغو شده توسط ایجادکننده + /// + Cancelled = 3 +} diff --git a/src/CMSMicroservice.Domain/Enums/ManualPaymentType.cs b/src/CMSMicroservice.Domain/Enums/ManualPaymentType.cs new file mode 100644 index 0000000..ebf551e --- /dev/null +++ b/src/CMSMicroservice.Domain/Enums/ManualPaymentType.cs @@ -0,0 +1,42 @@ +namespace CMSMicroservice.Domain.Enums; + +/// +/// نوع پرداخت دستی +/// +public enum ManualPaymentType +{ + /// + /// واریز نقدی + /// + CashDeposit = 1, + + /// + /// شارژ کیف پول تخفیف + /// + DiscountWalletCharge = 2, + + /// + /// شارژ کیف پول شبکه + /// + NetworkWalletCharge = 3, + + /// + /// تسویه حساب + /// + Settlement = 4, + + /// + /// اصلاح خطا + /// + ErrorCorrection = 5, + + /// + /// بازگشت وجه + /// + Refund = 6, + + /// + /// سایر موارد + /// + Other = 99 +} diff --git a/src/CMSMicroservice.Domain/Enums/MessagePriority.cs b/src/CMSMicroservice.Domain/Enums/MessagePriority.cs new file mode 100644 index 0000000..2bab650 --- /dev/null +++ b/src/CMSMicroservice.Domain/Enums/MessagePriority.cs @@ -0,0 +1,27 @@ +namespace CMSMicroservice.Domain.Enums; + +/// +/// اولویت پیام +/// +public enum MessagePriority +{ + /// + /// کم - 1 + /// + Low = 1, + + /// + /// متوسط - 2 + /// + Medium = 2, + + /// + /// بالا - 3 + /// + High = 3, + + /// + /// فوری - 4 + /// + Urgent = 4 +} diff --git a/src/CMSMicroservice.Domain/Enums/MessageType.cs b/src/CMSMicroservice.Domain/Enums/MessageType.cs new file mode 100644 index 0000000..eaf5872 --- /dev/null +++ b/src/CMSMicroservice.Domain/Enums/MessageType.cs @@ -0,0 +1,37 @@ +namespace CMSMicroservice.Domain.Enums; + +/// +/// نوع پیام عمومی +/// +public enum MessageType +{ + /// + /// اطلاعیه - 1 + /// + Announcement = 1, + + /// + /// اخبار - 2 + /// + News = 2, + + /// + /// هشدار - 3 + /// + Warning = 3, + + /// + /// تبلیغات - 4 + /// + Promotion = 4, + + /// + /// به‌روزرسانی سیستم - 5 + /// + SystemUpdate = 5, + + /// + /// رویداد - 6 + /// + Event = 6 +} diff --git a/src/CMSMicroservice.Domain/Enums/TransactionType.cs b/src/CMSMicroservice.Domain/Enums/TransactionType.cs index 9576f29..6846125 100644 --- a/src/CMSMicroservice.Domain/Enums/TransactionType.cs +++ b/src/CMSMicroservice.Domain/Enums/TransactionType.cs @@ -21,4 +21,9 @@ public enum TransactionType /// شارژ کیف پول تخفیف /// DiscountWalletCharge = 12, + + /// + /// خرید از فروشگاه تخفیف + /// + DiscountShopPurchase = 13, } diff --git a/src/CMSMicroservice.Domain/Events/ClearCartEvent.cs b/src/CMSMicroservice.Domain/Events/ClearCartEvent.cs index 9b4427a..d22cd7b 100644 --- a/src/CMSMicroservice.Domain/Events/ClearCartEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ClearCartEvent.cs @@ -2,10 +2,10 @@ namespace CMSMicroservice.Domain.Events; public class ClearCartEvent : BaseEvent { - public ClearCartEvent(UserCarts item) + public ClearCartEvent(UserCart item) { Item = item; } - public UserCarts Item { get; } + public UserCart Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/DayaLoanApprovedEvent.cs b/src/CMSMicroservice.Domain/Events/DayaLoanApprovedEvent.cs index cb2c3d5..220e06d 100644 --- a/src/CMSMicroservice.Domain/Events/DayaLoanApprovedEvent.cs +++ b/src/CMSMicroservice.Domain/Events/DayaLoanApprovedEvent.cs @@ -2,7 +2,7 @@ namespace CMSMicroservice.Domain.Events; public class DayaLoanApprovedEvent : BaseEvent { - public DayaLoanApprovedEvent(User user, Transactions transaction, string contractNumber) + public DayaLoanApprovedEvent(User user, Transaction transaction, string contractNumber) { User = user; Transaction = transaction; @@ -10,6 +10,6 @@ public class DayaLoanApprovedEvent : BaseEvent } public User User { get; } - public Transactions Transaction { get; } + public Transaction Transaction { get; } public string ContractNumber { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/CreateNewPruductCategoryEvent.cs b/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/CreateNewPruductCategoryEvent.cs new file mode 100644 index 0000000..d1fb4de --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/CreateNewPruductCategoryEvent.cs @@ -0,0 +1,8 @@ +namespace CMSMicroservice.Domain.Events; +public class CreateNewProductCategoryEvent : BaseEvent +{ + public CreateNewProductCategoryEvent(ProductCategory item) + { + } + public ProductCategory Item { get; } +} diff --git a/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/DeletePruductCategoryEvent.cs b/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/DeletePruductCategoryEvent.cs new file mode 100644 index 0000000..50e68df --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/DeletePruductCategoryEvent.cs @@ -0,0 +1,8 @@ +namespace CMSMicroservice.Domain.Events; +public class DeleteProductCategoryEvent : BaseEvent +{ + public DeleteProductCategoryEvent(ProductCategory item) + { + } + public ProductCategory Item { get; } +} diff --git a/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/UpdatePruductCategoryEvent.cs b/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/UpdatePruductCategoryEvent.cs new file mode 100644 index 0000000..968ae8e --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/ProductCategoryEvents/UpdatePruductCategoryEvent.cs @@ -0,0 +1,8 @@ +namespace CMSMicroservice.Domain.Events; +public class UpdateProductCategoryEvent : BaseEvent +{ + public UpdateProductCategoryEvent(ProductCategory item) + { + } + public ProductCategory Item { get; } +} diff --git a/src/CMSMicroservice.Domain/Events/ProductGallerysEvents/CreateNewProductGallerysEvent.cs b/src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/CreateNewProductGallerysEvent.cs similarity index 51% rename from src/CMSMicroservice.Domain/Events/ProductGallerysEvents/CreateNewProductGallerysEvent.cs rename to src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/CreateNewProductGallerysEvent.cs index 75945c9..d3cb298 100644 --- a/src/CMSMicroservice.Domain/Events/ProductGallerysEvents/CreateNewProductGallerysEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/CreateNewProductGallerysEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class CreateNewProductGallerysEvent : BaseEvent { - public CreateNewProductGallerysEvent(ProductGallerys item) + public CreateNewProductGallerysEvent(ProductGallery item) { } - public ProductGallerys Item { get; } + public ProductGallery Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductGallerysEvents/DeleteProductGallerysEvent.cs b/src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/DeleteProductGallerysEvent.cs similarity index 51% rename from src/CMSMicroservice.Domain/Events/ProductGallerysEvents/DeleteProductGallerysEvent.cs rename to src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/DeleteProductGallerysEvent.cs index 173b662..8f3682e 100644 --- a/src/CMSMicroservice.Domain/Events/ProductGallerysEvents/DeleteProductGallerysEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/DeleteProductGallerysEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class DeleteProductGallerysEvent : BaseEvent { - public DeleteProductGallerysEvent(ProductGallerys item) + public DeleteProductGallerysEvent(ProductGallery item) { } - public ProductGallerys Item { get; } + public ProductGallery Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductGallerysEvents/UpdateProductGallerysEvent.cs b/src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/UpdateProductGallerysEvent.cs similarity index 51% rename from src/CMSMicroservice.Domain/Events/ProductGallerysEvents/UpdateProductGallerysEvent.cs rename to src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/UpdateProductGallerysEvent.cs index cda7605..1c1961c 100644 --- a/src/CMSMicroservice.Domain/Events/ProductGallerysEvents/UpdateProductGallerysEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductGalleriesEvents/UpdateProductGallerysEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class UpdateProductGallerysEvent : BaseEvent { - public UpdateProductGallerysEvent(ProductGallerys item) + public UpdateProductGallerysEvent(ProductGallery item) { } - public ProductGallerys Item { get; } + public ProductGallery Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductImagesEvents/CreateNewProductImagesEvent.cs b/src/CMSMicroservice.Domain/Events/ProductImagesEvents/CreateNewProductImagesEvent.cs index 4e58912..c6e99a4 100644 --- a/src/CMSMicroservice.Domain/Events/ProductImagesEvents/CreateNewProductImagesEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductImagesEvents/CreateNewProductImagesEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class CreateNewProductImagesEvent : BaseEvent { - public CreateNewProductImagesEvent(ProductImages item) + public CreateNewProductImagesEvent(ProductImage item) { } - public ProductImages Item { get; } + public ProductImage Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductImagesEvents/DeleteProductImagesEvent.cs b/src/CMSMicroservice.Domain/Events/ProductImagesEvents/DeleteProductImagesEvent.cs index 504b0dd..6c006fe 100644 --- a/src/CMSMicroservice.Domain/Events/ProductImagesEvents/DeleteProductImagesEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductImagesEvents/DeleteProductImagesEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class DeleteProductImagesEvent : BaseEvent { - public DeleteProductImagesEvent(ProductImages item) + public DeleteProductImagesEvent(ProductImage item) { } - public ProductImages Item { get; } + public ProductImage Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductImagesEvents/UpdateProductImagesEvent.cs b/src/CMSMicroservice.Domain/Events/ProductImagesEvents/UpdateProductImagesEvent.cs index bcad21c..5b602dd 100644 --- a/src/CMSMicroservice.Domain/Events/ProductImagesEvents/UpdateProductImagesEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductImagesEvents/UpdateProductImagesEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class UpdateProductImagesEvent : BaseEvent { - public UpdateProductImagesEvent(ProductImages item) + public UpdateProductImagesEvent(ProductImage item) { } - public ProductImages Item { get; } + public ProductImage Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductTagEvents/CreateNewPruductTagEvent.cs b/src/CMSMicroservice.Domain/Events/ProductTagEvents/CreateNewPruductTagEvent.cs new file mode 100644 index 0000000..257d9a7 --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/ProductTagEvents/CreateNewPruductTagEvent.cs @@ -0,0 +1,10 @@ +namespace CMSMicroservice.Domain.Events; +public class CreateNewProductTagEvent : BaseEvent +{ + public CreateNewProductTagEvent(ProductTag item) + { + Item = item; + } + public ProductTag Item { get; } +} + diff --git a/src/CMSMicroservice.Domain/Events/ProductTagEvents/DeletePruductTagEvent.cs b/src/CMSMicroservice.Domain/Events/ProductTagEvents/DeletePruductTagEvent.cs new file mode 100644 index 0000000..e4bc3c2 --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/ProductTagEvents/DeletePruductTagEvent.cs @@ -0,0 +1,10 @@ +namespace CMSMicroservice.Domain.Events; +public class DeleteProductTagEvent : BaseEvent +{ + public DeleteProductTagEvent(ProductTag item) + { + Item = item; + } + public ProductTag Item { get; } +} + diff --git a/src/CMSMicroservice.Domain/Events/ProductTagEvents/UpdatePruductTagEvent.cs b/src/CMSMicroservice.Domain/Events/ProductTagEvents/UpdatePruductTagEvent.cs new file mode 100644 index 0000000..9ba49c4 --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/ProductTagEvents/UpdatePruductTagEvent.cs @@ -0,0 +1,10 @@ +namespace CMSMicroservice.Domain.Events; +public class UpdateProductTagEvent : BaseEvent +{ + public UpdateProductTagEvent(ProductTag item) + { + Item = item; + } + public ProductTag Item { get; } +} + diff --git a/src/CMSMicroservice.Domain/Events/ProductsEvents/CreateNewProductsEvent.cs b/src/CMSMicroservice.Domain/Events/ProductsEvents/CreateNewProductsEvent.cs index f930879..a6ab253 100644 --- a/src/CMSMicroservice.Domain/Events/ProductsEvents/CreateNewProductsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductsEvents/CreateNewProductsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class CreateNewProductsEvent : BaseEvent { - public CreateNewProductsEvent(Products item) + public CreateNewProductsEvent(Product item) { } - public Products Item { get; } + public Product Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductsEvents/DeleteProductsEvent.cs b/src/CMSMicroservice.Domain/Events/ProductsEvents/DeleteProductsEvent.cs index f172331..5a31b24 100644 --- a/src/CMSMicroservice.Domain/Events/ProductsEvents/DeleteProductsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductsEvents/DeleteProductsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class DeleteProductsEvent : BaseEvent { - public DeleteProductsEvent(Products item) + public DeleteProductsEvent(Product item) { } - public Products Item { get; } + public Product Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/ProductsEvents/UpdateProductsEvent.cs b/src/CMSMicroservice.Domain/Events/ProductsEvents/UpdateProductsEvent.cs index 9c8b500..defc8d5 100644 --- a/src/CMSMicroservice.Domain/Events/ProductsEvents/UpdateProductsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/ProductsEvents/UpdateProductsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class UpdateProductsEvent : BaseEvent { - public UpdateProductsEvent(Products item) + public UpdateProductsEvent(Product item) { } - public Products Item { get; } + public Product Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/CreateNewPruductCategoryEvent.cs b/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/CreateNewPruductCategoryEvent.cs deleted file mode 100644 index 1697673..0000000 --- a/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/CreateNewPruductCategoryEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class CreateNewPruductCategoryEvent : BaseEvent -{ - public CreateNewPruductCategoryEvent(PruductCategory item) - { - } - public PruductCategory Item { get; } -} diff --git a/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/DeletePruductCategoryEvent.cs b/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/DeletePruductCategoryEvent.cs deleted file mode 100644 index cf5e078..0000000 --- a/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/DeletePruductCategoryEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class DeletePruductCategoryEvent : BaseEvent -{ - public DeletePruductCategoryEvent(PruductCategory item) - { - } - public PruductCategory Item { get; } -} diff --git a/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/UpdatePruductCategoryEvent.cs b/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/UpdatePruductCategoryEvent.cs deleted file mode 100644 index 5604531..0000000 --- a/src/CMSMicroservice.Domain/Events/PruductCategoryEvents/UpdatePruductCategoryEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class UpdatePruductCategoryEvent : BaseEvent -{ - public UpdatePruductCategoryEvent(PruductCategory item) - { - } - public PruductCategory Item { get; } -} diff --git a/src/CMSMicroservice.Domain/Events/PruductTagEvents/CreateNewPruductTagEvent.cs b/src/CMSMicroservice.Domain/Events/PruductTagEvents/CreateNewPruductTagEvent.cs deleted file mode 100644 index 567f574..0000000 --- a/src/CMSMicroservice.Domain/Events/PruductTagEvents/CreateNewPruductTagEvent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class CreateNewPruductTagEvent : BaseEvent -{ - public CreateNewPruductTagEvent(PruductTag item) - { - Item = item; - } - public PruductTag Item { get; } -} - diff --git a/src/CMSMicroservice.Domain/Events/PruductTagEvents/DeletePruductTagEvent.cs b/src/CMSMicroservice.Domain/Events/PruductTagEvents/DeletePruductTagEvent.cs deleted file mode 100644 index 63f9f84..0000000 --- a/src/CMSMicroservice.Domain/Events/PruductTagEvents/DeletePruductTagEvent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class DeletePruductTagEvent : BaseEvent -{ - public DeletePruductTagEvent(PruductTag item) - { - Item = item; - } - public PruductTag Item { get; } -} - diff --git a/src/CMSMicroservice.Domain/Events/PruductTagEvents/UpdatePruductTagEvent.cs b/src/CMSMicroservice.Domain/Events/PruductTagEvents/UpdatePruductTagEvent.cs deleted file mode 100644 index 6405480..0000000 --- a/src/CMSMicroservice.Domain/Events/PruductTagEvents/UpdatePruductTagEvent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class UpdatePruductTagEvent : BaseEvent -{ - public UpdatePruductTagEvent(PruductTag item) - { - Item = item; - } - public PruductTag Item { get; } -} - diff --git a/src/CMSMicroservice.Domain/Events/RefundTransactionEvent.cs b/src/CMSMicroservice.Domain/Events/RefundTransactionEvent.cs index 265b03f..6c8256e 100644 --- a/src/CMSMicroservice.Domain/Events/RefundTransactionEvent.cs +++ b/src/CMSMicroservice.Domain/Events/RefundTransactionEvent.cs @@ -2,12 +2,12 @@ namespace CMSMicroservice.Domain.Events; public class RefundTransactionEvent : BaseEvent { - public RefundTransactionEvent(Transactions refundTransaction, Transactions originalTransaction) + public RefundTransactionEvent(Transaction refundTransaction, Transaction originalTransaction) { RefundTransaction = refundTransaction; OriginalTransaction = originalTransaction; } - public Transactions RefundTransaction { get; } - public Transactions OriginalTransaction { get; } + public Transaction RefundTransaction { get; } + public Transaction OriginalTransaction { get; } } diff --git a/src/CMSMicroservice.Domain/Events/TransactionsEvents/CreateNewTransactionsEvent.cs b/src/CMSMicroservice.Domain/Events/TransactionsEvents/CreateNewTransactionsEvent.cs index 5b8aac3..b34857b 100644 --- a/src/CMSMicroservice.Domain/Events/TransactionsEvents/CreateNewTransactionsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/TransactionsEvents/CreateNewTransactionsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class CreateNewTransactionsEvent : BaseEvent { - public CreateNewTransactionsEvent(Transactions item) + public CreateNewTransactionsEvent(Transaction item) { } - public Transactions Item { get; } + public Transaction Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/TransactionsEvents/DeleteTransactionsEvent.cs b/src/CMSMicroservice.Domain/Events/TransactionsEvents/DeleteTransactionsEvent.cs index a61cd0d..864e186 100644 --- a/src/CMSMicroservice.Domain/Events/TransactionsEvents/DeleteTransactionsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/TransactionsEvents/DeleteTransactionsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class DeleteTransactionsEvent : BaseEvent { - public DeleteTransactionsEvent(Transactions item) + public DeleteTransactionsEvent(Transaction item) { } - public Transactions Item { get; } + public Transaction Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/TransactionsEvents/UpdateTransactionsEvent.cs b/src/CMSMicroservice.Domain/Events/TransactionsEvents/UpdateTransactionsEvent.cs index bc8edeb..cfd44bd 100644 --- a/src/CMSMicroservice.Domain/Events/TransactionsEvents/UpdateTransactionsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/TransactionsEvents/UpdateTransactionsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class UpdateTransactionsEvent : BaseEvent { - public UpdateTransactionsEvent(Transactions item) + public UpdateTransactionsEvent(Transaction item) { } - public Transactions Item { get; } + public Transaction Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/UserCartsEvents/CreateNewUserCartsEvent.cs b/src/CMSMicroservice.Domain/Events/UserCartsEvents/CreateNewUserCartsEvent.cs index a1ff68c..e1e8807 100644 --- a/src/CMSMicroservice.Domain/Events/UserCartsEvents/CreateNewUserCartsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/UserCartsEvents/CreateNewUserCartsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class CreateNewUserCartsEvent : BaseEvent { - public CreateNewUserCartsEvent(UserCarts item) + public CreateNewUserCartsEvent(UserCart item) { } - public UserCarts Item { get; } + public UserCart Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/UserCartsEvents/DeleteUserCartsEvent.cs b/src/CMSMicroservice.Domain/Events/UserCartsEvents/DeleteUserCartsEvent.cs index 8c07ed1..275168f 100644 --- a/src/CMSMicroservice.Domain/Events/UserCartsEvents/DeleteUserCartsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/UserCartsEvents/DeleteUserCartsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class DeleteUserCartsEvent : BaseEvent { - public DeleteUserCartsEvent(UserCarts item) + public DeleteUserCartsEvent(UserCart item) { } - public UserCarts Item { get; } + public UserCart Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/UserCartsEvents/UpdateUserCartsEvent.cs b/src/CMSMicroservice.Domain/Events/UserCartsEvents/UpdateUserCartsEvent.cs index a63d50c..1c974c5 100644 --- a/src/CMSMicroservice.Domain/Events/UserCartsEvents/UpdateUserCartsEvent.cs +++ b/src/CMSMicroservice.Domain/Events/UserCartsEvents/UpdateUserCartsEvent.cs @@ -1,8 +1,8 @@ namespace CMSMicroservice.Domain.Events; public class UpdateUserCartsEvent : BaseEvent { - public UpdateUserCartsEvent(UserCarts item) + public UpdateUserCartsEvent(UserCart item) { } - public UserCarts Item { get; } + public UserCart Item { get; } } diff --git a/src/CMSMicroservice.Domain/Events/VerifyTransactionEvent.cs b/src/CMSMicroservice.Domain/Events/VerifyTransactionEvent.cs index 21f7154..a9f9b5c 100644 --- a/src/CMSMicroservice.Domain/Events/VerifyTransactionEvent.cs +++ b/src/CMSMicroservice.Domain/Events/VerifyTransactionEvent.cs @@ -2,10 +2,10 @@ namespace CMSMicroservice.Domain.Events; public class VerifyTransactionEvent : BaseEvent { - public VerifyTransactionEvent(Transactions item) + public VerifyTransactionEvent(Transaction item) { Item = item; } - public Transactions Item { get; } + public Transaction Item { get; } } diff --git a/src/CMSMicroservice.Infrastructure/ConfigureServices.cs b/src/CMSMicroservice.Infrastructure/ConfigureServices.cs index 0f002cf..44dacb5 100644 --- a/src/CMSMicroservice.Infrastructure/ConfigureServices.cs +++ b/src/CMSMicroservice.Infrastructure/ConfigureServices.cs @@ -34,28 +34,14 @@ public static class ConfigureServices services.AddScoped(); services.AddScoped(); // Mock - جایگزین با Real برای Production - // Payment Gateway Service - برای Development از Mock استفاده می‌شود - // برای Production یکی از سرویس‌های واقعی را فعال کنید + // Payment Gateway Service - فقط Daya (درگاه اینترنتی از Gateway میاد نه CMS) var useRealPaymentGateway = configuration.GetValue("UseRealPaymentGateway", false); if (useRealPaymentGateway) { - var paymentProvider = configuration.GetValue("PaymentProvider", "BankMellat"); - - if (paymentProvider == "Daya") - { - services.AddHttpClient() - .SetHandlerLifetime(TimeSpan.FromMinutes(5)); - } - else if (paymentProvider == "BankMellat") - { - services.AddHttpClient() - .SetHandlerLifetime(TimeSpan.FromMinutes(5)); - } - else - { - throw new InvalidOperationException($"Invalid PaymentProvider: {paymentProvider}. Valid values: Daya, BankMellat"); - } + // فقط Daya برای پرداخت به کاربران (Payout) + services.AddHttpClient() + .SetHandlerLifetime(TimeSpan.FromMinutes(5)); } else { diff --git a/src/CMSMicroservice.Infrastructure/Data/Seeding/NetworkParentIdMigrationSeeder.cs b/src/CMSMicroservice.Infrastructure/Data/Seeding/NetworkParentIdMigrationSeeder.cs index ed348fd..7640d44 100644 --- a/src/CMSMicroservice.Infrastructure/Data/Seeding/NetworkParentIdMigrationSeeder.cs +++ b/src/CMSMicroservice.Infrastructure/Data/Seeding/NetworkParentIdMigrationSeeder.cs @@ -8,7 +8,7 @@ namespace CMSMicroservice.Infrastructure.Data.Seeding; /// /// Seeder for migrating existing User.ParentId to User.NetworkParentId -/// این Seeder فقط یک بار اجرا می‌شود و داده‌های قدیمی را به ساختار Binary Tree جدید منتقل می‌کند +/// NOTE: ParentId has been removed from User entity, so this seeder is now obsolete /// public class NetworkParentIdMigrationSeeder { @@ -25,147 +25,12 @@ public class NetworkParentIdMigrationSeeder public async Task SeedAsync(CancellationToken cancellationToken = default) { - _logger.LogInformation("=== Starting ParentId → NetworkParentId Migration ==="); - - // Step 1: Validation - Check if migration already done - var alreadyMigrated = await _context.Users - .Where(u => u.ParentId != null && u.NetworkParentId != null) - .AnyAsync(cancellationToken); - - if (alreadyMigrated) - { - _logger.LogWarning("⚠️ Migration already completed! Skipping..."); - return; - } - - // Step 2: Find users with ParentId but no NetworkParentId - var usersToMigrate = await _context.Users - .Where(u => u.ParentId != null && u.NetworkParentId == null) - .OrderBy(u => u.Id) - .ToListAsync(cancellationToken); - - if (usersToMigrate.Count == 0) - { - _logger.LogInformation("✅ No users to migrate. All done!"); - return; - } - - _logger.LogInformation($"📊 Found {usersToMigrate.Count} users to migrate"); - - // Step 3: Group by ParentId to check binary tree constraint - var parentGroups = usersToMigrate.GroupBy(u => u.ParentId); - - int migratedCount = 0; - int skippedCount = 0; - - foreach (var group in parentGroups) - { - var parentId = group.Key; - var children = group.OrderBy(u => u.Id).ToList(); // ترتیب بر اساس Id - - if (children.Count > 2) - { - _logger.LogWarning( - "⚠️ Parent {ParentId} has {Count} children! Binary tree allows max 2. Taking first 2...", - parentId, children.Count); - - children = children.Take(2).ToList(); - skippedCount += (group.Count() - 2); - } - - // Assign NetworkParentId and LegPosition - for (int i = 0; i < children.Count && i < 2; i++) - { - var child = children[i]; - child.NetworkParentId = parentId; - child.LegPosition = i == 0 ? NetworkLeg.Left : NetworkLeg.Right; - - _logger.LogDebug( - "✅ Migrated User {UserId}: Parent={ParentId}, Leg={Leg}", - child.Id, parentId, child.LegPosition); - - migratedCount++; - } - } - - // Step 4: Save changes - await _context.SaveChangesAsync(cancellationToken); - - _logger.LogInformation( - "✅ Migration Completed! Migrated={Migrated}, Skipped={Skipped}", - migratedCount, skippedCount); - - // Step 5: Post-Migration Validation - await ValidateMigrationAsync(cancellationToken); - } - - private async Task ValidateMigrationAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("🔍 Validating Migration..."); - - // Check 1: Orphaned nodes (NetworkParent doesn't exist) - var orphanedUsers = await _context.Users - .Where(u => u.NetworkParentId != null && - !_context.Users.Any(p => p.Id == u.NetworkParentId)) - .Select(u => new { u.Id, u.NetworkParentId }) - .ToListAsync(cancellationToken); - - if (orphanedUsers.Any()) - { - _logger.LogError( - "❌ Found {Count} orphaned users (NetworkParent doesn't exist): {Ids}", - orphanedUsers.Count, - string.Join(", ", orphanedUsers.Select(u => u.Id))); - } - - // Check 2: Binary tree violation (more than 2 children per parent) - var parentsWithTooManyChildren = await _context.Users - .Where(u => u.NetworkParentId != null) - .GroupBy(u => u.NetworkParentId) - .Select(g => new { ParentId = g.Key, Count = g.Count() }) - .Where(x => x.Count > 2) - .ToListAsync(cancellationToken); - - if (parentsWithTooManyChildren.Any()) - { - _logger.LogError( - "❌ Binary tree violation! {Count} parents have more than 2 children", - parentsWithTooManyChildren.Count); - - foreach (var parent in parentsWithTooManyChildren) - { - _logger.LogError(" Parent {ParentId} has {Count} children", parent.ParentId, parent.Count); - } - } - - // Check 3: Statistics - var stats = await _context.Users - .GroupBy(u => 1) - .Select(g => new - { - TotalUsers = g.Count(), - UsersWithNetworkParent = g.Count(u => u.NetworkParentId != null), - LeftChildren = g.Count(u => u.LegPosition == NetworkLeg.Left), - RightChildren = g.Count(u => u.LegPosition == NetworkLeg.Right) - }) - .FirstOrDefaultAsync(cancellationToken); - - if (stats != null) - { - _logger.LogInformation("📊 Migration Statistics:"); - _logger.LogInformation(" Total Users: {Total}", stats.TotalUsers); - _logger.LogInformation(" Users with NetworkParent: {Count}", stats.UsersWithNetworkParent); - _logger.LogInformation(" Left Children: {Count}", stats.LeftChildren); - _logger.LogInformation(" Right Children: {Count}", stats.RightChildren); - } - - if (!orphanedUsers.Any() && !parentsWithTooManyChildren.Any()) - { - _logger.LogInformation("✅ Validation Passed! Binary tree is intact."); - } - else - { - _logger.LogError("❌ Validation Failed! Please fix issues manually."); - } + _logger.LogInformation("=== NetworkParentIdMigrationSeeder: ParentId Removed ==="); + + // ParentId has been removed from User entity + // This seeder is no longer necessary + _logger.LogInformation("ParentId field has been removed. Migration is obsolete."); + + await Task.CompletedTask; } } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs index a0dbb3b..ebc1e6c 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs @@ -1,6 +1,10 @@ using System.Reflection; using CMSMicroservice.Application.Common.Interfaces; using CMSMicroservice.Domain.Entities; +using CMSMicroservice.Domain.Entities.Payment; +using CMSMicroservice.Domain.Entities.Message; +using CMSMicroservice.Domain.Entities.Order; +using CMSMicroservice.Domain.Entities.DiscountShop; using CMSMicroservice.Infrastructure.Persistence.Interceptors; using MediatR; using Microsoft.EntityFrameworkCore; @@ -43,29 +47,37 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext return await base.SaveChangesAsync(cancellationToken); } - public DbSet UserAddresss => Set(); + public DbSet UserAddresses => Set(); public DbSet Packages => Set(); public DbSet Roles => Set(); - public DbSet Categorys => Set(); + public DbSet Categories => Set(); public DbSet UserRoles => Set(); - public DbSet UserCartss => Set(); - public DbSet ProductGalleryss => Set(); - public DbSet FactorDetailss => Set(); - public DbSet Productss => Set(); - public DbSet ProductImagess => Set(); + public DbSet UserCarts => Set(); + public DbSet ProductGalleries => Set(); + public DbSet FactorDetails => Set(); + public DbSet Products => Set(); + public DbSet ProductImages => Set(); public DbSet Users => Set(); public DbSet OtpTokens => Set(); public DbSet Contracts => Set(); public DbSet UserContracts => Set(); public DbSet Tags => Set(); - public DbSet PruductCategorys => Set(); - public DbSet PruductTags => Set(); - public DbSet Transactionss => Set(); + public DbSet ProductCategories => Set(); + public DbSet ProductTags => Set(); + public DbSet Transactions => Set(); public DbSet UserOrders => Set(); + public DbSet OrderVATs => Set(); + public DbSet UserPackagePurchases => Set(); public DbSet UserWallets => Set(); public DbSet UserWalletChangeLogs => Set(); public DbSet DayaLoanContracts => Set(); + // Payment + public DbSet ManualPayments => Set(); + + // Message + public DbSet PublicMessages => Set(); + // ============= Network Club System DbSets ============= // Configuration @@ -87,4 +99,12 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext public DbSet UserCommissionPayouts => Set(); public DbSet CommissionPayoutHistories => Set(); public DbSet WorkerExecutionLogs => Set(); + + // ============= Discount Shop DbSets ============= + public DbSet DiscountProducts => Set(); + public DbSet DiscountCategories => Set(); + public DbSet DiscountProductCategories => Set(); + public DbSet DiscountShoppingCarts => Set(); + public DbSet DiscountOrders => Set(); + public DbSet DiscountOrderDetails => Set(); } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs index 9c9ea87..7563d18 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs @@ -111,6 +111,14 @@ public class ApplicationDbContextInitialiser Scope = ConfigurationScope.Club, IsActive = true }, + new SystemConfiguration + { + Key = "Club.MembershipGiftValue", + Value = "25200000", + Description = "مبلغ هدیه حق عضویت باشگاه (ریال) - این مبلغ از کیف پول کم نمی‌شود", + Scope = ConfigurationScope.Club, + IsActive = true + }, // System Configuration new SystemConfiguration diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/CategoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/CategoryConfiguration.cs index c43146f..90a77a5 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/CategoryConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/CategoryConfiguration.cs @@ -17,7 +17,7 @@ public class CategoryConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.ImagePath).IsRequired(false); builder .HasOne(entity => entity.Parent) - .WithMany(entity => entity.Categorys) + .WithMany(entity => entity.Categories) .HasForeignKey(entity => entity.ParentId) .IsRequired(false); builder.Property(entity => entity.IsActive).IsRequired(true); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipConfiguration.cs index ebd6605..5b21622 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipConfiguration.cs @@ -20,6 +20,7 @@ public class ClubMembershipConfiguration : IEntityTypeConfiguration entity.IsActive).IsRequired(); builder.Property(entity => entity.ActivatedAt).IsRequired(false); builder.Property(entity => entity.InitialContribution).IsRequired(); + builder.Property(entity => entity.GiftValue).IsRequired(); builder.Property(entity => entity.TotalEarned).IsRequired(); // رابطه یک‌به‌یک با User diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountCategoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountCategoryConfiguration.cs new file mode 100644 index 0000000..d8c919e --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountCategoryConfiguration.cs @@ -0,0 +1,45 @@ +using CMSMicroservice.Domain.Entities.DiscountShop; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations.DiscountShop; + +/// +/// تنظیمات EF Core برای دسته‌بندی فروشگاه تخفیفی +/// +public class DiscountCategoryConfiguration : 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.Name) + .IsRequired() + .HasMaxLength(100); + + builder.Property(entity => entity.Title) + .IsRequired() + .HasMaxLength(200); + + builder.Property(entity => entity.Description) + .HasMaxLength(1000); + + builder.Property(entity => entity.ImagePath) + .HasMaxLength(500); + + builder.Property(entity => entity.IsActive) + .IsRequired() + .HasDefaultValue(true); + + // Self-referencing relationship for parent/child categories + builder + .HasOne(entity => entity.ParentCategory) + .WithMany(entity => entity.ChildCategories) + .HasForeignKey(entity => entity.ParentCategoryId) + .OnDelete(DeleteBehavior.Restrict); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountOrderConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountOrderConfiguration.cs new file mode 100644 index 0000000..8b6ebeb --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountOrderConfiguration.cs @@ -0,0 +1,56 @@ +using CMSMicroservice.Domain.Entities.DiscountShop; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations.DiscountShop; + +/// +/// تنظیمات EF Core برای سفارش فروشگاه تخفیفی +/// +public class DiscountOrderConfiguration : 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.UserId).IsRequired(); + builder.Property(entity => entity.TotalAmount).IsRequired(); + builder.Property(entity => entity.DiscountBalanceUsed).IsRequired(); + builder.Property(entity => entity.GatewayAmountPaid).IsRequired(); + builder.Property(entity => entity.VatAmount).IsRequired(); + builder.Property(entity => entity.PaymentStatus).IsRequired(); + builder.Property(entity => entity.UserAddressId).IsRequired(); + builder.Property(entity => entity.DeliveryStatus).IsRequired(); + + builder.Property(entity => entity.TrackingCode) + .HasMaxLength(100); + + builder.Property(entity => entity.DeliveryDescription) + .HasMaxLength(500); + + // Relationship: User -> Orders + builder + .HasOne(entity => entity.User) + .WithMany(entity => entity.DiscountOrders) + .HasForeignKey(entity => entity.UserId) + .OnDelete(DeleteBehavior.Restrict); + + // Relationship: Transaction (nullable) + builder + .HasOne(entity => entity.Transaction) + .WithMany() + .HasForeignKey(entity => entity.TransactionId) + .OnDelete(DeleteBehavior.Restrict); + + // Relationship: UserAddress + builder + .HasOne(entity => entity.UserAddress) + .WithMany() + .HasForeignKey(entity => entity.UserAddressId) + .OnDelete(DeleteBehavior.Restrict); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountOrderDetailConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountOrderDetailConfiguration.cs new file mode 100644 index 0000000..e64b5bd --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountOrderDetailConfiguration.cs @@ -0,0 +1,42 @@ +using CMSMicroservice.Domain.Entities.DiscountShop; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations.DiscountShop; + +/// +/// تنظیمات EF Core برای جزئیات سفارش فروشگاه تخفیفی +/// +public class DiscountOrderDetailConfiguration : 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.DiscountOrderId).IsRequired(); + builder.Property(entity => entity.ProductId).IsRequired(); + builder.Property(entity => entity.Count).IsRequired(); + builder.Property(entity => entity.UnitPrice).IsRequired(); + builder.Property(entity => entity.DiscountPercentUsed).IsRequired(); + builder.Property(entity => entity.DiscountAmount).IsRequired(); + builder.Property(entity => entity.FinalPrice).IsRequired(); + + // Relationship: Order -> OrderDetails + builder + .HasOne(entity => entity.DiscountOrder) + .WithMany(entity => entity.OrderDetails) + .HasForeignKey(entity => entity.DiscountOrderId) + .OnDelete(DeleteBehavior.Cascade); + + // Relationship: Product + builder + .HasOne(entity => entity.Product) + .WithMany(entity => entity.OrderDetails) + .HasForeignKey(entity => entity.ProductId) + .OnDelete(DeleteBehavior.Restrict); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductCategoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductCategoryConfiguration.cs new file mode 100644 index 0000000..28a6535 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductCategoryConfiguration.cs @@ -0,0 +1,39 @@ +using CMSMicroservice.Domain.Entities.DiscountShop; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations.DiscountShop; + +/// +/// تنظیمات EF Core برای رابطه محصول و دسته‌بندی +/// +public class DiscountProductCategoryConfiguration : 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.ProductId).IsRequired(); + builder.Property(entity => entity.CategoryId).IsRequired(); + + // Many-to-Many relationship: Product <-> Category + builder + .HasOne(entity => entity.Product) + .WithMany(entity => entity.ProductCategories) + .HasForeignKey(entity => entity.ProductId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasOne(entity => entity.Category) + .WithMany(entity => entity.ProductCategories) + .HasForeignKey(entity => entity.CategoryId) + .OnDelete(DeleteBehavior.Cascade); + + // Unique constraint: یک محصول فقط یکبار در یک دسته + builder.HasIndex(e => new { e.ProductId, e.CategoryId }).IsUnique(); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductConfiguration.cs new file mode 100644 index 0000000..dae4d65 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductConfiguration.cs @@ -0,0 +1,50 @@ +using CMSMicroservice.Domain.Entities.DiscountShop; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations.DiscountShop; + +/// +/// تنظیمات EF Core برای محصول فروشگاه تخفیفی +/// +public class DiscountProductConfiguration : 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() + .HasMaxLength(200); + + builder.Property(entity => entity.ShortInfomation) + .IsRequired() + .HasMaxLength(500); + + builder.Property(entity => entity.FullInformation) + .IsRequired() + .HasMaxLength(2000); + + builder.Property(entity => entity.Price) + .IsRequired(); + + builder.Property(entity => entity.MaxDiscountPercent) + .IsRequired(); + + builder.Property(entity => entity.ImagePath) + .IsRequired() + .HasMaxLength(500); + + builder.Property(entity => entity.ThumbnailPath) + .IsRequired() + .HasMaxLength(500); + + builder.Property(entity => entity.IsActive) + .IsRequired() + .HasDefaultValue(true); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountShoppingCartConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountShoppingCartConfiguration.cs new file mode 100644 index 0000000..0b18783 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountShoppingCartConfiguration.cs @@ -0,0 +1,41 @@ +using CMSMicroservice.Domain.Entities.DiscountShop; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations.DiscountShop; + +/// +/// تنظیمات EF Core برای سبد خرید فروشگاه تخفیفی +/// +public class DiscountShoppingCartConfiguration : 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.UserId).IsRequired(); + builder.Property(entity => entity.ProductId).IsRequired(); + builder.Property(entity => entity.Count).IsRequired(); + + // Relationship: User -> ShoppingCarts + builder + .HasOne(entity => entity.User) + .WithMany(entity => entity.DiscountShoppingCarts) + .HasForeignKey(entity => entity.UserId) + .OnDelete(DeleteBehavior.Cascade); + + // Relationship: Product -> ShoppingCarts + builder + .HasOne(entity => entity.Product) + .WithMany(entity => entity.ShoppingCarts) + .HasForeignKey(entity => entity.ProductId) + .OnDelete(DeleteBehavior.Cascade); + + // Unique constraint: کاربر فقط یک ردیف برای هر محصول در سبد دارد + builder.HasIndex(e => new { e.UserId, e.ProductId }).IsUnique(); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/FactorDetailsConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/FactorDetailsConfiguration.cs index 6401a07..0d17de3 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/FactorDetailsConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/FactorDetailsConfiguration.cs @@ -13,7 +13,7 @@ public class FactorDetailsConfiguration : IEntityTypeConfiguration entity.Id).UseIdentityColumn(); builder .HasOne(entity => entity.Product) - .WithMany(entity => entity.FactorDetailss) + .WithMany(entity => entity.FactorDetails) .HasForeignKey(entity => entity.ProductId) .IsRequired(true); builder.Property(entity => entity.Count).IsRequired(true); @@ -21,7 +21,7 @@ public class FactorDetailsConfiguration : IEntityTypeConfiguration entity.UnitDiscount).IsRequired(true); builder .HasOne(entity => entity.Order) - .WithMany(entity => entity.FactorDetailss) + .WithMany(entity => entity.FactorDetails) .HasForeignKey(entity => entity.OrderId) .IsRequired(true); builder.Property(entity => entity.UnitDiscountPrice).IsRequired(true); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ManualPaymentConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ManualPaymentConfiguration.cs new file mode 100644 index 0000000..b93e304 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ManualPaymentConfiguration.cs @@ -0,0 +1,65 @@ +using CMSMicroservice.Domain.Entities.Payment; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +public class ManualPaymentConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("ManualPayments"); + + builder.HasKey(x => x.Id); + + builder.Property(x => x.UserId) + .IsRequired(); + + builder.Property(x => x.Amount) + .IsRequired(); + + builder.Property(x => x.Type) + .IsRequired(); + + builder.Property(x => x.Description) + .IsRequired() + .HasMaxLength(1000); + + builder.Property(x => x.ReferenceNumber) + .HasMaxLength(100); + + builder.Property(x => x.Status) + .IsRequired(); + + builder.Property(x => x.RequestedBy) + .IsRequired(); + + builder.Property(x => x.ApprovedBy); + + builder.Property(x => x.ApprovedAt); + + builder.Property(x => x.RejectionReason) + .HasMaxLength(500); + + builder.Property(x => x.TransactionId); + + // Relations + builder.HasOne(x => x.User) + .WithMany() + .HasForeignKey(x => x.UserId) + .OnDelete(DeleteBehavior.Restrict); + + builder.HasOne(x => x.Transaction) + .WithMany() + .HasForeignKey(x => x.TransactionId) + .OnDelete(DeleteBehavior.Restrict); + + // Indexes + builder.HasIndex(x => x.UserId); + builder.HasIndex(x => x.Status); + builder.HasIndex(x => x.RequestedBy); + builder.HasIndex(x => x.ApprovedBy); + builder.HasIndex(x => x.Created); + builder.HasIndex(x => new { x.UserId, x.Status }); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/OrderVATConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/OrderVATConfiguration.cs new file mode 100644 index 0000000..5d98f86 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/OrderVATConfiguration.cs @@ -0,0 +1,55 @@ +using CMSMicroservice.Domain.Entities.Order; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +public class OrderVATConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("OrderVATs"); + + builder.HasKey(x => x.Id); + + builder.Property(x => x.OrderId) + .IsRequired(); + + builder.Property(x => x.VATRate) + .IsRequired() + .HasColumnType("decimal(5,4)"); // 0.0900 (9%) + + builder.Property(x => x.BaseAmount) + .IsRequired(); + + builder.Property(x => x.VATAmount) + .IsRequired(); + + builder.Property(x => x.TotalAmount) + .IsRequired(); + + builder.Property(x => x.IsPaid) + .IsRequired() + .HasDefaultValue(false); + + builder.Property(x => x.Note) + .HasMaxLength(500); + + // Foreign Key + builder.HasOne(x => x.Order) + .WithOne() + .HasForeignKey(x => x.OrderId) + .OnDelete(DeleteBehavior.Restrict); + + // Indexes + builder.HasIndex(x => x.OrderId) + .IsUnique() + .HasDatabaseName("IX_OrderVATs_OrderId"); + + builder.HasIndex(x => x.IsPaid) + .HasDatabaseName("IX_OrderVATs_IsPaid"); + + builder.HasIndex(x => x.Created) + .HasDatabaseName("IX_OrderVATs_Created"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductCategoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductCategoryConfiguration.cs new file mode 100644 index 0000000..ff87209 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductCategoryConfiguration.cs @@ -0,0 +1,21 @@ +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; +public class ProductCategoryConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("ProductCategories", "CMS"); + builder.HasKey(e => e.Id); + + builder.HasOne(d => d.Product) + .WithMany(p => p.ProductCategories) + .HasForeignKey(d => d.ProductId); + + builder.HasOne(d => d.Category) + .WithMany(p => p.ProductCategories) + .HasForeignKey(d => d.CategoryId); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductsConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductConfiguration.cs similarity index 91% rename from src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductsConfiguration.cs rename to src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductConfiguration.cs index c15cbde..c232f57 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductsConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductConfiguration.cs @@ -2,10 +2,10 @@ using CMSMicroservice.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; -//توکن Otp -public class ProductsConfiguration : IEntityTypeConfiguration +//محصول +public class ProductConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.HasQueryFilter(p => !p.IsDeleted); builder.Ignore(entity => entity.DomainEvents); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/PruductCategoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGalleriesConfiguration.cs similarity index 59% rename from src/CMSMicroservice.Infrastructure/Persistence/Configurations/PruductCategoryConfiguration.cs rename to src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGalleriesConfiguration.cs index 67e85d8..2828155 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/PruductCategoryConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGalleriesConfiguration.cs @@ -2,24 +2,24 @@ using CMSMicroservice.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; -//دسته بندی -public class PruductCategoryConfiguration : IEntityTypeConfiguration +//تنظیمات گالری تصاویر محصول +public class ProductGalleriesConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + 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 - .HasOne(entity => entity.Product) - .WithMany(entity => entity.PruductCategorys) - .HasForeignKey(entity => entity.ProductId) + .HasOne(entity => entity.ProductImage) + .WithMany(entity => entity.ProductGalleries) + .HasForeignKey(entity => entity.ProductImageId) .IsRequired(true); builder - .HasOne(entity => entity.Category) - .WithMany(entity => entity.PruductCategorys) - .HasForeignKey(entity => entity.CategoryId) + .HasOne(entity => entity.Product) + .WithMany(entity => entity.ProductGalleries) + .HasForeignKey(entity => entity.ProductId) .IsRequired(true); } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/PruductTagConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGalleryConfiguration.cs similarity index 59% rename from src/CMSMicroservice.Infrastructure/Persistence/Configurations/PruductTagConfiguration.cs rename to src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGalleryConfiguration.cs index 5bd267f..b58de90 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/PruductTagConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGalleryConfiguration.cs @@ -2,24 +2,24 @@ using CMSMicroservice.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; -//برچسب محصول -public class PruductTagConfiguration : IEntityTypeConfiguration +//تنظیمات گالری تصاویر محصول +public class ProductGalleryConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + 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 - .HasOne(entity => entity.Product) - .WithMany(entity => entity.PruductTags) - .HasForeignKey(entity => entity.ProductId) + .HasOne(entity => entity.ProductImage) + .WithMany(entity => entity.ProductGalleries) + .HasForeignKey(entity => entity.ProductImageId) .IsRequired(true); builder - .HasOne(entity => entity.Tag) - .WithMany(entity => entity.PruductTags) - .HasForeignKey(entity => entity.TagId) + .HasOne(entity => entity.Product) + .WithMany(entity => entity.ProductGalleries) + .HasForeignKey(entity => entity.ProductId) .IsRequired(true); } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGallerysConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGallerysConfiguration.cs index b84fa5b..f43c3e2 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGallerysConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductGallerysConfiguration.cs @@ -3,9 +3,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; //توکن Otp -public class ProductGallerysConfiguration : IEntityTypeConfiguration +public class ProductGallerysConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.HasQueryFilter(p => !p.IsDeleted); builder.Ignore(entity => entity.DomainEvents); @@ -13,12 +13,12 @@ public class ProductGallerysConfiguration : IEntityTypeConfiguration entity.Id).UseIdentityColumn(); builder .HasOne(entity => entity.ProductImage) - .WithMany(entity => entity.ProductGalleryss) + .WithMany(entity => entity.ProductGalleries) .HasForeignKey(entity => entity.ProductImageId) .IsRequired(true); builder .HasOne(entity => entity.Product) - .WithMany(entity => entity.ProductGalleryss) + .WithMany(entity => entity.ProductGalleries) .HasForeignKey(entity => entity.ProductId) .IsRequired(true); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductImagesConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductImageConfiguration.cs similarity index 79% rename from src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductImagesConfiguration.cs rename to src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductImageConfiguration.cs index 4119892..b8c6fcc 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductImagesConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductImageConfiguration.cs @@ -2,10 +2,10 @@ using CMSMicroservice.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; -//توکن Otp -public class ProductImagesConfiguration : IEntityTypeConfiguration +//تصاویر محصول +public class ProductImageConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.HasQueryFilter(p => !p.IsDeleted); builder.Ignore(entity => entity.DomainEvents); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductTagConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductTagConfiguration.cs new file mode 100644 index 0000000..4c82748 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductTagConfiguration.cs @@ -0,0 +1,21 @@ +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; +public class ProductTagConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("ProductTags", "CMS"); + builder.HasKey(e => e.Id); + + builder.HasOne(d => d.Product) + .WithMany(p => p.ProductTags) + .HasForeignKey(d => d.ProductId); + + builder.HasOne(d => d.Tag) + .WithMany(p => p.ProductTags) + .HasForeignKey(d => d.TagId); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/PublicMessageConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/PublicMessageConfiguration.cs new file mode 100644 index 0000000..4983607 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/PublicMessageConfiguration.cs @@ -0,0 +1,74 @@ +using CMSMicroservice.Domain.Entities.Message; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +public class PublicMessageConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("PublicMessages"); + + builder.HasKey(x => x.Id); + + builder.Property(x => x.Title) + .IsRequired() + .HasMaxLength(200); + + builder.Property(x => x.Content) + .IsRequired() + .HasMaxLength(2000); + + builder.Property(x => x.Type) + .IsRequired(); + + builder.Property(x => x.Priority) + .IsRequired(); + + builder.Property(x => x.IsActive) + .IsRequired() + .HasDefaultValue(true); + + builder.Property(x => x.StartsAt) + .IsRequired(); + + builder.Property(x => x.ExpiresAt) + .IsRequired(); + + builder.Property(x => x.CreatedByUserId) + .IsRequired(); + + builder.Property(x => x.ViewCount) + .IsRequired() + .HasDefaultValue(0); + + builder.Property(x => x.LinkUrl) + .HasMaxLength(500); + + builder.Property(x => x.LinkText) + .HasMaxLength(100); + + // Indexes + builder.HasIndex(x => x.IsActive) + .HasDatabaseName("IX_PublicMessages_IsActive"); + + builder.HasIndex(x => x.Type) + .HasDatabaseName("IX_PublicMessages_Type"); + + builder.HasIndex(x => x.Priority) + .HasDatabaseName("IX_PublicMessages_Priority"); + + builder.HasIndex(x => x.StartsAt) + .HasDatabaseName("IX_PublicMessages_StartsAt"); + + builder.HasIndex(x => x.ExpiresAt) + .HasDatabaseName("IX_PublicMessages_ExpiresAt"); + + builder.HasIndex(x => x.CreatedByUserId) + .HasDatabaseName("IX_PublicMessages_CreatedByUserId"); + + builder.HasIndex(x => new { x.IsActive, x.ExpiresAt }) + .HasDatabaseName("IX_PublicMessages_IsActive_ExpiresAt"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/TransactionsConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/TransactionConfiguration.cs similarity index 83% rename from src/CMSMicroservice.Infrastructure/Persistence/Configurations/TransactionsConfiguration.cs rename to src/CMSMicroservice.Infrastructure/Persistence/Configurations/TransactionConfiguration.cs index 1087cf9..6e4ee5e 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/TransactionsConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/TransactionConfiguration.cs @@ -2,10 +2,10 @@ using CMSMicroservice.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; -//آدرس کاربر -public class TransactionsConfiguration : IEntityTypeConfiguration +//تراکنش +public class TransactionConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.HasQueryFilter(p => !p.IsDeleted); builder.Ignore(entity => entity.DomainEvents); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserAddressConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserAddressConfiguration.cs index ab690ef..807ba93 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserAddressConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserAddressConfiguration.cs @@ -13,7 +13,7 @@ public class UserAddressConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.Id).UseIdentityColumn(); builder .HasOne(entity => entity.User) - .WithMany(entity => entity.UserAddresss) + .WithMany(entity => entity.UserAddresses) .HasForeignKey(entity => entity.UserId) .IsRequired(true); builder.Property(entity => entity.Title).IsRequired(true); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCartConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCartConfiguration.cs new file mode 100644 index 0000000..69c060e --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCartConfiguration.cs @@ -0,0 +1,27 @@ +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; +//تنظیمات سبد خرید کاربر +public class UserCartConfiguration : 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 + .HasOne(entity => entity.Product) + .WithMany(entity => entity.UserCarts) + .HasForeignKey(entity => entity.ProductId) + .IsRequired(true); + builder + .HasOne(entity => entity.User) + .WithMany(entity => entity.UserCarts) + .HasForeignKey(entity => entity.UserId) + .IsRequired(true); + builder.Property(entity => entity.Count).IsRequired(true); + + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCartsConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCartsConfiguration.cs index 106a0ef..e319536 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCartsConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCartsConfiguration.cs @@ -3,9 +3,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; //آدرس کاربر -public class UserCartsConfiguration : IEntityTypeConfiguration +public class UserCartsConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.HasQueryFilter(p => !p.IsDeleted); builder.Ignore(entity => entity.DomainEvents); @@ -13,12 +13,12 @@ public class UserCartsConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.Id).UseIdentityColumn(); builder .HasOne(entity => entity.Product) - .WithMany(entity => entity.UserCartss) + .WithMany(entity => entity.UserCarts) .HasForeignKey(entity => entity.ProductId) .IsRequired(true); builder .HasOne(entity => entity.User) - .WithMany(entity => entity.UserCartss) + .WithMany(entity => entity.UserCarts) .HasForeignKey(entity => entity.UserId) .IsRequired(true); builder.Property(entity => entity.Count).IsRequired(true); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs index d39edba..f1710e5 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs @@ -16,11 +16,6 @@ public class UserConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.Mobile).IsRequired(true); builder.Property(entity => entity.NationalCode).IsRequired(false); builder.Property(entity => entity.AvatarPath).IsRequired(false); - builder - .HasOne(entity => entity.Parent) - .WithMany(entity => entity.Users) - .HasForeignKey(entity => entity.ParentId) - .IsRequired(false); builder.Property(entity => entity.ReferralCode).IsRequired(true); builder.Property(entity => entity.IsMobileVerified ).IsRequired(true); builder.Property(entity => entity.MobileVerifiedAt).IsRequired(false); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserPackagePurchaseConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserPackagePurchaseConfiguration.cs new file mode 100644 index 0000000..b3bfb8d --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserPackagePurchaseConfiguration.cs @@ -0,0 +1,70 @@ +using CMSMicroservice.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// خرید پکیج توسط کاربر +/// +public class UserPackagePurchaseConfiguration : 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.UserId).IsRequired(); + builder.Property(entity => entity.PackageId).IsRequired(); + builder.Property(entity => entity.PurchaseMethod).IsRequired(); + builder.Property(entity => entity.PurchasedAt).IsRequired(); + builder.Property(entity => entity.Amount).IsRequired(); + builder.Property(entity => entity.OrderId).IsRequired(false); + builder.Property(entity => entity.TransactionId).IsRequired(false); + + // رابطه با User + builder.HasOne(entity => entity.User) + .WithMany() // User can have multiple package purchases + .HasForeignKey(entity => entity.UserId) + .OnDelete(DeleteBehavior.Restrict); + + // رابطه با Package + builder.HasOne(entity => entity.Package) + .WithMany() + .HasForeignKey(entity => entity.PackageId) + .OnDelete(DeleteBehavior.Restrict); + + // رابطه با UserOrder (اختیاری) + builder.HasOne(entity => entity.Order) + .WithMany() + .HasForeignKey(entity => entity.OrderId) + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(false); + + // رابطه با Transaction (اختیاری) + builder.HasOne(entity => entity.Transaction) + .WithMany() + .HasForeignKey(entity => entity.TransactionId) + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(false); + + // Index برای UserId (برای کوئری سریع) + builder.HasIndex(e => e.UserId) + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + // Index برای PackageId + builder.HasIndex(e => e.PackageId) + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + // Index برای PurchasedAt (برای فیلتر زمانی) + builder.HasIndex(e => e.PurchasedAt) + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + // Composite Index برای UserId + PurchasedAt (کوئری‌های متداول) + builder.HasIndex(e => new { e.UserId, e.PurchasedAt }) + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112173307_u05.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112173307_u05.Designer.cs index 24caa46..289941d 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112173307_u05.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112173307_u05.Designer.cs @@ -171,7 +171,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -813,7 +813,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112201503_u06.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112201503_u06.Designer.cs index 1e828eb..4f0b61c 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112201503_u06.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251112201503_u06.Designer.cs @@ -171,7 +171,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -816,7 +816,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251116133807_u07.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251116133807_u07.Designer.cs index a4228b1..ae222aa 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251116133807_u07.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251116133807_u07.Designer.cs @@ -214,7 +214,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -905,7 +905,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251120150518_u08.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251120150518_u08.Designer.cs index 442c68d..7254be0 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251120150518_u08.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251120150518_u08.Designer.cs @@ -267,7 +267,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1088,7 +1088,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251122183829_u09.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251122183829_u09.Designer.cs index abd0cd9..2166168 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251122183829_u09.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251122183829_u09.Designer.cs @@ -267,7 +267,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1091,7 +1091,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124213641_u10.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124213641_u10.Designer.cs index 10a4680..14a45c7 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124213641_u10.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124213641_u10.Designer.cs @@ -267,7 +267,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1044,7 +1044,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124223532_u11.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124223532_u11.Designer.cs index 9108544..dbe59ee 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124223532_u11.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251124223532_u11.Designer.cs @@ -267,7 +267,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1053,7 +1053,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251127030633_u12.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251127030633_u12.Designer.cs index 02f29ab..833e03c 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251127030633_u12.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251127030633_u12.Designer.cs @@ -267,7 +267,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1062,7 +1062,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.Designer.cs index c88bad4..dbb8311 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.Designer.cs @@ -937,7 +937,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1857,7 +1857,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201144400_UpdateNetworkWeeklyBalanceWithCarryover.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201144400_UpdateNetworkWeeklyBalanceWithCarryover.Designer.cs index 0a39f77..c199b2e 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201144400_UpdateNetworkWeeklyBalanceWithCarryover.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201144400_UpdateNetworkWeeklyBalanceWithCarryover.Designer.cs @@ -961,7 +961,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1881,7 +1881,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201164233_AddWorkerExecutionLog.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201164233_AddWorkerExecutionLog.Designer.cs index a27810e..fb13983 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201164233_AddWorkerExecutionLog.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201164233_AddWorkerExecutionLog.Designer.cs @@ -1031,7 +1031,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1951,7 +1951,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201165453_AddProcessedByToWithdrawal.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201165453_AddProcessedByToWithdrawal.Designer.cs index 610fbcd..c87c2f0 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201165453_AddProcessedByToWithdrawal.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201165453_AddProcessedByToWithdrawal.Designer.cs @@ -1042,7 +1042,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1962,7 +1962,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201172747_AddEmailToUser.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201172747_AddEmailToUser.Designer.cs index 2cc2d00..4c6175b 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201172747_AddEmailToUser.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201172747_AddEmailToUser.Designer.cs @@ -1042,7 +1042,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1965,7 +1965,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201191716_AddDayaLoanIntegration.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201191716_AddDayaLoanIntegration.Designer.cs index b5c92c2..9838c19 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201191716_AddDayaLoanIntegration.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201191716_AddDayaLoanIntegration.Designer.cs @@ -1099,7 +1099,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -2045,7 +2045,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201230330_AddPackagePurchaseMethod.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201230330_AddPackagePurchaseMethod.Designer.cs index f26095e..822c115 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201230330_AddPackagePurchaseMethod.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201230330_AddPackagePurchaseMethod.Designer.cs @@ -1111,7 +1111,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -2060,7 +2060,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201235621_AddDiscountBalanceToWalletChangeLog.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201235621_AddDiscountBalanceToWalletChangeLog.Designer.cs index 93c8d15..8138823 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201235621_AddDiscountBalanceToWalletChangeLog.Designer.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251201235621_AddDiscountBalanceToWalletChangeLog.Designer.cs @@ -1111,7 +1111,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -2066,7 +2066,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") .WithMany("ProductGalleryss") diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202165758_RemoveParentIdFromUser.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202165758_RemoveParentIdFromUser.Designer.cs new file mode 100644 index 0000000..bb94d18 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202165758_RemoveParentIdFromUser.Designer.cs @@ -0,0 +1,2373 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251202165758_RemoveParentIdFromUser")] + partial class RemoveParentIdFromUser + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.ProductGalleries", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202165758_RemoveParentIdFromUser.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202165758_RemoveParentIdFromUser.cs new file mode 100644 index 0000000..149654b --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202165758_RemoveParentIdFromUser.cs @@ -0,0 +1,55 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class RemoveParentIdFromUser : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Users_Users_ParentId", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_Users_ParentId", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropColumn( + name: "ParentId", + schema: "CMS", + table: "Users"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ParentId", + schema: "CMS", + table: "Users", + type: "bigint", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Users_ParentId", + schema: "CMS", + table: "Users", + column: "ParentId"); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Users_ParentId", + schema: "CMS", + table: "Users", + column: "ParentId", + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202173338_AddGiftValueToClubMembership.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202173338_AddGiftValueToClubMembership.Designer.cs new file mode 100644 index 0000000..8492dab --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202173338_AddGiftValueToClubMembership.Designer.cs @@ -0,0 +1,2376 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251202173338_AddGiftValueToClubMembership")] + partial class AddGiftValueToClubMembership + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.ProductGalleries", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202173338_AddGiftValueToClubMembership.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202173338_AddGiftValueToClubMembership.cs new file mode 100644 index 0000000..f3ba3cb --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202173338_AddGiftValueToClubMembership.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddGiftValueToClubMembership : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "GiftValue", + schema: "CMS", + table: "ClubMemberships", + type: "bigint", + nullable: false, + defaultValue: 0L); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "GiftValue", + schema: "CMS", + table: "ClubMemberships"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202192856_AddUserPackagePurchase.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202192856_AddUserPackagePurchase.Designer.cs new file mode 100644 index 0000000..ffe5380 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202192856_AddUserPackagePurchase.Designer.cs @@ -0,0 +1,2474 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251202192856_AddUserPackagePurchase")] + partial class AddUserPackagePurchase + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.ProductGalleries", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202192856_AddUserPackagePurchase.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202192856_AddUserPackagePurchase.cs new file mode 100644 index 0000000..0c548a8 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251202192856_AddUserPackagePurchase.cs @@ -0,0 +1,112 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddUserPackagePurchase : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "UserPackagePurchases", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + PackageId = table.Column(type: "bigint", nullable: false), + PurchaseMethod = table.Column(type: "int", nullable: false), + PurchasedAt = table.Column(type: "datetime2", nullable: false), + Amount = table.Column(type: "bigint", nullable: false), + OrderId = table.Column(type: "bigint", nullable: true), + TransactionId = table.Column(type: "bigint", nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserPackagePurchases", x => x.Id); + table.ForeignKey( + name: "FK_UserPackagePurchases_Packages_PackageId", + column: x => x.PackageId, + principalSchema: "CMS", + principalTable: "Packages", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserPackagePurchases_Transactionss_TransactionId", + column: x => x.TransactionId, + principalSchema: "CMS", + principalTable: "Transactionss", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserPackagePurchases_UserOrders_OrderId", + column: x => x.OrderId, + principalSchema: "CMS", + principalTable: "UserOrders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserPackagePurchases_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_UserPackagePurchase_PackageId", + schema: "CMS", + table: "UserPackagePurchases", + column: "PackageId"); + + migrationBuilder.CreateIndex( + name: "IX_UserPackagePurchase_PurchasedAt", + schema: "CMS", + table: "UserPackagePurchases", + column: "PurchasedAt"); + + migrationBuilder.CreateIndex( + name: "IX_UserPackagePurchase_UserId", + schema: "CMS", + table: "UserPackagePurchases", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserPackagePurchase_UserId_PurchasedAt", + schema: "CMS", + table: "UserPackagePurchases", + columns: new[] { "UserId", "PurchasedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_UserPackagePurchases_OrderId", + schema: "CMS", + table: "UserPackagePurchases", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_UserPackagePurchases_TransactionId", + schema: "CMS", + table: "UserPackagePurchases", + column: "TransactionId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "UserPackagePurchases", + schema: "CMS"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203171356_AddClubMembershipGiftValueConfiguration.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203171356_AddClubMembershipGiftValueConfiguration.Designer.cs new file mode 100644 index 0000000..7f5ad4a --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203171356_AddClubMembershipGiftValueConfiguration.Designer.cs @@ -0,0 +1,2474 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251203171356_AddClubMembershipGiftValueConfiguration")] + partial class AddClubMembershipGiftValueConfiguration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.ProductGalleries", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203171356_AddClubMembershipGiftValueConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203171356_AddClubMembershipGiftValueConfiguration.cs new file mode 100644 index 0000000..a72d03c --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203171356_AddClubMembershipGiftValueConfiguration.cs @@ -0,0 +1,42 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddClubMembershipGiftValueConfiguration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + // اضافه کردن تنظیمات Club.MembershipGiftValue + migrationBuilder.Sql(@" + INSERT INTO ""SystemConfigurations"" + (""Key"", ""Value"", ""Description"", ""Scope"", ""IsActive"", ""Created"", ""CreatedBy"") + SELECT + 'Club.MembershipGiftValue', + '25200000', + 'مبلغ هدیه حق عضویت باشگاه (ریال) - این مبلغ از کیف پول کم نمی‌شود', + 1, -- ConfigurationScope.Club = 1 + true, + NOW(), + 'System' + WHERE NOT EXISTS ( + SELECT 1 FROM ""SystemConfigurations"" + WHERE ""Key"" = 'Club.MembershipGiftValue' + ); + "); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + // حذف تنظیمات Club.MembershipGiftValue + migrationBuilder.Sql(@" + DELETE FROM ""SystemConfigurations"" + WHERE ""Key"" = 'Club.MembershipGiftValue'; + "); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203173641_AddManualPaymentSystem.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203173641_AddManualPaymentSystem.Designer.cs new file mode 100644 index 0000000..eaf8960 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203173641_AddManualPaymentSystem.Designer.cs @@ -0,0 +1,2571 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251203173641_AddManualPaymentSystem")] + partial class AddManualPaymentSystem + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedBy") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RequestedBy") + .HasColumnType("bigint"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedBy"); + + b.HasIndex("Created"); + + b.HasIndex("RequestedBy"); + + b.HasIndex("Status"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.HasIndex("UserId", "Status"); + + b.ToTable("ManualPayments", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.Payment.ManualPayment", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203173641_AddManualPaymentSystem.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203173641_AddManualPaymentSystem.cs new file mode 100644 index 0000000..1dd474b --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203173641_AddManualPaymentSystem.cs @@ -0,0 +1,108 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddManualPaymentSystem : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ManualPayments", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + Amount = table.Column(type: "bigint", nullable: false), + Type = table.Column(type: "int", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + ReferenceNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Status = table.Column(type: "int", nullable: false), + RequestedBy = table.Column(type: "bigint", nullable: false), + ApprovedBy = table.Column(type: "bigint", nullable: true), + ApprovedAt = table.Column(type: "datetime2", nullable: true), + RejectionReason = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + TransactionId = table.Column(type: "bigint", nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ManualPayments", x => x.Id); + table.ForeignKey( + name: "FK_ManualPayments_Transactionss_TransactionId", + column: x => x.TransactionId, + principalSchema: "CMS", + principalTable: "Transactionss", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ManualPayments_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_ManualPayments_ApprovedBy", + schema: "CMS", + table: "ManualPayments", + column: "ApprovedBy"); + + migrationBuilder.CreateIndex( + name: "IX_ManualPayments_Created", + schema: "CMS", + table: "ManualPayments", + column: "Created"); + + migrationBuilder.CreateIndex( + name: "IX_ManualPayments_RequestedBy", + schema: "CMS", + table: "ManualPayments", + column: "RequestedBy"); + + migrationBuilder.CreateIndex( + name: "IX_ManualPayments_Status", + schema: "CMS", + table: "ManualPayments", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_ManualPayments_TransactionId", + schema: "CMS", + table: "ManualPayments", + column: "TransactionId"); + + migrationBuilder.CreateIndex( + name: "IX_ManualPayments_UserId", + schema: "CMS", + table: "ManualPayments", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_ManualPayments_UserId_Status", + schema: "CMS", + table: "ManualPayments", + columns: new[] { "UserId", "Status" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ManualPayments", + schema: "CMS"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203174445_AddPublicMessageSystem.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203174445_AddPublicMessageSystem.Designer.cs new file mode 100644 index 0000000..b721c3c --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203174445_AddPublicMessageSystem.Designer.cs @@ -0,0 +1,2663 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251203174445_AddPublicMessageSystem")] + partial class AddPublicMessageSystem + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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.Message.PublicMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedByUserId") + .HasColumnType("bigint"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LinkText") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LinkUrl") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("ViewCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId") + .HasDatabaseName("IX_PublicMessages_CreatedByUserId"); + + b.HasIndex("ExpiresAt") + .HasDatabaseName("IX_PublicMessages_ExpiresAt"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_PublicMessages_IsActive"); + + b.HasIndex("Priority") + .HasDatabaseName("IX_PublicMessages_Priority"); + + b.HasIndex("StartsAt") + .HasDatabaseName("IX_PublicMessages_StartsAt"); + + b.HasIndex("Type") + .HasDatabaseName("IX_PublicMessages_Type"); + + b.HasIndex("IsActive", "ExpiresAt") + .HasDatabaseName("IX_PublicMessages_IsActive_ExpiresAt"); + + b.ToTable("PublicMessages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedBy") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RequestedBy") + .HasColumnType("bigint"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedBy"); + + b.HasIndex("Created"); + + b.HasIndex("RequestedBy"); + + b.HasIndex("Status"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.HasIndex("UserId", "Status"); + + b.ToTable("ManualPayments", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.Payment.ManualPayment", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203174445_AddPublicMessageSystem.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203174445_AddPublicMessageSystem.cs new file mode 100644 index 0000000..0fb7691 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203174445_AddPublicMessageSystem.cs @@ -0,0 +1,94 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddPublicMessageSystem : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "PublicMessages", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Content = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false), + Type = table.Column(type: "int", nullable: false), + Priority = table.Column(type: "int", nullable: false), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + StartsAt = table.Column(type: "datetime2", nullable: false), + ExpiresAt = table.Column(type: "datetime2", nullable: false), + CreatedByUserId = table.Column(type: "bigint", nullable: false), + ViewCount = table.Column(type: "int", nullable: false, defaultValue: 0), + LinkUrl = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + LinkText = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PublicMessages", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_PublicMessages_CreatedByUserId", + schema: "CMS", + table: "PublicMessages", + column: "CreatedByUserId"); + + migrationBuilder.CreateIndex( + name: "IX_PublicMessages_ExpiresAt", + schema: "CMS", + table: "PublicMessages", + column: "ExpiresAt"); + + migrationBuilder.CreateIndex( + name: "IX_PublicMessages_IsActive", + schema: "CMS", + table: "PublicMessages", + column: "IsActive"); + + migrationBuilder.CreateIndex( + name: "IX_PublicMessages_IsActive_ExpiresAt", + schema: "CMS", + table: "PublicMessages", + columns: new[] { "IsActive", "ExpiresAt" }); + + migrationBuilder.CreateIndex( + name: "IX_PublicMessages_Priority", + schema: "CMS", + table: "PublicMessages", + column: "Priority"); + + migrationBuilder.CreateIndex( + name: "IX_PublicMessages_StartsAt", + schema: "CMS", + table: "PublicMessages", + column: "StartsAt"); + + migrationBuilder.CreateIndex( + name: "IX_PublicMessages_Type", + schema: "CMS", + table: "PublicMessages", + column: "Type"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PublicMessages", + schema: "CMS"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203175713_AddVATSystem.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203175713_AddVATSystem.Designer.cs new file mode 100644 index 0000000..1fd4915 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203175713_AddVATSystem.Designer.cs @@ -0,0 +1,2753 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251203175713_AddVATSystem")] + partial class AddVATSystem + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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.Message.PublicMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedByUserId") + .HasColumnType("bigint"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LinkText") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LinkUrl") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("ViewCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId") + .HasDatabaseName("IX_PublicMessages_CreatedByUserId"); + + b.HasIndex("ExpiresAt") + .HasDatabaseName("IX_PublicMessages_ExpiresAt"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_PublicMessages_IsActive"); + + b.HasIndex("Priority") + .HasDatabaseName("IX_PublicMessages_Priority"); + + b.HasIndex("StartsAt") + .HasDatabaseName("IX_PublicMessages_StartsAt"); + + b.HasIndex("Type") + .HasDatabaseName("IX_PublicMessages_Type"); + + b.HasIndex("IsActive", "ExpiresAt") + .HasDatabaseName("IX_PublicMessages_IsActive_ExpiresAt"); + + b.ToTable("PublicMessages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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.Order.OrderVAT", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BaseAmount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsPaid") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("VATAmount") + .HasColumnType("bigint"); + + b.Property("VATRate") + .HasColumnType("decimal(5,4)"); + + b.HasKey("Id"); + + b.HasIndex("Created") + .HasDatabaseName("IX_OrderVATs_Created"); + + b.HasIndex("IsPaid") + .HasDatabaseName("IX_OrderVATs_IsPaid"); + + b.HasIndex("OrderId") + .IsUnique() + .HasDatabaseName("IX_OrderVATs_OrderId"); + + b.ToTable("OrderVATs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedBy") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RequestedBy") + .HasColumnType("bigint"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedBy"); + + b.HasIndex("Created"); + + b.HasIndex("RequestedBy"); + + b.HasIndex("Status"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.HasIndex("UserId", "Status"); + + b.ToTable("ManualPayments", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("HasVAT") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderVATId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderVATId"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.Order.OrderVAT", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithOne() + .HasForeignKey("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGalleries", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderVAT") + .WithMany() + .HasForeignKey("OrderVATId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderVAT"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203175713_AddVATSystem.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203175713_AddVATSystem.cs new file mode 100644 index 0000000..5b7e3ea --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203175713_AddVATSystem.cs @@ -0,0 +1,125 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddVATSystem : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "HasVAT", + schema: "CMS", + table: "UserOrders", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "OrderVATId", + schema: "CMS", + table: "UserOrders", + type: "bigint", + nullable: true); + + migrationBuilder.CreateTable( + name: "OrderVATs", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrderId = table.Column(type: "bigint", nullable: false), + VATRate = table.Column(type: "decimal(5,4)", nullable: false), + BaseAmount = table.Column(type: "bigint", nullable: false), + VATAmount = table.Column(type: "bigint", nullable: false), + TotalAmount = table.Column(type: "bigint", nullable: false), + IsPaid = table.Column(type: "bit", nullable: false, defaultValue: false), + PaidAt = table.Column(type: "datetime2", nullable: true), + Note = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderVATs", x => x.Id); + table.ForeignKey( + name: "FK_OrderVATs_UserOrders_OrderId", + column: x => x.OrderId, + principalSchema: "CMS", + principalTable: "UserOrders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_UserOrders_OrderVATId", + schema: "CMS", + table: "UserOrders", + column: "OrderVATId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderVATs_Created", + schema: "CMS", + table: "OrderVATs", + column: "Created"); + + migrationBuilder.CreateIndex( + name: "IX_OrderVATs_IsPaid", + schema: "CMS", + table: "OrderVATs", + column: "IsPaid"); + + migrationBuilder.CreateIndex( + name: "IX_OrderVATs_OrderId", + schema: "CMS", + table: "OrderVATs", + column: "OrderId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_UserOrders_OrderVATs_OrderVATId", + schema: "CMS", + table: "UserOrders", + column: "OrderVATId", + principalSchema: "CMS", + principalTable: "OrderVATs", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_UserOrders_OrderVATs_OrderVATId", + schema: "CMS", + table: "UserOrders"); + + migrationBuilder.DropTable( + name: "OrderVATs", + schema: "CMS"); + + migrationBuilder.DropIndex( + name: "IX_UserOrders_OrderVATId", + schema: "CMS", + table: "UserOrders"); + + migrationBuilder.DropColumn( + name: "HasVAT", + schema: "CMS", + table: "UserOrders"); + + migrationBuilder.DropColumn( + name: "OrderVATId", + schema: "CMS", + table: "UserOrders"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203203713_AddDiscountShopSystem.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203203713_AddDiscountShopSystem.Designer.cs new file mode 100644 index 0000000..384ac69 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203203713_AddDiscountShopSystem.Designer.cs @@ -0,0 +1,3212 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251203203713_AddDiscountShopSystem")] + partial class AddDiscountShopSystem + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("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.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekNumber"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ImagePath") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentCategoryId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("ParentCategoryId"); + + b.ToTable("DiscountCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("DiscountBalanceUsed") + .HasColumnType("bigint"); + + b.Property("GatewayAmountPaid") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("TrackingCode") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("VatAmount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("DiscountOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrderDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountOrderId") + .HasColumnType("bigint"); + + b.Property("DiscountPercentUsed") + .HasColumnType("int"); + + b.Property("FinalPrice") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DiscountOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("DiscountOrderDetails", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("FullInformation") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ImagePath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxDiscountPercent") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("DiscountProducts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId", "CategoryId") + .IsUnique(); + + b.ToTable("DiscountProductCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId", "ProductId") + .IsUnique(); + + b.ToTable("DiscountShoppingCarts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetails", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("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.Message.PublicMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedByUserId") + .HasColumnType("bigint"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LinkText") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LinkUrl") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("ViewCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId") + .HasDatabaseName("IX_PublicMessages_CreatedByUserId"); + + b.HasIndex("ExpiresAt") + .HasDatabaseName("IX_PublicMessages_ExpiresAt"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_PublicMessages_IsActive"); + + b.HasIndex("Priority") + .HasDatabaseName("IX_PublicMessages_Priority"); + + b.HasIndex("StartsAt") + .HasDatabaseName("IX_PublicMessages_StartsAt"); + + b.HasIndex("Type") + .HasDatabaseName("IX_PublicMessages_Type"); + + b.HasIndex("IsActive", "ExpiresAt") + .HasDatabaseName("IX_PublicMessages_IsActive_ExpiresAt"); + + b.ToTable("PublicMessages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("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.Order.OrderVAT", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BaseAmount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsPaid") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("VATAmount") + .HasColumnType("bigint"); + + b.Property("VATRate") + .HasColumnType("decimal(5,4)"); + + b.HasKey("Id"); + + b.HasIndex("Created") + .HasDatabaseName("IX_OrderVATs_Created"); + + b.HasIndex("IsPaid") + .HasDatabaseName("IX_OrderVATs_IsPaid"); + + b.HasIndex("OrderId") + .IsUnique() + .HasDatabaseName("IX_OrderVATs_OrderId"); + + b.ToTable("OrderVATs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedBy") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RequestedBy") + .HasColumnType("bigint"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedBy"); + + b.HasIndex("Created"); + + b.HasIndex("RequestedBy"); + + b.HasIndex("Status"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.HasIndex("UserId", "Status"); + + b.ToTable("ManualPayments", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Products", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleries", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("ProductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactions", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("PackagePurchaseMethod") + .HasColumnType("int"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresses", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCarts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("HasVAT") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderVATId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderVATId"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeDiscountValue") + .HasColumnType("bigint"); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentDiscountBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categories") + .HasForeignKey("ParentId"); + + 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.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", "ParentCategory") + .WithMany("ChildCategories") + .HasForeignKey("ParentCategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ParentCategory"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany() + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DiscountOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrderDetail", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", "DiscountOrder") + .WithMany("OrderDetails") + .HasForeignKey("DiscountOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("OrderDetails") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DiscountOrder"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", "Category") + .WithMany("ProductCategories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("ProductCategories") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("ShoppingCarts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DiscountShoppingCarts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetails") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("FactorDetails") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + 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.Order.OrderVAT", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithOne() + .HasForeignKey("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("ProductCategories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductCategories") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallery", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductGalleries") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImage", "ProductImage") + .WithMany("ProductGalleries") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("ProductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCart", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("UserCarts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCarts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderVAT") + .WithMany() + .HasForeignKey("OrderVATId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderVAT"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categories"); + + b.Navigation("ProductCategories"); + }); + + 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"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.Navigation("ChildCategories"); + + b.Navigation("ProductCategories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.Navigation("OrderDetails"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", b => + { + b.Navigation("OrderDetails"); + + b.Navigation("ProductCategories"); + + b.Navigation("ShoppingCarts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Product", b => + { + b.Navigation("FactorDetails"); + + b.Navigation("ProductCategories"); + + b.Navigation("ProductGalleries"); + + b.Navigation("ProductTags"); + + b.Navigation("UserCarts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImage", b => + { + b.Navigation("ProductGalleries"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("ProductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transaction", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("DiscountOrders"); + + b.Navigation("DiscountShoppingCarts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresses"); + + b.Navigation("UserCarts"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetails"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203203713_AddDiscountShopSystem.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203203713_AddDiscountShopSystem.cs new file mode 100644 index 0000000..61b7096 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251203203713_AddDiscountShopSystem.cs @@ -0,0 +1,1330 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddDiscountShopSystem : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Categorys_Categorys_ParentId", + schema: "CMS", + table: "Categorys"); + + migrationBuilder.DropForeignKey( + name: "FK_DayaLoanContracts_Transactionss_TransactionId", + schema: "CMS", + table: "DayaLoanContracts"); + + migrationBuilder.DropForeignKey( + name: "FK_FactorDetailss_Productss_ProductId", + schema: "CMS", + table: "FactorDetailss"); + + migrationBuilder.DropForeignKey( + name: "FK_FactorDetailss_UserOrders_OrderId", + schema: "CMS", + table: "FactorDetailss"); + + migrationBuilder.DropForeignKey( + name: "FK_ManualPayments_Transactionss_TransactionId", + schema: "CMS", + table: "ManualPayments"); + + migrationBuilder.DropForeignKey( + name: "FK_UserAddresss_Users_UserId", + schema: "CMS", + table: "UserAddresss"); + + migrationBuilder.DropForeignKey( + name: "FK_UserOrders_Transactionss_TransactionId", + schema: "CMS", + table: "UserOrders"); + + migrationBuilder.DropForeignKey( + name: "FK_UserOrders_UserAddresss_UserAddressId", + schema: "CMS", + table: "UserOrders"); + + migrationBuilder.DropForeignKey( + name: "FK_UserPackagePurchases_Transactionss_TransactionId", + schema: "CMS", + table: "UserPackagePurchases"); + + migrationBuilder.DropTable( + name: "ProductGalleryss", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "PruductCategorys", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "PruductTags", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "Transactionss", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "UserCartss", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "ProductImagess", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "Productss", + schema: "CMS"); + + migrationBuilder.DropPrimaryKey( + name: "PK_UserAddresss", + schema: "CMS", + table: "UserAddresss"); + + migrationBuilder.DropPrimaryKey( + name: "PK_FactorDetailss", + schema: "CMS", + table: "FactorDetailss"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Categorys", + schema: "CMS", + table: "Categorys"); + + migrationBuilder.RenameTable( + name: "UserAddresss", + schema: "CMS", + newName: "UserAddresses", + newSchema: "CMS"); + + migrationBuilder.RenameTable( + name: "FactorDetailss", + schema: "CMS", + newName: "FactorDetails", + newSchema: "CMS"); + + migrationBuilder.RenameTable( + name: "Categorys", + schema: "CMS", + newName: "Categories", + newSchema: "CMS"); + + migrationBuilder.RenameIndex( + name: "IX_UserAddresss_UserId", + schema: "CMS", + table: "UserAddresses", + newName: "IX_UserAddresses_UserId"); + + migrationBuilder.RenameIndex( + name: "IX_FactorDetailss_ProductId", + schema: "CMS", + table: "FactorDetails", + newName: "IX_FactorDetails_ProductId"); + + migrationBuilder.RenameIndex( + name: "IX_FactorDetailss_OrderId", + schema: "CMS", + table: "FactorDetails", + newName: "IX_FactorDetails_OrderId"); + + migrationBuilder.RenameIndex( + name: "IX_Categorys_ParentId", + schema: "CMS", + table: "Categories", + newName: "IX_Categories_ParentId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_UserAddresses", + schema: "CMS", + table: "UserAddresses", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_FactorDetails", + schema: "CMS", + table: "FactorDetails", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Categories", + schema: "CMS", + table: "Categories", + column: "Id"); + + migrationBuilder.CreateTable( + name: "DiscountCategories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + ImagePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + ParentCategoryId = table.Column(type: "bigint", nullable: true), + SortOrder = table.Column(type: "int", nullable: false), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DiscountCategories", x => x.Id); + table.ForeignKey( + name: "FK_DiscountCategories_DiscountCategories_ParentCategoryId", + column: x => x.ParentCategoryId, + principalSchema: "CMS", + principalTable: "DiscountCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "DiscountProducts", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ShortInfomation = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), + FullInformation = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false), + Price = table.Column(type: "bigint", nullable: false), + MaxDiscountPercent = table.Column(type: "int", nullable: false), + Rate = table.Column(type: "int", nullable: false), + ImagePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), + ThumbnailPath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), + SaleCount = table.Column(type: "int", nullable: false), + ViewCount = table.Column(type: "int", nullable: false), + RemainingCount = table.Column(type: "int", nullable: false), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DiscountProducts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ProductImages", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(max)", nullable: false), + ImagePath = table.Column(type: "nvarchar(max)", nullable: false), + ImageThumbnailPath = table.Column(type: "nvarchar(max)", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductImages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Products", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + ShortInfomation = table.Column(type: "nvarchar(max)", nullable: false), + FullInformation = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "bigint", nullable: false), + Discount = table.Column(type: "int", nullable: false), + Rate = table.Column(type: "int", nullable: false), + ImagePath = table.Column(type: "nvarchar(max)", nullable: false), + ThumbnailPath = table.Column(type: "nvarchar(max)", nullable: false), + SaleCount = table.Column(type: "int", nullable: false), + ViewCount = table.Column(type: "int", nullable: false), + RemainingCount = table.Column(type: "int", nullable: false), + IsClubExclusive = table.Column(type: "bit", nullable: false), + ClubDiscountPercent = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Transactions", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Amount = table.Column(type: "bigint", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + PaymentStatus = table.Column(type: "int", nullable: false), + PaymentDate = table.Column(type: "datetime2", nullable: true), + RefId = table.Column(type: "nvarchar(max)", nullable: true), + Type = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Transactions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "DiscountProductCategories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductId = table.Column(type: "bigint", nullable: false), + CategoryId = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DiscountProductCategories", x => x.Id); + table.ForeignKey( + name: "FK_DiscountProductCategories_DiscountCategories_CategoryId", + column: x => x.CategoryId, + principalSchema: "CMS", + principalTable: "DiscountCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DiscountProductCategories_DiscountProducts_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "DiscountProducts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DiscountShoppingCarts", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + ProductId = table.Column(type: "bigint", nullable: false), + Count = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DiscountShoppingCarts", x => x.Id); + table.ForeignKey( + name: "FK_DiscountShoppingCarts_DiscountProducts_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "DiscountProducts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DiscountShoppingCarts_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductCategories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductId = table.Column(type: "bigint", nullable: false), + CategoryId = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductCategories", x => x.Id); + table.ForeignKey( + name: "FK_ProductCategories_Categories_CategoryId", + column: x => x.CategoryId, + principalSchema: "CMS", + principalTable: "Categories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductCategories_Products_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductGalleries", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductImageId = table.Column(type: "bigint", nullable: false), + ProductId = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductGalleries", x => x.Id); + table.ForeignKey( + name: "FK_ProductGalleries_ProductImages_ProductImageId", + column: x => x.ProductImageId, + principalSchema: "CMS", + principalTable: "ProductImages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductGalleries_Products_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductTags", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductId = table.Column(type: "bigint", nullable: false), + TagId = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductTags", x => x.Id); + table.ForeignKey( + name: "FK_ProductTags_Products_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductTags_Tags_TagId", + column: x => x.TagId, + principalSchema: "CMS", + principalTable: "Tags", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserCarts", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductId = table.Column(type: "bigint", nullable: false), + UserId = table.Column(type: "bigint", nullable: false), + Count = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserCarts", x => x.Id); + table.ForeignKey( + name: "FK_UserCarts_Products_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UserCarts_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DiscountOrders", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + TotalAmount = table.Column(type: "bigint", nullable: false), + DiscountBalanceUsed = table.Column(type: "bigint", nullable: false), + GatewayAmountPaid = table.Column(type: "bigint", nullable: false), + VatAmount = table.Column(type: "bigint", nullable: false), + PaymentStatus = table.Column(type: "int", nullable: false), + PaymentDate = table.Column(type: "datetime2", nullable: true), + TransactionId = table.Column(type: "bigint", nullable: true), + UserAddressId = table.Column(type: "bigint", nullable: false), + DeliveryStatus = table.Column(type: "int", nullable: false), + TrackingCode = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + DeliveryDescription = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DiscountOrders", x => x.Id); + table.ForeignKey( + name: "FK_DiscountOrders_Transactions_TransactionId", + column: x => x.TransactionId, + principalSchema: "CMS", + principalTable: "Transactions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_DiscountOrders_UserAddresses_UserAddressId", + column: x => x.UserAddressId, + principalSchema: "CMS", + principalTable: "UserAddresses", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_DiscountOrders_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "DiscountOrderDetails", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DiscountOrderId = table.Column(type: "bigint", nullable: false), + ProductId = table.Column(type: "bigint", nullable: false), + Count = table.Column(type: "int", nullable: false), + UnitPrice = table.Column(type: "bigint", nullable: false), + DiscountPercentUsed = table.Column(type: "int", nullable: false), + DiscountAmount = table.Column(type: "bigint", nullable: false), + FinalPrice = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DiscountOrderDetails", x => x.Id); + table.ForeignKey( + name: "FK_DiscountOrderDetails_DiscountOrders_DiscountOrderId", + column: x => x.DiscountOrderId, + principalSchema: "CMS", + principalTable: "DiscountOrders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DiscountOrderDetails_DiscountProducts_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "DiscountProducts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_DiscountCategories_ParentCategoryId", + schema: "CMS", + table: "DiscountCategories", + column: "ParentCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountOrderDetails_DiscountOrderId", + schema: "CMS", + table: "DiscountOrderDetails", + column: "DiscountOrderId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountOrderDetails_ProductId", + schema: "CMS", + table: "DiscountOrderDetails", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountOrders_TransactionId", + schema: "CMS", + table: "DiscountOrders", + column: "TransactionId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountOrders_UserAddressId", + schema: "CMS", + table: "DiscountOrders", + column: "UserAddressId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountOrders_UserId", + schema: "CMS", + table: "DiscountOrders", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountProductCategories_CategoryId", + schema: "CMS", + table: "DiscountProductCategories", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountProductCategories_ProductId_CategoryId", + schema: "CMS", + table: "DiscountProductCategories", + columns: new[] { "ProductId", "CategoryId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_DiscountShoppingCarts_ProductId", + schema: "CMS", + table: "DiscountShoppingCarts", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountShoppingCarts_UserId_ProductId", + schema: "CMS", + table: "DiscountShoppingCarts", + columns: new[] { "UserId", "ProductId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ProductCategories_CategoryId", + schema: "CMS", + table: "ProductCategories", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductCategories_ProductId", + schema: "CMS", + table: "ProductCategories", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductGalleries_ProductId", + schema: "CMS", + table: "ProductGalleries", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductGalleries_ProductImageId", + schema: "CMS", + table: "ProductGalleries", + column: "ProductImageId"); + + migrationBuilder.CreateIndex( + name: "IX_Products_IsClubExclusive", + schema: "CMS", + table: "Products", + column: "IsClubExclusive"); + + migrationBuilder.CreateIndex( + name: "IX_ProductTags_ProductId", + schema: "CMS", + table: "ProductTags", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductTags_TagId", + schema: "CMS", + table: "ProductTags", + column: "TagId"); + + migrationBuilder.CreateIndex( + name: "IX_UserCarts_ProductId", + schema: "CMS", + table: "UserCarts", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_UserCarts_UserId", + schema: "CMS", + table: "UserCarts", + column: "UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_Categories_Categories_ParentId", + schema: "CMS", + table: "Categories", + column: "ParentId", + principalSchema: "CMS", + principalTable: "Categories", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DayaLoanContracts_Transactions_TransactionId", + schema: "CMS", + table: "DayaLoanContracts", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactions", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FactorDetails_Products_ProductId", + schema: "CMS", + table: "FactorDetails", + column: "ProductId", + principalSchema: "CMS", + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FactorDetails_UserOrders_OrderId", + schema: "CMS", + table: "FactorDetails", + column: "OrderId", + principalSchema: "CMS", + principalTable: "UserOrders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ManualPayments_Transactions_TransactionId", + schema: "CMS", + table: "ManualPayments", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_UserAddresses_Users_UserId", + schema: "CMS", + table: "UserAddresses", + column: "UserId", + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_UserOrders_Transactions_TransactionId", + schema: "CMS", + table: "UserOrders", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactions", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UserOrders_UserAddresses_UserAddressId", + schema: "CMS", + table: "UserOrders", + column: "UserAddressId", + principalSchema: "CMS", + principalTable: "UserAddresses", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UserPackagePurchases_Transactions_TransactionId", + schema: "CMS", + table: "UserPackagePurchases", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Categories_Categories_ParentId", + schema: "CMS", + table: "Categories"); + + migrationBuilder.DropForeignKey( + name: "FK_DayaLoanContracts_Transactions_TransactionId", + schema: "CMS", + table: "DayaLoanContracts"); + + migrationBuilder.DropForeignKey( + name: "FK_FactorDetails_Products_ProductId", + schema: "CMS", + table: "FactorDetails"); + + migrationBuilder.DropForeignKey( + name: "FK_FactorDetails_UserOrders_OrderId", + schema: "CMS", + table: "FactorDetails"); + + migrationBuilder.DropForeignKey( + name: "FK_ManualPayments_Transactions_TransactionId", + schema: "CMS", + table: "ManualPayments"); + + migrationBuilder.DropForeignKey( + name: "FK_UserAddresses_Users_UserId", + schema: "CMS", + table: "UserAddresses"); + + migrationBuilder.DropForeignKey( + name: "FK_UserOrders_Transactions_TransactionId", + schema: "CMS", + table: "UserOrders"); + + migrationBuilder.DropForeignKey( + name: "FK_UserOrders_UserAddresses_UserAddressId", + schema: "CMS", + table: "UserOrders"); + + migrationBuilder.DropForeignKey( + name: "FK_UserPackagePurchases_Transactions_TransactionId", + schema: "CMS", + table: "UserPackagePurchases"); + + migrationBuilder.DropTable( + name: "DiscountOrderDetails", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "DiscountProductCategories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "DiscountShoppingCarts", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "ProductCategories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "ProductGalleries", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "ProductTags", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "UserCarts", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "DiscountOrders", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "DiscountCategories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "DiscountProducts", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "ProductImages", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "Products", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "Transactions", + schema: "CMS"); + + migrationBuilder.DropPrimaryKey( + name: "PK_UserAddresses", + schema: "CMS", + table: "UserAddresses"); + + migrationBuilder.DropPrimaryKey( + name: "PK_FactorDetails", + schema: "CMS", + table: "FactorDetails"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Categories", + schema: "CMS", + table: "Categories"); + + migrationBuilder.RenameTable( + name: "UserAddresses", + schema: "CMS", + newName: "UserAddresss", + newSchema: "CMS"); + + migrationBuilder.RenameTable( + name: "FactorDetails", + schema: "CMS", + newName: "FactorDetailss", + newSchema: "CMS"); + + migrationBuilder.RenameTable( + name: "Categories", + schema: "CMS", + newName: "Categorys", + newSchema: "CMS"); + + migrationBuilder.RenameIndex( + name: "IX_UserAddresses_UserId", + schema: "CMS", + table: "UserAddresss", + newName: "IX_UserAddresss_UserId"); + + migrationBuilder.RenameIndex( + name: "IX_FactorDetails_ProductId", + schema: "CMS", + table: "FactorDetailss", + newName: "IX_FactorDetailss_ProductId"); + + migrationBuilder.RenameIndex( + name: "IX_FactorDetails_OrderId", + schema: "CMS", + table: "FactorDetailss", + newName: "IX_FactorDetailss_OrderId"); + + migrationBuilder.RenameIndex( + name: "IX_Categories_ParentId", + schema: "CMS", + table: "Categorys", + newName: "IX_Categorys_ParentId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_UserAddresss", + schema: "CMS", + table: "UserAddresss", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_FactorDetailss", + schema: "CMS", + table: "FactorDetailss", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Categorys", + schema: "CMS", + table: "Categorys", + column: "Id"); + + migrationBuilder.CreateTable( + name: "ProductImagess", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + ImagePath = table.Column(type: "nvarchar(max)", nullable: false), + ImageThumbnailPath = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + Title = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductImagess", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Productss", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClubDiscountPercent = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + Description = table.Column(type: "nvarchar(max)", nullable: false), + Discount = table.Column(type: "int", nullable: false), + FullInformation = table.Column(type: "nvarchar(max)", nullable: false), + ImagePath = table.Column(type: "nvarchar(max)", nullable: false), + IsClubExclusive = table.Column(type: "bit", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + Price = table.Column(type: "bigint", nullable: false), + Rate = table.Column(type: "int", nullable: false), + RemainingCount = table.Column(type: "int", nullable: false), + SaleCount = table.Column(type: "int", nullable: false), + ShortInfomation = table.Column(type: "nvarchar(max)", nullable: false), + ThumbnailPath = table.Column(type: "nvarchar(max)", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: false), + ViewCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Productss", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Transactionss", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Amount = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + Description = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + PaymentDate = table.Column(type: "datetime2", nullable: true), + PaymentStatus = table.Column(type: "int", nullable: false), + RefId = table.Column(type: "nvarchar(max)", nullable: true), + Type = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Transactionss", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ProductGalleryss", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductId = table.Column(type: "bigint", nullable: false), + ProductImageId = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductGalleryss", x => x.Id); + table.ForeignKey( + name: "FK_ProductGalleryss_ProductImagess_ProductImageId", + column: x => x.ProductImageId, + principalSchema: "CMS", + principalTable: "ProductImagess", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductGalleryss_Productss_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Productss", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "PruductCategorys", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CategoryId = table.Column(type: "bigint", nullable: false), + ProductId = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PruductCategorys", x => x.Id); + table.ForeignKey( + name: "FK_PruductCategorys_Categorys_CategoryId", + column: x => x.CategoryId, + principalSchema: "CMS", + principalTable: "Categorys", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PruductCategorys_Productss_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Productss", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "PruductTags", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductId = table.Column(type: "bigint", nullable: false), + TagId = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PruductTags", x => x.Id); + table.ForeignKey( + name: "FK_PruductTags_Productss_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Productss", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PruductTags_Tags_TagId", + column: x => x.TagId, + principalSchema: "CMS", + principalTable: "Tags", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserCartss", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProductId = table.Column(type: "bigint", nullable: false), + UserId = table.Column(type: "bigint", nullable: false), + Count = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserCartss", x => x.Id); + table.ForeignKey( + name: "FK_UserCartss_Productss_ProductId", + column: x => x.ProductId, + principalSchema: "CMS", + principalTable: "Productss", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UserCartss_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ProductGalleryss_ProductId", + schema: "CMS", + table: "ProductGalleryss", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductGalleryss_ProductImageId", + schema: "CMS", + table: "ProductGalleryss", + column: "ProductImageId"); + + migrationBuilder.CreateIndex( + name: "IX_Products_IsClubExclusive", + schema: "CMS", + table: "Productss", + column: "IsClubExclusive"); + + migrationBuilder.CreateIndex( + name: "IX_PruductCategorys_CategoryId", + schema: "CMS", + table: "PruductCategorys", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_PruductCategorys_ProductId", + schema: "CMS", + table: "PruductCategorys", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_PruductTags_ProductId", + schema: "CMS", + table: "PruductTags", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_PruductTags_TagId", + schema: "CMS", + table: "PruductTags", + column: "TagId"); + + migrationBuilder.CreateIndex( + name: "IX_UserCartss_ProductId", + schema: "CMS", + table: "UserCartss", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_UserCartss_UserId", + schema: "CMS", + table: "UserCartss", + column: "UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_Categorys_Categorys_ParentId", + schema: "CMS", + table: "Categorys", + column: "ParentId", + principalSchema: "CMS", + principalTable: "Categorys", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DayaLoanContracts_Transactionss_TransactionId", + schema: "CMS", + table: "DayaLoanContracts", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactionss", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FactorDetailss_Productss_ProductId", + schema: "CMS", + table: "FactorDetailss", + column: "ProductId", + principalSchema: "CMS", + principalTable: "Productss", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FactorDetailss_UserOrders_OrderId", + schema: "CMS", + table: "FactorDetailss", + column: "OrderId", + principalSchema: "CMS", + principalTable: "UserOrders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ManualPayments_Transactionss_TransactionId", + schema: "CMS", + table: "ManualPayments", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactionss", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_UserAddresss_Users_UserId", + schema: "CMS", + table: "UserAddresss", + column: "UserId", + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_UserOrders_Transactionss_TransactionId", + schema: "CMS", + table: "UserOrders", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactionss", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UserOrders_UserAddresss_UserAddressId", + schema: "CMS", + table: "UserOrders", + column: "UserAddressId", + principalSchema: "CMS", + principalTable: "UserAddresss", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UserPackagePurchases_Transactionss_TransactionId", + schema: "CMS", + table: "UserPackagePurchases", + column: "TransactionId", + principalSchema: "CMS", + principalTable: "Transactionss", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index df19feb..73fc53c 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -73,7 +73,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("ParentId"); - b.ToTable("Categorys", "CMS"); + b.ToTable("Categories", "CMS"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => @@ -142,6 +142,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("CreatedBy") .HasColumnType("nvarchar(max)"); + b.Property("GiftValue") + .HasColumnType("bigint"); + b.Property("InitialContribution") .HasColumnType("bigint"); @@ -612,6 +615,347 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("DayaLoanContracts", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ImagePath") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentCategoryId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("ParentCategoryId"); + + b.ToTable("DiscountCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("DiscountBalanceUsed") + .HasColumnType("bigint"); + + b.Property("GatewayAmountPaid") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("TrackingCode") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("VatAmount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("DiscountOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrderDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountOrderId") + .HasColumnType("bigint"); + + b.Property("DiscountPercentUsed") + .HasColumnType("int"); + + b.Property("FinalPrice") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DiscountOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("DiscountOrderDetails", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("FullInformation") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ImagePath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxDiscountPercent") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("DiscountProducts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId", "CategoryId") + .IsUnique(); + + b.ToTable("DiscountProductCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId", "ProductId") + .IsUnique(); + + b.ToTable("DiscountShoppingCarts", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => { b.Property("Id") @@ -662,7 +1006,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("ProductId"); - b.ToTable("FactorDetailss", "CMS"); + b.ToTable("FactorDetails", "CMS"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => @@ -928,6 +1272,98 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("SystemConfigurationHistories", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Message.PublicMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedByUserId") + .HasColumnType("bigint"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LinkText") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LinkUrl") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("ViewCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId") + .HasDatabaseName("IX_PublicMessages_CreatedByUserId"); + + b.HasIndex("ExpiresAt") + .HasDatabaseName("IX_PublicMessages_ExpiresAt"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_PublicMessages_IsActive"); + + b.HasIndex("Priority") + .HasDatabaseName("IX_PublicMessages_Priority"); + + b.HasIndex("StartsAt") + .HasDatabaseName("IX_PublicMessages_StartsAt"); + + b.HasIndex("Type") + .HasDatabaseName("IX_PublicMessages_Type"); + + b.HasIndex("IsActive", "ExpiresAt") + .HasDatabaseName("IX_PublicMessages_IsActive_ExpiresAt"); + + b.ToTable("PublicMessages", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => { b.Property("Id") @@ -1016,6 +1452,71 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("NetworkWeeklyBalances", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Order.OrderVAT", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BaseAmount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsPaid") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("VATAmount") + .HasColumnType("bigint"); + + b.Property("VATRate") + .HasColumnType("decimal(5,4)"); + + b.HasKey("Id"); + + b.HasIndex("Created") + .HasDatabaseName("IX_OrderVATs_Created"); + + b.HasIndex("IsPaid") + .HasDatabaseName("IX_OrderVATs_IsPaid"); + + b.HasIndex("OrderId") + .IsUnique() + .HasDatabaseName("IX_OrderVATs_OrderId"); + + b.ToTable("OrderVATs", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b => { b.Property("Id") @@ -1108,7 +1609,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Packages", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1116,12 +1617,26 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedBy") + .HasColumnType("bigint"); + b.Property("Created") .HasColumnType("datetime2"); b.Property("CreatedBy") .HasColumnType("nvarchar(max)"); + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + b.Property("IsDeleted") .HasColumnType("bit"); @@ -1131,62 +1646,49 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("LastModifiedBy") .HasColumnType("nvarchar(max)"); - b.Property("ProductId") + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RequestedBy") .HasColumnType("bigint"); - b.Property("ProductImageId") + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") .HasColumnType("bigint"); b.HasKey("Id"); - b.HasIndex("ProductId"); + b.HasIndex("ApprovedBy"); - b.HasIndex("ProductImageId"); + b.HasIndex("Created"); - b.ToTable("ProductGalleryss", "CMS"); + b.HasIndex("RequestedBy"); + + b.HasIndex("Status"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.HasIndex("UserId", "Status"); + + b.ToTable("ManualPayments", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("ImagePath") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ImageThumbnailPath") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("ProductImagess", "CMS"); - }); - - modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Product", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1262,10 +1764,10 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("IsClubExclusive") .HasDatabaseName("IX_Products_IsClubExclusive"); - b.ToTable("Productss", "CMS"); + b.ToTable("Products", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductCategory", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1300,10 +1802,88 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("ProductId"); - b.ToTable("PruductCategorys", "CMS"); + b.ToTable("ProductCategories", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleries", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductTag", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1338,7 +1918,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("TagId"); - b.ToTable("PruductTags", "CMS"); + b.ToTable("ProductTags", "CMS"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => @@ -1422,7 +2002,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Tags", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transaction", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1466,7 +2046,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasKey("Id"); - b.ToTable("Transactionss", "CMS"); + b.ToTable("Transactions", "CMS"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => @@ -1544,9 +2124,6 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("PackagePurchaseMethod") .HasColumnType("int"); - b.Property("ParentId") - .HasColumnType("bigint"); - b.Property("PushNotifications") .HasColumnType("bit"); @@ -1568,8 +2145,6 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("NetworkParentId") .HasDatabaseName("IX_User_NetworkParentId"); - b.HasIndex("ParentId"); - b.ToTable("Users", "CMS"); }); @@ -1621,10 +2196,10 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("UserId"); - b.ToTable("UserAddresss", "CMS"); + b.ToTable("UserAddresses", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCart", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1662,7 +2237,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("UserId"); - b.ToTable("UserCartss", "CMS"); + b.ToTable("UserCarts", "CMS"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => @@ -1734,6 +2309,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("DeliveryStatus") .HasColumnType("int"); + b.Property("HasVAT") + .HasColumnType("bit"); + b.Property("IsDeleted") .HasColumnType("bit"); @@ -1743,6 +2321,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("LastModifiedBy") .HasColumnType("nvarchar(max)"); + b.Property("OrderVATId") + .HasColumnType("bigint"); + b.Property("PackageId") .HasColumnType("bigint"); @@ -1769,6 +2350,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasKey("Id"); + b.HasIndex("OrderVATId"); + b.HasIndex("PackageId"); b.HasIndex("TransactionId"); @@ -1780,6 +2363,71 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("UserOrders", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => { b.Property("Id") @@ -1920,7 +2568,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => { b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") - .WithMany("Categorys") + .WithMany("Categories") .HasForeignKey("ParentId"); b.Navigation("Parent"); @@ -1985,7 +2633,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => { - b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") .WithMany() .HasForeignKey("TransactionId"); @@ -2000,16 +2648,109 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", "ParentCategory") + .WithMany("ChildCategories") + .HasForeignKey("ParentCategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ParentCategory"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany() + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DiscountOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrderDetail", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", "DiscountOrder") + .WithMany("OrderDetails") + .HasForeignKey("DiscountOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("OrderDetails") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DiscountOrder"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", "Category") + .WithMany("ProductCategories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("ProductCategories") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("ShoppingCarts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DiscountShoppingCarts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => { b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") - .WithMany("FactorDetailss") + .WithMany("FactorDetails") .HasForeignKey("OrderId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") - .WithMany("FactorDetailss") + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("FactorDetails") .HasForeignKey("ProductId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -2063,35 +2804,45 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Order.OrderVAT", b => { - b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") - .WithMany("ProductGalleryss") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithOne() + .HasForeignKey("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderId") + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") - .WithMany("ProductGalleryss") - .HasForeignKey("ProductImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("ProductImage"); + b.Navigation("Order"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductCategory", b => { b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") - .WithMany("PruductCategorys") + .WithMany("ProductCategories") .HasForeignKey("CategoryId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") - .WithMany("PruductCategorys") + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductCategories") .HasForeignKey("ProductId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -2101,16 +2852,35 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallery", b => { - b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") - .WithMany("PruductTags") + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductGalleries") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImage", "ProductImage") + .WithMany("ProductGalleries") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductTags") .HasForeignKey("ProductId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") - .WithMany("PruductTags") + .WithMany("ProductTags") .HasForeignKey("TagId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -2127,19 +2897,13 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations .HasForeignKey("NetworkParentId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("CMSMicroservice.Domain.Entities.User", "Parent") - .WithMany("Users") - .HasForeignKey("ParentId"); - b.Navigation("NetworkParent"); - - b.Navigation("Parent"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => { b.HasOne("CMSMicroservice.Domain.Entities.User", "User") - .WithMany("UserAddresss") + .WithMany("UserAddresses") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -2147,16 +2911,16 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCart", b => { - b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") - .WithMany("UserCartss") + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("UserCarts") .HasForeignKey("ProductId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("CMSMicroservice.Domain.Entities.User", "User") - .WithMany("UserCartss") + .WithMany("UserCarts") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -2187,11 +2951,15 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => { + b.HasOne("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderVAT") + .WithMany() + .HasForeignKey("OrderVATId"); + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") .WithMany("UserOrders") .HasForeignKey("PackageId"); - b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") .WithMany("UserOrders") .HasForeignKey("TransactionId"); @@ -2207,6 +2975,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("OrderVAT"); + b.Navigation("Package"); b.Navigation("Transaction"); @@ -2216,6 +2986,39 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("UserAddress"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => { b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") @@ -2259,9 +3062,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => { - b.Navigation("Categorys"); + b.Navigation("Categories"); - b.Navigation("PruductCategorys"); + b.Navigation("ProductCategories"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => @@ -2296,27 +3099,48 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("UserContracts"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.Navigation("ChildCategories"); + + b.Navigation("ProductCategories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.Navigation("OrderDetails"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", b => + { + b.Navigation("OrderDetails"); + + b.Navigation("ProductCategories"); + + b.Navigation("ShoppingCarts"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => { b.Navigation("UserOrders"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Product", b => { - b.Navigation("ProductGalleryss"); + b.Navigation("FactorDetails"); + + b.Navigation("ProductCategories"); + + b.Navigation("ProductGalleries"); + + b.Navigation("ProductTags"); + + b.Navigation("UserCarts"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImage", b => { - b.Navigation("FactorDetailss"); - - b.Navigation("ProductGalleryss"); - - b.Navigation("PruductCategorys"); - - b.Navigation("PruductTags"); - - b.Navigation("UserCartss"); + b.Navigation("ProductGalleries"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => @@ -2326,10 +3150,10 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => { - b.Navigation("PruductTags"); + b.Navigation("ProductTags"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transaction", b => { b.Navigation("UserOrders"); }); @@ -2342,13 +3166,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("DayaLoanContracts"); + b.Navigation("DiscountOrders"); + + b.Navigation("DiscountShoppingCarts"); + b.Navigation("NetworkChildren"); b.Navigation("NetworkWeeklyBalances"); - b.Navigation("UserAddresss"); + b.Navigation("UserAddresses"); - b.Navigation("UserCartss"); + b.Navigation("UserCarts"); b.Navigation("UserClubFeatures"); @@ -2359,8 +3187,6 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("UserRoles"); b.Navigation("UserWallets"); - - b.Navigation("Users"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => @@ -2370,7 +3196,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => { - b.Navigation("FactorDetailss"); + b.Navigation("FactorDetails"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => diff --git a/src/CMSMicroservice.Infrastructure/Services/Payment/BankMellatPaymentService.cs b/src/CMSMicroservice.Infrastructure/Services/Payment/BankMellatPaymentService.cs deleted file mode 100644 index e47ae3b..0000000 --- a/src/CMSMicroservice.Infrastructure/Services/Payment/BankMellatPaymentService.cs +++ /dev/null @@ -1,367 +0,0 @@ -using CMSMicroservice.Application.Common.Interfaces; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using System.Net.Http; -using System.Net.Http.Json; -using System.Text; -using System.Xml.Linq; - -namespace CMSMicroservice.Infrastructure.Services.Payment; - -/// -/// Real Implementation برای درگاه پرداخت بانک ملت (IPG) -/// بانک ملت از SOAP Web Service استفاده می‌کند -/// برای فعال‌سازی: باید TerminalId, Username, Password را در appsettings.json تنظیم کنید -/// -public class BankMellatPaymentService : IPaymentGatewayService -{ - private readonly HttpClient _httpClient; - private readonly IConfiguration _configuration; - private readonly ILogger _logger; - private readonly string _terminalId; - private readonly string _username; - private readonly string _password; - private readonly string _serviceUrl; - - public BankMellatPaymentService( - HttpClient httpClient, - IConfiguration configuration, - ILogger logger) - { - _httpClient = httpClient; - _configuration = configuration; - _logger = logger; - - // خواندن تنظیمات از appsettings.json - _terminalId = _configuration["BankMellat:TerminalId"] ?? throw new InvalidOperationException( - "BankMellat:TerminalId is not configured"); - _username = _configuration["BankMellat:Username"] ?? throw new InvalidOperationException( - "BankMellat:Username is not configured"); - _password = _configuration["BankMellat:Password"] ?? throw new InvalidOperationException( - "BankMellat:Password is not configured"); - _serviceUrl = _configuration["BankMellat:ServiceUrl"] ?? "https://bpm.shaparak.ir/pgwchannel/services/pgw"; - - _httpClient.Timeout = TimeSpan.FromSeconds(30); - } - - public async Task InitiatePaymentAsync( - PaymentRequest request, - CancellationToken cancellationToken = default) - { - try - { - _logger.LogInformation( - "Initiating Bank Mellat payment: UserId={UserId}, Amount={Amount}", - request.UserId, request.Amount); - - // تبدیل مبلغ به ریال (بانک ملت ریال می‌خواهد) - var amountInRials = (long)(request.Amount * 10); - var localDate = DateTime.Now.ToString("yyyyMMdd"); - var localTime = DateTime.Now.ToString("HHmmss"); - var orderId = $"{request.UserId}_{DateTime.Now.Ticks}"; - - // ساخت SOAP Request - var soapRequest = $@" - - - - {_terminalId} - {_username} - {_password} - {orderId} - {amountInRials} - {localDate} - {localTime} - {request.Description} - {request.CallbackUrl} - 0 - - - "; - - var content = new StringContent(soapRequest, Encoding.UTF8, "text/xml"); - content.Headers.Add("SOAPAction", "http://interfaces.core.sw.bps.com/IPaymentGateway/bpPayRequest"); - - var response = await _httpClient.PostAsync(_serviceUrl, content, cancellationToken); - - if (!response.IsSuccessStatusCode) - { - _logger.LogError( - "Bank Mellat API error: StatusCode={StatusCode}", - response.StatusCode); - - return new PaymentInitiateResult - { - IsSuccess = false, - ErrorMessage = $"خطا در ارتباط با بانک ملت: {response.StatusCode}" - }; - } - - var responseContent = await response.Content.ReadAsStringAsync(cancellationToken); - var refId = ParseSoapResponse(responseContent, "return"); - - // بررسی کد خطا - if (string.IsNullOrEmpty(refId) || !long.TryParse(refId, out var refIdNumber)) - { - _logger.LogError("Invalid RefId from Bank Mellat: {RefId}", refId); - return new PaymentInitiateResult - { - IsSuccess = false, - ErrorMessage = "پاسخ نامعتبر از بانک ملت" - }; - } - - if (refIdNumber < 0) - { - var errorMessage = GetBankMellatErrorMessage(refIdNumber.ToString()); - _logger.LogError("Bank Mellat error code: {ErrorCode} - {Message}", refIdNumber, errorMessage); - return new PaymentInitiateResult - { - IsSuccess = false, - ErrorMessage = errorMessage - }; - } - - _logger.LogInformation( - "Bank Mellat payment initiated successfully: RefId={RefId}", - refId); - - // URL درگاه بانک ملت - var gatewayUrl = $"https://bpm.shaparak.ir/pgwchannel/startpay.mellat?RefId={refId}"; - - return new PaymentInitiateResult - { - IsSuccess = true, - RefId = refId, - GatewayUrl = gatewayUrl, - ErrorMessage = null - }; - } - catch (Exception ex) - { - _logger.LogError(ex, "Error in InitiatePaymentAsync"); - return new PaymentInitiateResult - { - IsSuccess = false, - ErrorMessage = "خطای غیرمنتظره در برقراری ارتباط با بانک" - }; - } - } - - public async Task VerifyPaymentAsync( - string refId, - string verificationToken, - CancellationToken cancellationToken = default) - { - try - { - _logger.LogInformation("Verifying Bank Mellat payment: RefId={RefId}", refId); - - // ساخت SOAP Request برای Verify - var soapRequest = $@" - - - - {_terminalId} - {_username} - {_password} - {verificationToken} - {verificationToken} - {refId} - - - "; - - var content = new StringContent(soapRequest, Encoding.UTF8, "text/xml"); - content.Headers.Add("SOAPAction", "http://interfaces.core.sw.bps.com/IPaymentGateway/bpVerifyRequest"); - - var response = await _httpClient.PostAsync(_serviceUrl, content, cancellationToken); - var responseContent = await response.Content.ReadAsStringAsync(cancellationToken); - var result = ParseSoapResponse(responseContent, "return"); - - var isSuccess = result == "0"; // 0 = موفق - - if (isSuccess) - { - // اگر Verify موفق بود، باید Settle کنیم - await SettlePaymentAsync(refId, verificationToken, cancellationToken); - } - - _logger.LogInformation( - "Bank Mellat verification result: RefId={RefId}, IsSuccess={IsSuccess}", - refId, isSuccess); - - return new PaymentVerificationResult - { - IsSuccess = isSuccess, - RefId = refId, - TrackingCode = refId, - Amount = 0, // مبلغ باید از Database بیاید - Message = isSuccess ? "تراکنش موفق" : GetBankMellatErrorMessage(result) - }; - } - catch (Exception ex) - { - _logger.LogError(ex, "Error in VerifyPaymentAsync"); - return new PaymentVerificationResult - { - IsSuccess = false, - RefId = refId, - Message = "خطا در تأیید پرداخت" - }; - } - } - - private async Task SettlePaymentAsync(string refId, string orderId, CancellationToken cancellationToken) - { - try - { - var soapRequest = $@" - - - - {_terminalId} - {_username} - {_password} - {orderId} - {orderId} - {refId} - - - "; - - var content = new StringContent(soapRequest, Encoding.UTF8, "text/xml"); - content.Headers.Add("SOAPAction", "http://interfaces.core.sw.bps.com/IPaymentGateway/bpSettleRequest"); - - var response = await _httpClient.PostAsync(_serviceUrl, content, cancellationToken); - var responseContent = await response.Content.ReadAsStringAsync(cancellationToken); - var result = ParseSoapResponse(responseContent, "return"); - - var isSuccess = result == "0"; - _logger.LogInformation( - "Bank Mellat settle result: RefId={RefId}, IsSuccess={IsSuccess}", - refId, isSuccess); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error in SettlePaymentAsync"); - } - } - - public async Task ProcessPayoutAsync( - PayoutRequest request, - CancellationToken cancellationToken = default) - { - try - { - _logger.LogInformation( - "Processing Bank Mellat payout: UserId={UserId}, Amount={Amount}, IBAN={Iban}", - request.UserId, request.Amount, request.Iban); - - // Validation - if (!request.Iban.StartsWith("IR") || request.Iban.Length != 26) - { - return new PayoutResult - { - IsSuccess = false, - Message = "فرمت شماره شبا نامعتبر است", - ProcessedAt = DateTime.UtcNow - }; - } - - if (request.Amount < 10_000) - { - return new PayoutResult - { - IsSuccess = false, - Message = "حداقل مبلغ برداشت 10,000 تومان است", - ProcessedAt = DateTime.UtcNow - }; - } - - // TODO: بانک ملت ممکن است API واریز مستقیم نداشته باشد - // در این صورت باید از Shaparak Paya (سامانه پایا) استفاده کرد - // یا از سرویس‌های واسط مانند Fanapay, IPG.ir استفاده شود - - _logger.LogWarning( - "Bank Mellat direct payout is not supported. Use Shaparak Paya or third-party service."); - - return new PayoutResult - { - IsSuccess = false, - Message = "واریز مستقیم از طریق بانک ملت پشتیبانی نمی‌شود. از سامانه پایا استفاده کنید.", - ProcessedAt = DateTime.UtcNow - }; - } - catch (Exception ex) - { - _logger.LogError(ex, "Error in ProcessPayoutAsync"); - return new PayoutResult - { - IsSuccess = false, - Message = "خطا در پردازش واریز", - ProcessedAt = DateTime.UtcNow - }; - } - } - - // Helper method to parse SOAP XML response - private string ParseSoapResponse(string soapResponse, string elementName) - { - try - { - var doc = XDocument.Parse(soapResponse); - var ns = doc.Root?.GetDefaultNamespace(); - var element = doc.Descendants(ns + elementName).FirstOrDefault(); - return element?.Value ?? string.Empty; - } - catch - { - return string.Empty; - } - } - - // کدهای خطای بانک ملت - private string GetBankMellatErrorMessage(string errorCode) - { - return errorCode switch - { - "0" => "تراکنش موفق", - "11" => "شماره کارت نامعتبر است", - "12" => "موجودی کافی نیست", - "13" => "رمز نادرست است", - "14" => "تعداد دفعات وارد کردن رمز بیش از حد مجاز است", - "15" => "کارت نامعتبر است", - "16" => "دفعات برداشت وجه بیش از حد مجاز است", - "17" => "کاربر از انجام تراکنش منصرف شده است", - "18" => "تاریخ انقضای کارت گذشته است", - "19" => "مبلغ برداشت وجه بیش از حد مجاز است", - "21" => "پذیرنده نامعتبر است", - "23" => "خطای امنیتی رخ داده است", - "24" => "اطلاعات کاربری پذیرنده نامعتبر است", - "25" => "مبلغ نامعتبر است", - "31" => "پاسخ نامعتبر است", - "32" => "فرمت اطلاعات وارد شده صحیح نمی‌باشد", - "33" => "حساب نامعتبر است", - "34" => "خطای سیستمی", - "35" => "تاریخ نامعتبر است", - "41" => "شماره درخواست تکراری است", - "42" => "تراکنش یافت نشد", - "43" => "قبلا درخواست Verify داده شده است", - "44" => "درخواست Verify یافت نشد", - "45" => "تراکنش Settle شده است", - "46" => "تراکنش Settle نشده است", - "47" => "تراکنش Settle یافت نشد", - "48" => "تراکنش Reverse شده است", - "49" => "تراکنش Refund یافت نشد", - "51" => "تراکنش تکراری است", - "54" => "تراکنش مرجع موجود نیست", - "55" => "تراکنش نامعتبر است", - "61" => "خطا در واریز", - _ => $"خطای ناشناخته: {errorCode}" - }; - } -} diff --git a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj index 2855011..00796a5 100644 --- a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj +++ b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj @@ -31,7 +31,7 @@ - + @@ -39,15 +39,20 @@ - + - + + + + + + diff --git a/src/CMSMicroservice.Protobuf/Protos/discountcategory.proto b/src/CMSMicroservice.Protobuf/Protos/discountcategory.proto new file mode 100644 index 0000000..c245817 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/discountcategory.proto @@ -0,0 +1,100 @@ +syntax = "proto3"; + +package discountcategory; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.DiscountCategory"; + +service DiscountCategoryContract +{ + rpc CreateDiscountCategory(CreateDiscountCategoryRequest) returns (CreateDiscountCategoryResponse){ + option (google.api.http) = { + post: "/CreateDiscountCategory" + body: "*" + }; + }; + rpc UpdateDiscountCategory(UpdateDiscountCategoryRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + put: "/UpdateDiscountCategory" + body: "*" + }; + }; + rpc DeleteDiscountCategory(DeleteDiscountCategoryRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + delete: "/DeleteDiscountCategory" + body: "*" + }; + }; + rpc GetDiscountCategories(GetDiscountCategoriesRequest) returns (GetDiscountCategoriesResponse){ + option (google.api.http) = { + get: "/GetDiscountCategories" + }; + }; +} + +// Create Category +message CreateDiscountCategoryRequest +{ + string name = 1; + string title = 2; + google.protobuf.StringValue description = 3; + google.protobuf.StringValue image_path = 4; + google.protobuf.Int64Value parent_category_id = 5; + int32 sort_order = 6; + bool is_active = 7; +} + +message CreateDiscountCategoryResponse +{ + int64 category_id = 1; +} + +// Update Category +message UpdateDiscountCategoryRequest +{ + int64 category_id = 1; + string name = 2; + string title = 3; + google.protobuf.StringValue description = 4; + google.protobuf.StringValue image_path = 5; + google.protobuf.Int64Value parent_category_id = 6; + int32 sort_order = 7; + bool is_active = 8; +} + +// Delete Category +message DeleteDiscountCategoryRequest +{ + int64 category_id = 1; +} + +// Get Categories with Tree Structure +message GetDiscountCategoriesRequest +{ + google.protobuf.Int64Value parent_category_id = 1; // null = root categories + google.protobuf.BoolValue is_active = 2; +} + +message GetDiscountCategoriesResponse +{ + repeated DiscountCategoryDto categories = 1; +} + +message DiscountCategoryDto +{ + int64 id = 1; + string name = 2; + string title = 3; + google.protobuf.StringValue description = 4; + google.protobuf.StringValue image_path = 5; + google.protobuf.Int64Value parent_category_id = 6; + int32 sort_order = 7; + bool is_active = 8; + int32 product_count = 9; + repeated DiscountCategoryDto children = 10; // Recursive children +} diff --git a/src/CMSMicroservice.Protobuf/Protos/discountorder.proto b/src/CMSMicroservice.Protobuf/Protos/discountorder.proto new file mode 100644 index 0000000..e84b4ff --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/discountorder.proto @@ -0,0 +1,177 @@ +syntax = "proto3"; + +package discountorder; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.DiscountOrder"; + +service DiscountOrderContract +{ + rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse){ + option (google.api.http) = { + post: "/PlaceOrder" + body: "*" + }; + }; + rpc CompleteOrderPayment(CompleteOrderPaymentRequest) returns (CompleteOrderPaymentResponse){ + option (google.api.http) = { + post: "/CompleteOrderPayment" + body: "*" + }; + }; + rpc UpdateOrderStatus(UpdateOrderStatusRequest) returns (UpdateOrderStatusResponse){ + option (google.api.http) = { + put: "/UpdateOrderStatus" + body: "*" + }; + }; + rpc GetOrderById(GetOrderByIdRequest) returns (GetOrderByIdResponse){ + option (google.api.http) = { + get: "/GetOrderById" + }; + }; + rpc GetUserOrders(GetUserOrdersRequest) returns (GetUserOrdersResponse){ + option (google.api.http) = { + get: "/GetUserOrders" + }; + }; +} + +// Place Order (Initial Step - Create Order) +message PlaceOrderRequest +{ + int64 user_id = 1; + int64 user_address_id = 2; + int64 discount_balance_to_use = 3; // Amount from DiscountBalance wallet + google.protobuf.StringValue notes = 4; +} + +message PlaceOrderResponse +{ + bool success = 1; + string message = 2; + int64 order_id = 3; + int64 gateway_amount = 4; // Amount to pay via gateway (if any) + google.protobuf.StringValue payment_url = 5; // Payment gateway URL (if needed) +} + +// Complete Order Payment (After Gateway Callback) +message CompleteOrderPaymentRequest +{ + int64 order_id = 1; + google.protobuf.StringValue transaction_id = 2; + bool payment_success = 3; +} + +message CompleteOrderPaymentResponse +{ + bool success = 1; + string message = 2; +} + +// Update Order Status (Admin) +message UpdateOrderStatusRequest +{ + int64 order_id = 1; + DeliveryStatus delivery_status = 2; + google.protobuf.StringValue tracking_code = 3; + google.protobuf.StringValue admin_notes = 4; +} + +message UpdateOrderStatusResponse +{ + bool success = 1; + string message = 2; +} + +enum DeliveryStatus +{ + DELIVERY_PENDING = 0; + DELIVERY_PROCESSING = 1; + DELIVERY_SHIPPED = 2; + DELIVERY_DELIVERED = 3; + DELIVERY_CANCELLED = 4; +} + +// Get Order By Id +message GetOrderByIdRequest +{ + int64 order_id = 1; + int64 user_id = 2; // For authorization check +} + +message GetOrderByIdResponse +{ + int64 id = 1; + int64 user_id = 2; + string order_number = 3; + AddressInfo address = 4; + int64 total_price = 5; + int64 discount_balance_used = 6; + int64 gateway_amount = 7; + bool payment_completed = 8; + google.protobuf.StringValue transaction_id = 9; + DeliveryStatus delivery_status = 10; + google.protobuf.StringValue tracking_code = 11; + google.protobuf.StringValue notes = 12; + google.protobuf.StringValue admin_notes = 13; + repeated OrderItemDto items = 14; + google.protobuf.Timestamp created = 15; + google.protobuf.Timestamp last_modified = 16; +} + +message AddressInfo +{ + int64 id = 1; + string title = 2; + string address = 3; + string postal_code = 4; + google.protobuf.StringValue phone = 5; +} + +message OrderItemDto +{ + int64 product_id = 1; + string product_title = 2; + int64 unit_price = 3; + int32 max_discount_percent = 4; + int32 count = 5; + int64 total_price = 6; + int64 discount_amount = 7; + int64 final_price = 8; +} + +// Get User Orders +message GetUserOrdersRequest +{ + int64 user_id = 1; + google.protobuf.BoolValue payment_completed = 2; + google.protobuf.Int32Value delivery_status = 3; // DeliveryStatus as int + int32 page_number = 4; + int32 page_size = 5; +} + +message GetUserOrdersResponse +{ + messages.MetaData meta_data = 1; + repeated OrderSummaryDto models = 2; +} + +message OrderSummaryDto +{ + int64 id = 1; + string order_number = 2; + int64 total_price = 3; + int64 discount_balance_used = 4; + int64 gateway_amount = 5; + bool payment_completed = 6; + DeliveryStatus delivery_status = 7; + google.protobuf.StringValue tracking_code = 8; + int32 items_count = 9; + google.protobuf.Timestamp created = 10; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/discountproduct.proto b/src/CMSMicroservice.Protobuf/Protos/discountproduct.proto new file mode 100644 index 0000000..1e3048c --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/discountproduct.proto @@ -0,0 +1,152 @@ +syntax = "proto3"; + +package discountproduct; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.DiscountProduct"; + +service DiscountProductContract +{ + rpc CreateDiscountProduct(CreateDiscountProductRequest) returns (CreateDiscountProductResponse){ + option (google.api.http) = { + post: "/CreateDiscountProduct" + body: "*" + }; + }; + rpc UpdateDiscountProduct(UpdateDiscountProductRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + put: "/UpdateDiscountProduct" + body: "*" + }; + }; + rpc DeleteDiscountProduct(DeleteDiscountProductRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + delete: "/DeleteDiscountProduct" + body: "*" + }; + }; + rpc GetDiscountProductById(GetDiscountProductByIdRequest) returns (GetDiscountProductByIdResponse){ + option (google.api.http) = { + get: "/GetDiscountProductById" + }; + }; + rpc GetDiscountProducts(GetDiscountProductsRequest) returns (GetDiscountProductsResponse){ + option (google.api.http) = { + get: "/GetDiscountProducts" + }; + }; +} + +// Create Product +message CreateDiscountProductRequest +{ + string title = 1; + string short_infomation = 2; + string full_information = 3; + int64 price = 4; + int32 max_discount_percent = 5; + string image_path = 6; + string thumbnail_path = 7; + int32 initial_count = 8; + int32 sort_order = 9; + bool is_active = 10; + repeated int64 category_ids = 11; +} + +message CreateDiscountProductResponse +{ + int64 product_id = 1; +} + +// Update Product +message UpdateDiscountProductRequest +{ + int64 product_id = 1; + string title = 2; + string short_infomation = 3; + string full_information = 4; + int64 price = 5; + int32 max_discount_percent = 6; + string image_path = 7; + string thumbnail_path = 8; + int32 sort_order = 9; + bool is_active = 10; + repeated int64 category_ids = 11; +} + +// Delete Product +message DeleteDiscountProductRequest +{ + int64 product_id = 1; +} + +// Get Product By Id +message GetDiscountProductByIdRequest +{ + int64 product_id = 1; + int64 user_id = 2; // Optional for view count tracking +} + +message GetDiscountProductByIdResponse +{ + int64 id = 1; + string title = 2; + string short_infomation = 3; + string full_information = 4; + int64 price = 5; + int32 max_discount_percent = 6; + string image_path = 7; + string thumbnail_path = 8; + int32 remaining_count = 9; + int32 view_count = 10; + int32 sort_order = 11; + bool is_active = 12; + repeated CategoryInfo categories = 13; + google.protobuf.Timestamp created = 14; +} + +message CategoryInfo +{ + int64 id = 1; + string name = 2; + string title = 3; +} + +// Get Products with Filters +message GetDiscountProductsRequest +{ + google.protobuf.Int64Value category_id = 1; + google.protobuf.StringValue search_query = 2; + google.protobuf.Int64Value min_price = 3; + google.protobuf.Int64Value max_price = 4; + google.protobuf.BoolValue is_active = 5; + google.protobuf.BoolValue in_stock = 6; + int32 page_number = 7; + int32 page_size = 8; +} + +message GetDiscountProductsResponse +{ + messages.MetaData meta_data = 1; + repeated DiscountProductDto models = 2; +} + +message DiscountProductDto +{ + int64 id = 1; + string title = 2; + string short_infomation = 3; + int64 price = 4; + int32 max_discount_percent = 5; + string image_path = 6; + string thumbnail_path = 7; + int32 remaining_count = 8; + int32 view_count = 9; + bool is_active = 10; + google.protobuf.Timestamp created = 11; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/discountshoppingcart.proto b/src/CMSMicroservice.Protobuf/Protos/discountshoppingcart.proto new file mode 100644 index 0000000..182d396 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/discountshoppingcart.proto @@ -0,0 +1,120 @@ +syntax = "proto3"; + +package discountshoppingcart; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.DiscountShoppingCart"; + +service DiscountShoppingCartContract +{ + rpc AddToCart(AddToCartRequest) returns (AddToCartResponse){ + option (google.api.http) = { + post: "/AddToCart" + body: "*" + }; + }; + rpc RemoveFromCart(RemoveFromCartRequest) returns (RemoveFromCartResponse){ + option (google.api.http) = { + delete: "/RemoveFromCart" + body: "*" + }; + }; + rpc UpdateCartItemCount(UpdateCartItemCountRequest) returns (UpdateCartItemCountResponse){ + option (google.api.http) = { + put: "/UpdateCartItemCount" + body: "*" + }; + }; + rpc GetUserCart(GetUserCartRequest) returns (GetUserCartResponse){ + option (google.api.http) = { + get: "/GetUserCart" + }; + }; + rpc ClearCart(ClearCartRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + delete: "/ClearCart" + body: "*" + }; + }; +} + +// Add to Cart +message AddToCartRequest +{ + int64 user_id = 1; + int64 product_id = 2; + int32 count = 3; +} + +message AddToCartResponse +{ + bool success = 1; + string message = 2; +} + +// Remove from Cart +message RemoveFromCartRequest +{ + int64 user_id = 1; + int64 product_id = 2; +} + +message RemoveFromCartResponse +{ + bool success = 1; + string message = 2; +} + +// Update Cart Item Count +message UpdateCartItemCountRequest +{ + int64 user_id = 1; + int64 product_id = 2; + int32 new_count = 3; +} + +message UpdateCartItemCountResponse +{ + bool success = 1; + string message = 2; +} + +// Get User Cart +message GetUserCartRequest +{ + int64 user_id = 1; +} + +message GetUserCartResponse +{ + repeated CartItemDto items = 1; + int64 total_price = 2; + int64 total_discount_amount = 3; + int64 final_price = 4; +} + +message CartItemDto +{ + int64 product_id = 1; + string product_title = 2; + string product_image_path = 3; + int64 unit_price = 4; + int32 max_discount_percent = 5; + int32 count = 6; + int64 total_price = 7; + int64 discount_amount = 8; + int64 final_price = 9; + int32 product_remaining_count = 10; + google.protobuf.Timestamp created = 11; +} + +// Clear Cart +message ClearCartRequest +{ + int64 user_id = 1; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/pruductcategory.proto b/src/CMSMicroservice.Protobuf/Protos/productcategory.proto similarity index 50% rename from src/CMSMicroservice.Protobuf/Protos/pruductcategory.proto rename to src/CMSMicroservice.Protobuf/Protos/productcategory.proto index 46eecda..11870bf 100644 --- a/src/CMSMicroservice.Protobuf/Protos/pruductcategory.proto +++ b/src/CMSMicroservice.Protobuf/Protos/productcategory.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package pruductcategory; +package productcategory; import "public_messages.proto"; import "google/protobuf/empty.proto"; @@ -9,88 +9,88 @@ import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto"; -option csharp_namespace = "CMSMicroservice.Protobuf.Protos.PruductCategory"; +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ProductCategory"; -service PruductCategoryContract +service ProductCategoryContract { - rpc CreateNewPruductCategory(CreateNewPruductCategoryRequest) returns (CreateNewPruductCategoryResponse){ + rpc CreateNewProductCategory(CreateNewProductCategoryRequest) returns (CreateNewProductCategoryResponse){ option (google.api.http) = { - post: "/CreateNewPruductCategory" + post: "/CreateNewProductCategory" body: "*" }; }; - rpc UpdatePruductCategory(UpdatePruductCategoryRequest) returns (google.protobuf.Empty){ + rpc UpdateProductCategory(UpdateProductCategoryRequest) returns (google.protobuf.Empty){ option (google.api.http) = { - put: "/UpdatePruductCategory" + put: "/UpdateProductCategory" body: "*" }; }; - rpc DeletePruductCategory(DeletePruductCategoryRequest) returns (google.protobuf.Empty){ + rpc DeleteProductCategory(DeleteProductCategoryRequest) returns (google.protobuf.Empty){ option (google.api.http) = { - delete: "/DeletePruductCategory" + delete: "/DeleteProductCategory" body: "*" }; }; - rpc GetPruductCategory(GetPruductCategoryRequest) returns (GetPruductCategoryResponse){ + rpc GetProductCategory(GetProductCategoryRequest) returns (GetProductCategoryResponse){ option (google.api.http) = { - get: "/GetPruductCategory" + get: "/GetProductCategory" }; }; - rpc GetAllPruductCategoryByFilter(GetAllPruductCategoryByFilterRequest) returns (GetAllPruductCategoryByFilterResponse){ + rpc GetAllProductCategoryByFilter(GetAllProductCategoryByFilterRequest) returns (GetAllProductCategoryByFilterResponse){ option (google.api.http) = { - get: "/GetAllPruductCategoryByFilter" + get: "/GetAllProductCategoryByFilter" }; }; } -message CreateNewPruductCategoryRequest +message CreateNewProductCategoryRequest { int64 product_id = 1; int64 category_id = 2; } -message CreateNewPruductCategoryResponse +message CreateNewProductCategoryResponse { int64 id = 1; } -message UpdatePruductCategoryRequest +message UpdateProductCategoryRequest { int64 id = 1; int64 product_id = 2; int64 category_id = 3; } -message DeletePruductCategoryRequest +message DeleteProductCategoryRequest { int64 id = 1; } -message GetPruductCategoryRequest +message GetProductCategoryRequest { int64 id = 1; } -message GetPruductCategoryResponse +message GetProductCategoryResponse { int64 id = 1; int64 product_id = 2; int64 category_id = 3; } -message GetAllPruductCategoryByFilterRequest +message GetAllProductCategoryByFilterRequest { messages.PaginationState pagination_state = 1; google.protobuf.StringValue sort_by = 2; - GetAllPruductCategoryByFilterFilter filter = 3; + GetAllProductCategoryByFilterFilter filter = 3; } -message GetAllPruductCategoryByFilterFilter +message GetAllProductCategoryByFilterFilter { google.protobuf.Int64Value id = 1; google.protobuf.Int64Value product_id = 2; google.protobuf.Int64Value category_id = 3; } -message GetAllPruductCategoryByFilterResponse +message GetAllProductCategoryByFilterResponse { messages.MetaData meta_data = 1; - repeated GetAllPruductCategoryByFilterResponseModel models = 2; + repeated GetAllProductCategoryByFilterResponseModel models = 2; } -message GetAllPruductCategoryByFilterResponseModel +message GetAllProductCategoryByFilterResponseModel { int64 id = 1; int64 product_id = 2; diff --git a/src/CMSMicroservice.Protobuf/Protos/productgalleries.proto b/src/CMSMicroservice.Protobuf/Protos/productgalleries.proto new file mode 100644 index 0000000..cf6e5c2 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/productgalleries.proto @@ -0,0 +1,98 @@ +syntax = "proto3"; + +package productgalleries; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ProductGalleries"; + +service ProductGalleriesContract +{ + rpc CreateNewProductGalleries(CreateNewProductGalleriesRequest) returns (CreateNewProductGalleriesResponse){ + option (google.api.http) = { + post: "/CreateNewProductGalleries" + body: "*" + }; + }; + rpc UpdateProductGalleries(UpdateProductGalleriesRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + put: "/UpdateProductGalleries" + body: "*" + }; + }; + rpc DeleteProductGalleries(DeleteProductGalleriesRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + delete: "/DeleteProductGalleries" + body: "*" + }; + }; + rpc GetProductGalleries(GetProductGalleriesRequest) returns (GetProductGalleriesResponse){ + option (google.api.http) = { + get: "/GetProductGalleries" + + }; + }; + rpc GetAllProductGalleriesByFilter(GetAllProductGalleriesByFilterRequest) returns (GetAllProductGalleriesByFilterResponse){ + option (google.api.http) = { + get: "/GetAllProductGalleriesByFilter" + + }; + }; +} +message CreateNewProductGalleriesRequest +{ + int64 product_image_id = 1; + int64 product_id = 2; +} +message CreateNewProductGalleriesResponse +{ + int64 id = 1; +} +message UpdateProductGalleriesRequest +{ + int64 id = 1; + int64 product_image_id = 2; + int64 product_id = 3; +} +message DeleteProductGalleriesRequest +{ + int64 id = 1; +} +message GetProductGalleriesRequest +{ + int64 id = 1; +} +message GetProductGalleriesResponse +{ + int64 id = 1; + int64 product_image_id = 2; + int64 product_id = 3; +} +message GetAllProductGalleriesByFilterRequest +{ + messages.PaginationState pagination_state = 1; + google.protobuf.StringValue sort_by = 2; + GetAllProductGalleriesByFilterFilter filter = 3; +} +message GetAllProductGalleriesByFilterFilter +{ + google.protobuf.Int64Value id = 1; + google.protobuf.Int64Value product_image_id = 2; + google.protobuf.Int64Value product_id = 3; +} +message GetAllProductGalleriesByFilterResponse +{ + messages.MetaData meta_data = 1; + repeated GetAllProductGalleriesByFilterResponseModel models = 2; +} +message GetAllProductGalleriesByFilterResponseModel +{ + int64 id = 1; + int64 product_image_id = 2; + int64 product_id = 3; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/productgallerys.proto b/src/CMSMicroservice.Protobuf/Protos/productgallerys.proto deleted file mode 100644 index 1785bad..0000000 --- a/src/CMSMicroservice.Protobuf/Protos/productgallerys.proto +++ /dev/null @@ -1,98 +0,0 @@ -syntax = "proto3"; - -package productgallerys; - -import "public_messages.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/wrappers.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ProductGallerys"; - -service ProductGallerysContract -{ - rpc CreateNewProductGallerys(CreateNewProductGallerysRequest) returns (CreateNewProductGallerysResponse){ - option (google.api.http) = { - post: "/CreateNewProductGallerys" - body: "*" - }; - }; - rpc UpdateProductGallerys(UpdateProductGallerysRequest) returns (google.protobuf.Empty){ - option (google.api.http) = { - put: "/UpdateProductGallerys" - body: "*" - }; - }; - rpc DeleteProductGallerys(DeleteProductGallerysRequest) returns (google.protobuf.Empty){ - option (google.api.http) = { - delete: "/DeleteProductGallerys" - body: "*" - }; - }; - rpc GetProductGallerys(GetProductGallerysRequest) returns (GetProductGallerysResponse){ - option (google.api.http) = { - get: "/GetProductGallerys" - - }; - }; - rpc GetAllProductGallerysByFilter(GetAllProductGallerysByFilterRequest) returns (GetAllProductGallerysByFilterResponse){ - option (google.api.http) = { - get: "/GetAllProductGallerysByFilter" - - }; - }; -} -message CreateNewProductGallerysRequest -{ - int64 product_image_id = 1; - int64 product_id = 2; -} -message CreateNewProductGallerysResponse -{ - int64 id = 1; -} -message UpdateProductGallerysRequest -{ - int64 id = 1; - int64 product_image_id = 2; - int64 product_id = 3; -} -message DeleteProductGallerysRequest -{ - int64 id = 1; -} -message GetProductGallerysRequest -{ - int64 id = 1; -} -message GetProductGallerysResponse -{ - int64 id = 1; - int64 product_image_id = 2; - int64 product_id = 3; -} -message GetAllProductGallerysByFilterRequest -{ - messages.PaginationState pagination_state = 1; - google.protobuf.StringValue sort_by = 2; - GetAllProductGallerysByFilterFilter filter = 3; -} -message GetAllProductGallerysByFilterFilter -{ - google.protobuf.Int64Value id = 1; - google.protobuf.Int64Value product_image_id = 2; - google.protobuf.Int64Value product_id = 3; -} -message GetAllProductGallerysByFilterResponse -{ - messages.MetaData meta_data = 1; - repeated GetAllProductGallerysByFilterResponseModel models = 2; -} -message GetAllProductGallerysByFilterResponseModel -{ - int64 id = 1; - int64 product_image_id = 2; - int64 product_id = 3; -} diff --git a/src/CMSMicroservice.Protobuf/Protos/pruducttag.proto b/src/CMSMicroservice.Protobuf/Protos/producttag.proto similarity index 52% rename from src/CMSMicroservice.Protobuf/Protos/pruducttag.proto rename to src/CMSMicroservice.Protobuf/Protos/producttag.proto index acbc92f..cb83fdf 100644 --- a/src/CMSMicroservice.Protobuf/Protos/pruducttag.proto +++ b/src/CMSMicroservice.Protobuf/Protos/producttag.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package pruducttag; +package producttag; import "public_messages.proto"; import "google/protobuf/empty.proto"; @@ -9,88 +9,88 @@ import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto"; -option csharp_namespace = "CMSMicroservice.Protobuf.Protos.PruductTag"; +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ProductTag"; -service PruductTagContract +service ProductTagContract { - rpc CreateNewPruductTag(CreateNewPruductTagRequest) returns (CreateNewPruductTagResponse){ + rpc CreateNewProductTag(CreateNewProductTagRequest) returns (CreateNewProductTagResponse){ option (google.api.http) = { - post: "/CreateNewPruductTag" + post: "/CreateNewProductTag" body: "*" }; }; - rpc UpdatePruductTag(UpdatePruductTagRequest) returns (google.protobuf.Empty){ + rpc UpdateProductTag(UpdateProductTagRequest) returns (google.protobuf.Empty){ option (google.api.http) = { - put: "/UpdatePruductTag" + put: "/UpdateProductTag" body: "*" }; }; - rpc DeletePruductTag(DeletePruductTagRequest) returns (google.protobuf.Empty){ + rpc DeleteProductTag(DeleteProductTagRequest) returns (google.protobuf.Empty){ option (google.api.http) = { - delete: "/DeletePruductTag" + delete: "/DeleteProductTag" body: "*" }; }; - rpc GetPruductTag(GetPruductTagRequest) returns (GetPruductTagResponse){ + rpc GetProductTag(GetProductTagRequest) returns (GetProductTagResponse){ option (google.api.http) = { - get: "/GetPruductTag" + get: "/GetProductTag" }; }; - rpc GetAllPruductTagByFilter(GetAllPruductTagByFilterRequest) returns (GetAllPruductTagByFilterResponse){ + rpc GetAllProductTagByFilter(GetAllProductTagByFilterRequest) returns (GetAllProductTagByFilterResponse){ option (google.api.http) = { - get: "/GetAllPruductTagByFilter" + get: "/GetAllProductTagByFilter" }; }; } -message CreateNewPruductTagRequest +message CreateNewProductTagRequest { int64 product_id = 1; int64 tag_id = 2; } -message CreateNewPruductTagResponse +message CreateNewProductTagResponse { int64 id = 1; } -message UpdatePruductTagRequest +message UpdateProductTagRequest { int64 id = 1; int64 product_id = 2; int64 tag_id = 3; } -message DeletePruductTagRequest +message DeleteProductTagRequest { int64 id = 1; } -message GetPruductTagRequest +message GetProductTagRequest { int64 id = 1; } -message GetPruductTagResponse +message GetProductTagResponse { int64 id = 1; int64 product_id = 2; int64 tag_id = 3; } -message GetAllPruductTagByFilterRequest +message GetAllProductTagByFilterRequest { messages.PaginationState pagination_state = 1; google.protobuf.StringValue sort_by = 2; - GetAllPruductTagByFilterFilter filter = 3; + GetAllProductTagByFilterFilter filter = 3; } -message GetAllPruductTagByFilterFilter +message GetAllProductTagByFilterFilter { google.protobuf.Int64Value id = 1; google.protobuf.Int64Value product_id = 2; google.protobuf.Int64Value tag_id = 3; } -message GetAllPruductTagByFilterResponse +message GetAllProductTagByFilterResponse { messages.MetaData meta_data = 1; - repeated GetAllPruductTagByFilterResponseModel models = 2; + repeated GetAllProductTagByFilterResponseModel models = 2; } -message GetAllPruductTagByFilterResponseModel +message GetAllProductTagByFilterResponseModel { int64 id = 1; int64 product_id = 2; diff --git a/src/CMSMicroservice.Protobuf/Protos/tag.proto b/src/CMSMicroservice.Protobuf/Protos/tag.proto index 7b4f343..30fd3ea 100644 --- a/src/CMSMicroservice.Protobuf/Protos/tag.proto +++ b/src/CMSMicroservice.Protobuf/Protos/tag.proto @@ -43,6 +43,11 @@ service TagContract }; }; + rpc GetProductsByTag(GetProductsByTagRequest) returns (GetProductsByTagResponse){ + option (google.api.http) = { + get: "/GetProductsByTag" + }; + }; } message CreateNewTagRequest { @@ -111,3 +116,20 @@ message GetAllTagByFilterResponseModel bool is_active = 5; int32 sort_order = 6; } +message GetProductsByTagRequest +{ + int64 tag_id = 1; +} +message GetProductsByTagResponse +{ + repeated ProductSimpleModel products = 1; +} +message ProductSimpleModel +{ + int64 id = 1; + string title = 2; + int64 price = 3; + int32 inventory = 4; + bool is_active = 5; + google.protobuf.StringValue image_path = 6; +} diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/CreateNewPruductCategoryRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/CreateNewPruductCategoryRequestValidator.cs similarity index 61% rename from src/CMSMicroservice.Protobuf/Validator/PruductCategory/CreateNewPruductCategoryRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductCategory/CreateNewPruductCategoryRequestValidator.cs index cb0b9a5..caa3262 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/CreateNewPruductCategoryRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/CreateNewPruductCategoryRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductCategory; -namespace CMSMicroservice.Protobuf.Validator.PruductCategory; +using CMSMicroservice.Protobuf.Protos.ProductCategory; +namespace CMSMicroservice.Protobuf.Validator.ProductCategory; -public class CreateNewPruductCategoryRequestValidator : AbstractValidator +public class CreateNewProductCategoryRequestValidator : AbstractValidator { - public CreateNewPruductCategoryRequestValidator() + public CreateNewProductCategoryRequestValidator() { RuleFor(model => model.ProductId) .NotNull(); @@ -13,7 +13,7 @@ public class CreateNewPruductCategoryRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewPruductCategoryRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductCategoryRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/DeletePruductCategoryRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/DeletePruductCategoryRequestValidator.cs similarity index 58% rename from src/CMSMicroservice.Protobuf/Validator/PruductCategory/DeletePruductCategoryRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductCategory/DeletePruductCategoryRequestValidator.cs index fe12af0..cc7efc9 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/DeletePruductCategoryRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/DeletePruductCategoryRequestValidator.cs @@ -1,17 +1,17 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductCategory; -namespace CMSMicroservice.Protobuf.Validator.PruductCategory; +using CMSMicroservice.Protobuf.Protos.ProductCategory; +namespace CMSMicroservice.Protobuf.Validator.ProductCategory; -public class DeletePruductCategoryRequestValidator : AbstractValidator +public class DeleteProductCategoryRequestValidator : AbstractValidator { - public DeletePruductCategoryRequestValidator() + public DeleteProductCategoryRequestValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeletePruductCategoryRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductCategoryRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/GetAllPruductCategoryByFilterRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/GetAllPruductCategoryByFilterRequestValidator.cs similarity index 54% rename from src/CMSMicroservice.Protobuf/Validator/PruductCategory/GetAllPruductCategoryByFilterRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductCategory/GetAllPruductCategoryByFilterRequestValidator.cs index 66206da..75e4ee3 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/GetAllPruductCategoryByFilterRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/GetAllPruductCategoryByFilterRequestValidator.cs @@ -1,15 +1,15 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductCategory; -namespace CMSMicroservice.Protobuf.Validator.PruductCategory; +using CMSMicroservice.Protobuf.Protos.ProductCategory; +namespace CMSMicroservice.Protobuf.Validator.ProductCategory; -public class GetAllPruductCategoryByFilterRequestValidator : AbstractValidator +public class GetAllProductCategoryByFilterRequestValidator : AbstractValidator { - public GetAllPruductCategoryByFilterRequestValidator() + public GetAllProductCategoryByFilterRequestValidator() { } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllPruductCategoryByFilterRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductCategoryByFilterRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/GetPruductCategoryRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/GetPruductCategoryRequestValidator.cs similarity index 58% rename from src/CMSMicroservice.Protobuf/Validator/PruductCategory/GetPruductCategoryRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductCategory/GetPruductCategoryRequestValidator.cs index 3b751ea..6081539 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/GetPruductCategoryRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/GetPruductCategoryRequestValidator.cs @@ -1,17 +1,17 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductCategory; -namespace CMSMicroservice.Protobuf.Validator.PruductCategory; +using CMSMicroservice.Protobuf.Protos.ProductCategory; +namespace CMSMicroservice.Protobuf.Validator.ProductCategory; -public class GetPruductCategoryRequestValidator : AbstractValidator +public class GetProductCategoryRequestValidator : AbstractValidator { - public GetPruductCategoryRequestValidator() + public GetProductCategoryRequestValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetPruductCategoryRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductCategoryRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/UpdatePruductCategoryRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/UpdatePruductCategoryRequestValidator.cs similarity index 64% rename from src/CMSMicroservice.Protobuf/Validator/PruductCategory/UpdatePruductCategoryRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductCategory/UpdatePruductCategoryRequestValidator.cs index ea0eef7..feadfae 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductCategory/UpdatePruductCategoryRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductCategory/UpdatePruductCategoryRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductCategory; -namespace CMSMicroservice.Protobuf.Validator.PruductCategory; +using CMSMicroservice.Protobuf.Protos.ProductCategory; +namespace CMSMicroservice.Protobuf.Validator.ProductCategory; -public class UpdatePruductCategoryRequestValidator : AbstractValidator +public class UpdateProductCategoryRequestValidator : AbstractValidator { - public UpdatePruductCategoryRequestValidator() + public UpdateProductCategoryRequestValidator() { RuleFor(model => model.Id) .NotNull(); @@ -15,7 +15,7 @@ public class UpdatePruductCategoryRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdatePruductCategoryRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductCategoryRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/CreateNewProductGallerysRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/CreateNewProductGalleriesRequestValidator.cs similarity index 54% rename from src/CMSMicroservice.Protobuf/Validator/ProductGallerys/CreateNewProductGallerysRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductGalleries/CreateNewProductGalleriesRequestValidator.cs index a9d029c..8d0a995 100644 --- a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/CreateNewProductGallerysRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/CreateNewProductGalleriesRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.ProductGallerys; -namespace CMSMicroservice.Protobuf.Validator.ProductGallerys; +using CMSMicroservice.Protobuf.Protos.ProductGalleries; +namespace CMSMicroservice.Protobuf.Validator.ProductGalleries; -public class CreateNewProductGallerysRequestValidator : AbstractValidator +public class CreateNewProductGalleriesRequestValidator : AbstractValidator { - public CreateNewProductGallerysRequestValidator() + public CreateNewProductGalleriesRequestValidator() { RuleFor(model => model.ProductImageId) .NotNull(); @@ -13,7 +13,7 @@ public class CreateNewProductGallerysRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductGallerysRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductGalleriesRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/DeleteProductGallerysRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/DeleteProductGalleriesRequestValidator.cs similarity index 50% rename from src/CMSMicroservice.Protobuf/Validator/ProductGallerys/DeleteProductGallerysRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductGalleries/DeleteProductGalleriesRequestValidator.cs index 7467563..8e4da20 100644 --- a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/DeleteProductGallerysRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/DeleteProductGalleriesRequestValidator.cs @@ -1,17 +1,17 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.ProductGallerys; -namespace CMSMicroservice.Protobuf.Validator.ProductGallerys; +using CMSMicroservice.Protobuf.Protos.ProductGalleries; +namespace CMSMicroservice.Protobuf.Validator.ProductGalleries; -public class DeleteProductGallerysRequestValidator : AbstractValidator +public class DeleteProductGalleriesRequestValidator : AbstractValidator { - public DeleteProductGallerysRequestValidator() + public DeleteProductGalleriesRequestValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductGallerysRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductGalleriesRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/GetAllProductGalleriesByFilterRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/GetAllProductGalleriesByFilterRequestValidator.cs new file mode 100644 index 0000000..0688221 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/GetAllProductGalleriesByFilterRequestValidator.cs @@ -0,0 +1,17 @@ +using FluentValidation; +using CMSMicroservice.Protobuf.Protos.ProductGalleries; +namespace CMSMicroservice.Protobuf.Validator.ProductGalleries; + +public class GetAllProductGalleriesByFilterRequestValidator : AbstractValidator +{ + public GetAllProductGalleriesByFilterRequestValidator() + { + } + public Func>> ValidateValue => async (model, propertyName) => + { + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductGalleriesByFilterRequest)model, x => x.IncludeProperties(propertyName))); + if (result.IsValid) + return Array.Empty(); + return result.Errors.Select(e => e.ErrorMessage); + }; +} diff --git a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/GetProductGallerysRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/GetProductGalleriesRequestValidator.cs similarity index 51% rename from src/CMSMicroservice.Protobuf/Validator/ProductGallerys/GetProductGallerysRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductGalleries/GetProductGalleriesRequestValidator.cs index 22b723a..e9ac011 100644 --- a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/GetProductGallerysRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/GetProductGalleriesRequestValidator.cs @@ -1,17 +1,17 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.ProductGallerys; -namespace CMSMicroservice.Protobuf.Validator.ProductGallerys; +using CMSMicroservice.Protobuf.Protos.ProductGalleries; +namespace CMSMicroservice.Protobuf.Validator.ProductGalleries; -public class GetProductGallerysRequestValidator : AbstractValidator +public class GetProductGalleriesRequestValidator : AbstractValidator { - public GetProductGallerysRequestValidator() + public GetProductGalleriesRequestValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductGallerysRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductGalleriesRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/UpdateProductGallerysRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/UpdateProductGalleriesRequestValidator.cs similarity index 57% rename from src/CMSMicroservice.Protobuf/Validator/ProductGallerys/UpdateProductGallerysRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductGalleries/UpdateProductGalleriesRequestValidator.cs index 033a58a..a671d68 100644 --- a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/UpdateProductGallerysRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductGalleries/UpdateProductGalleriesRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.ProductGallerys; -namespace CMSMicroservice.Protobuf.Validator.ProductGallerys; +using CMSMicroservice.Protobuf.Protos.ProductGalleries; +namespace CMSMicroservice.Protobuf.Validator.ProductGalleries; -public class UpdateProductGallerysRequestValidator : AbstractValidator +public class UpdateProductGalleriesRequestValidator : AbstractValidator { - public UpdateProductGallerysRequestValidator() + public UpdateProductGalleriesRequestValidator() { RuleFor(model => model.Id) .NotNull(); @@ -15,7 +15,7 @@ public class UpdateProductGallerysRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductGallerysRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductGalleriesRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/GetAllProductGallerysByFilterRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/GetAllProductGallerysByFilterRequestValidator.cs deleted file mode 100644 index e366a8f..0000000 --- a/src/CMSMicroservice.Protobuf/Validator/ProductGallerys/GetAllProductGallerysByFilterRequestValidator.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentValidation; -using CMSMicroservice.Protobuf.Protos.ProductGallerys; -namespace CMSMicroservice.Protobuf.Validator.ProductGallerys; - -public class GetAllProductGallerysByFilterRequestValidator : AbstractValidator -{ - public GetAllProductGallerysByFilterRequestValidator() - { - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductGallerysByFilterRequest)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductTag/CreateNewPruductTagRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductTag/CreateNewPruductTagRequestValidator.cs similarity index 62% rename from src/CMSMicroservice.Protobuf/Validator/PruductTag/CreateNewPruductTagRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductTag/CreateNewPruductTagRequestValidator.cs index ae027e0..f212241 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductTag/CreateNewPruductTagRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductTag/CreateNewPruductTagRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductTag; -namespace CMSMicroservice.Protobuf.Validator.PruductTag; +using CMSMicroservice.Protobuf.Protos.ProductTag; +namespace CMSMicroservice.Protobuf.Validator.ProductTag; -public class CreateNewPruductTagRequestValidator : AbstractValidator +public class CreateNewProductTagRequestValidator : AbstractValidator { - public CreateNewPruductTagRequestValidator() + public CreateNewProductTagRequestValidator() { RuleFor(model => model.ProductId) .NotNull(); @@ -13,7 +13,7 @@ public class CreateNewPruductTagRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewPruductTagRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductTagRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductTag/DeletePruductTagRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductTag/DeletePruductTagRequestValidator.cs similarity index 59% rename from src/CMSMicroservice.Protobuf/Validator/PruductTag/DeletePruductTagRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductTag/DeletePruductTagRequestValidator.cs index 07d41cc..7743450 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductTag/DeletePruductTagRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductTag/DeletePruductTagRequestValidator.cs @@ -1,17 +1,17 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductTag; -namespace CMSMicroservice.Protobuf.Validator.PruductTag; +using CMSMicroservice.Protobuf.Protos.ProductTag; +namespace CMSMicroservice.Protobuf.Validator.ProductTag; -public class DeletePruductTagRequestValidator : AbstractValidator +public class DeleteProductTagRequestValidator : AbstractValidator { - public DeletePruductTagRequestValidator() + public DeleteProductTagRequestValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeletePruductTagRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteProductTagRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductTag/GetAllPruductTagByFilterRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductTag/GetAllPruductTagByFilterRequestValidator.cs similarity index 55% rename from src/CMSMicroservice.Protobuf/Validator/PruductTag/GetAllPruductTagByFilterRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductTag/GetAllPruductTagByFilterRequestValidator.cs index 68a8ad1..84e29d7 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductTag/GetAllPruductTagByFilterRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductTag/GetAllPruductTagByFilterRequestValidator.cs @@ -1,15 +1,15 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductTag; -namespace CMSMicroservice.Protobuf.Validator.PruductTag; +using CMSMicroservice.Protobuf.Protos.ProductTag; +namespace CMSMicroservice.Protobuf.Validator.ProductTag; -public class GetAllPruductTagByFilterRequestValidator : AbstractValidator +public class GetAllProductTagByFilterRequestValidator : AbstractValidator { - public GetAllPruductTagByFilterRequestValidator() + public GetAllProductTagByFilterRequestValidator() { } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllPruductTagByFilterRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllProductTagByFilterRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductTag/GetPruductTagRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductTag/GetPruductTagRequestValidator.cs similarity index 60% rename from src/CMSMicroservice.Protobuf/Validator/PruductTag/GetPruductTagRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductTag/GetPruductTagRequestValidator.cs index 47db25c..add40b2 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductTag/GetPruductTagRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductTag/GetPruductTagRequestValidator.cs @@ -1,17 +1,17 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductTag; -namespace CMSMicroservice.Protobuf.Validator.PruductTag; +using CMSMicroservice.Protobuf.Protos.ProductTag; +namespace CMSMicroservice.Protobuf.Validator.ProductTag; -public class GetPruductTagRequestValidator : AbstractValidator +public class GetProductTagRequestValidator : AbstractValidator { - public GetPruductTagRequestValidator() + public GetProductTagRequestValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetPruductTagRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetProductTagRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Protobuf/Validator/PruductTag/UpdatePruductTagRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/ProductTag/UpdatePruductTagRequestValidator.cs similarity index 65% rename from src/CMSMicroservice.Protobuf/Validator/PruductTag/UpdatePruductTagRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/ProductTag/UpdatePruductTagRequestValidator.cs index 1bdb0a3..5cff5ca 100644 --- a/src/CMSMicroservice.Protobuf/Validator/PruductTag/UpdatePruductTagRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/ProductTag/UpdatePruductTagRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.PruductTag; -namespace CMSMicroservice.Protobuf.Validator.PruductTag; +using CMSMicroservice.Protobuf.Protos.ProductTag; +namespace CMSMicroservice.Protobuf.Validator.ProductTag; -public class UpdatePruductTagRequestValidator : AbstractValidator +public class UpdateProductTagRequestValidator : AbstractValidator { - public UpdatePruductTagRequestValidator() + public UpdateProductTagRequestValidator() { RuleFor(model => model.Id) .NotNull(); @@ -15,7 +15,7 @@ public class UpdatePruductTagRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdatePruductTagRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateProductTagRequest)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.WebApi/Common/Mappings/ProductGallerysProfile.cs b/src/CMSMicroservice.WebApi/Common/Mappings/ProductGalleriesProfile.cs similarity index 100% rename from src/CMSMicroservice.WebApi/Common/Mappings/ProductGallerysProfile.cs rename to src/CMSMicroservice.WebApi/Common/Mappings/ProductGalleriesProfile.cs diff --git a/src/CMSMicroservice.WebApi/Common/Mappings/TagProfile.cs b/src/CMSMicroservice.WebApi/Common/Mappings/TagProfile.cs index 1e48844..97ffd38 100644 --- a/src/CMSMicroservice.WebApi/Common/Mappings/TagProfile.cs +++ b/src/CMSMicroservice.WebApi/Common/Mappings/TagProfile.cs @@ -1,10 +1,40 @@ +using CMSMicroservice.Application.TagCQ.Queries.GetProductsByTag; +using CMSMicroservice.Protobuf.Protos.Tag; +using System.Collections.Generic; + namespace CMSMicroservice.WebApi.Common.Mappings; public class TagProfile : IRegister { void IRegister.Register(TypeAdapterConfig config) { - //config.NewConfig() - // .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}"); + // GetProductsByTagRequest -> GetProductsByTagQuery + config.NewConfig() + .Map(dest => dest.TagId, src => src.TagId); + + // List -> GetProductsByTagResponse + config.NewConfig, GetProductsByTagResponse>() + .MapWith(src => ConvertToResponse(src)); + } + + private static GetProductsByTagResponse ConvertToResponse(List products) + { + var response = new GetProductsByTagResponse(); + + foreach (var product in products) + { + response.Products.Add(new ProductSimpleModel + { + Id = product.Id, + Title = product.Title, + Price = product.Price, + Inventory = product.Inventory, + IsActive = product.IsActive, + ImagePath = product.ImagePath + }); + } + + return response; } } + diff --git a/src/CMSMicroservice.WebApi/Services/DiscountCategoryService.cs b/src/CMSMicroservice.WebApi/Services/DiscountCategoryService.cs new file mode 100644 index 0000000..be757e8 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/DiscountCategoryService.cs @@ -0,0 +1,38 @@ +using CMSMicroservice.Protobuf.Protos.DiscountCategory; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountCategory; +using CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountCategory; +using CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountCategory; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountCategories; + +namespace CMSMicroservice.WebApi.Services; + +public class DiscountCategoryService : DiscountCategoryContract.DiscountCategoryContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public DiscountCategoryService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + public override async Task CreateDiscountCategory(CreateDiscountCategoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task UpdateDiscountCategory(UpdateDiscountCategoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task DeleteDiscountCategory(DeleteDiscountCategoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetDiscountCategories(GetDiscountCategoriesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/DiscountOrderService.cs b/src/CMSMicroservice.WebApi/Services/DiscountOrderService.cs new file mode 100644 index 0000000..23c1857 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/DiscountOrderService.cs @@ -0,0 +1,44 @@ +using CMSMicroservice.Protobuf.Protos.DiscountOrder; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.DiscountShopCQ.Commands.PlaceOrder; +using CMSMicroservice.Application.DiscountShopCQ.Commands.CompleteOrderPayment; +using CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateOrderStatus; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetOrderById; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetUserOrders; + +namespace CMSMicroservice.WebApi.Services; + +public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public DiscountOrderService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + public override async Task PlaceOrder(PlaceOrderRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task CompleteOrderPayment(CompleteOrderPaymentRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task UpdateOrderStatus(UpdateOrderStatusRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetOrderById(GetOrderByIdRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetUserOrders(GetUserOrdersRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/DiscountProductService.cs b/src/CMSMicroservice.WebApi/Services/DiscountProductService.cs new file mode 100644 index 0000000..236fbb7 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/DiscountProductService.cs @@ -0,0 +1,44 @@ +using CMSMicroservice.Protobuf.Protos.DiscountProduct; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountProduct; +using CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProduct; +using CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountProduct; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProductById; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProducts; + +namespace CMSMicroservice.WebApi.Services; + +public class DiscountProductService : DiscountProductContract.DiscountProductContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public DiscountProductService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + public override async Task CreateDiscountProduct(CreateDiscountProductRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task UpdateDiscountProduct(UpdateDiscountProductRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task DeleteDiscountProduct(DeleteDiscountProductRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetDiscountProductById(GetDiscountProductByIdRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetDiscountProducts(GetDiscountProductsRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/DiscountShoppingCartService.cs b/src/CMSMicroservice.WebApi/Services/DiscountShoppingCartService.cs new file mode 100644 index 0000000..56e2672 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/DiscountShoppingCartService.cs @@ -0,0 +1,44 @@ +using CMSMicroservice.Protobuf.Protos.DiscountShoppingCart; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.DiscountShopCQ.Commands.AddToCart; +using CMSMicroservice.Application.DiscountShopCQ.Commands.RemoveFromCart; +using CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateCartItemCount; +using CMSMicroservice.Application.DiscountShopCQ.Commands.ClearCart; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetUserCart; + +namespace CMSMicroservice.WebApi.Services; + +public class DiscountShoppingCartService : DiscountShoppingCartContract.DiscountShoppingCartContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public DiscountShoppingCartService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + public override async Task AddToCart(AddToCartRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task RemoveFromCart(RemoveFromCartRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task UpdateCartItemCount(UpdateCartItemCountRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetUserCart(GetUserCartRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task ClearCart(ClearCartRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/ProductCategoryService.cs b/src/CMSMicroservice.WebApi/Services/ProductCategoryService.cs new file mode 100644 index 0000000..7b7ac03 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/ProductCategoryService.cs @@ -0,0 +1,37 @@ +using CMSMicroservice.Protobuf.Protos.ProductCategory; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.ProductCategoryCQ.Commands.CreateNewProductCategory; +using CMSMicroservice.Application.ProductCategoryCQ.Commands.UpdateProductCategory; +using CMSMicroservice.Application.ProductCategoryCQ.Commands.DeleteProductCategory; +using CMSMicroservice.Application.ProductCategoryCQ.Queries.GetProductCategory; +using CMSMicroservice.Application.ProductCategoryCQ.Queries.GetAllProductCategoryByFilter; +namespace CMSMicroservice.WebApi.Services; +public class ProductCategoryService : ProductCategoryContract.ProductCategoryContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public ProductCategoryService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + public override async Task CreateNewProductCategory(CreateNewProductCategoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task UpdateProductCategory(UpdateProductCategoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task DeleteProductCategory(DeleteProductCategoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetProductCategory(GetProductCategoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetAllProductCategoryByFilter(GetAllProductCategoryByFilterRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/ProductGalleriesService.cs b/src/CMSMicroservice.WebApi/Services/ProductGalleriesService.cs new file mode 100644 index 0000000..6999978 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/ProductGalleriesService.cs @@ -0,0 +1,37 @@ +using CMSMicroservice.Protobuf.Protos.ProductGalleries; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.ProductGalleriesCQ.Commands.CreateNewProductGalleries; +using CMSMicroservice.Application.ProductGalleriesCQ.Commands.UpdateProductGalleries; +using CMSMicroservice.Application.ProductGalleriesCQ.Commands.DeleteProductGalleries; +using CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetProductGalleries; +using CMSMicroservice.Application.ProductGalleriesCQ.Queries.GetAllProductGalleriesByFilter; +namespace CMSMicroservice.WebApi.Services; +public class ProductGalleriesService : ProductGalleriesContract.ProductGalleriesContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public ProductGalleriesService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + public override async Task CreateNewProductGalleries(CreateNewProductGalleriesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task UpdateProductGalleries(UpdateProductGalleriesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task DeleteProductGalleries(DeleteProductGalleriesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetProductGalleries(GetProductGalleriesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetAllProductGalleriesByFilter(GetAllProductGalleriesByFilterRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/ProductGallerysService.cs b/src/CMSMicroservice.WebApi/Services/ProductGallerysService.cs deleted file mode 100644 index 93920cc..0000000 --- a/src/CMSMicroservice.WebApi/Services/ProductGallerysService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CMSMicroservice.Protobuf.Protos.ProductGallerys; -using CMSMicroservice.WebApi.Common.Services; -using CMSMicroservice.Application.ProductGallerysCQ.Commands.CreateNewProductGallerys; -using CMSMicroservice.Application.ProductGallerysCQ.Commands.UpdateProductGallerys; -using CMSMicroservice.Application.ProductGallerysCQ.Commands.DeleteProductGallerys; -using CMSMicroservice.Application.ProductGallerysCQ.Queries.GetProductGallerys; -using CMSMicroservice.Application.ProductGallerysCQ.Queries.GetAllProductGallerysByFilter; -namespace CMSMicroservice.WebApi.Services; -public class ProductGallerysService : ProductGallerysContract.ProductGallerysContractBase -{ - private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; - - public ProductGallerysService(IDispatchRequestToCQRS dispatchRequestToCQRS) - { - _dispatchRequestToCQRS = dispatchRequestToCQRS; - } - public override async Task CreateNewProductGallerys(CreateNewProductGallerysRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task UpdateProductGallerys(UpdateProductGallerysRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task DeleteProductGallerys(DeleteProductGallerysRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetProductGallerys(GetProductGallerysRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetAllProductGallerysByFilter(GetAllProductGallerysByFilterRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } -} diff --git a/src/CMSMicroservice.WebApi/Services/ProductTagService.cs b/src/CMSMicroservice.WebApi/Services/ProductTagService.cs new file mode 100644 index 0000000..41f788a --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/ProductTagService.cs @@ -0,0 +1,37 @@ +using CMSMicroservice.Protobuf.Protos.ProductTag; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.ProductTagCQ.Commands.CreateNewProductTag; +using CMSMicroservice.Application.ProductTagCQ.Commands.UpdateProductTag; +using CMSMicroservice.Application.ProductTagCQ.Commands.DeleteProductTag; +using CMSMicroservice.Application.ProductTagCQ.Queries.GetProductTag; +using CMSMicroservice.Application.ProductTagCQ.Queries.GetAllProductTagByFilter; +namespace CMSMicroservice.WebApi.Services; +public class ProductTagService : ProductTagContract.ProductTagContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public ProductTagService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + public override async Task CreateNewProductTag(CreateNewProductTagRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task UpdateProductTag(UpdateProductTagRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task DeleteProductTag(DeleteProductTagRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetProductTag(GetProductTagRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetAllProductTagByFilter(GetAllProductTagByFilterRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/PruductCategoryService.cs b/src/CMSMicroservice.WebApi/Services/PruductCategoryService.cs deleted file mode 100644 index 0f5d244..0000000 --- a/src/CMSMicroservice.WebApi/Services/PruductCategoryService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CMSMicroservice.Protobuf.Protos.PruductCategory; -using CMSMicroservice.WebApi.Common.Services; -using CMSMicroservice.Application.PruductCategoryCQ.Commands.CreateNewPruductCategory; -using CMSMicroservice.Application.PruductCategoryCQ.Commands.UpdatePruductCategory; -using CMSMicroservice.Application.PruductCategoryCQ.Commands.DeletePruductCategory; -using CMSMicroservice.Application.PruductCategoryCQ.Queries.GetPruductCategory; -using CMSMicroservice.Application.PruductCategoryCQ.Queries.GetAllPruductCategoryByFilter; -namespace CMSMicroservice.WebApi.Services; -public class PruductCategoryService : PruductCategoryContract.PruductCategoryContractBase -{ - private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; - - public PruductCategoryService(IDispatchRequestToCQRS dispatchRequestToCQRS) - { - _dispatchRequestToCQRS = dispatchRequestToCQRS; - } - public override async Task CreateNewPruductCategory(CreateNewPruductCategoryRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task UpdatePruductCategory(UpdatePruductCategoryRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task DeletePruductCategory(DeletePruductCategoryRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetPruductCategory(GetPruductCategoryRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetAllPruductCategoryByFilter(GetAllPruductCategoryByFilterRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } -} diff --git a/src/CMSMicroservice.WebApi/Services/PruductTagService.cs b/src/CMSMicroservice.WebApi/Services/PruductTagService.cs deleted file mode 100644 index b796b3f..0000000 --- a/src/CMSMicroservice.WebApi/Services/PruductTagService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CMSMicroservice.Protobuf.Protos.PruductTag; -using CMSMicroservice.WebApi.Common.Services; -using CMSMicroservice.Application.PruductTagCQ.Commands.CreateNewPruductTag; -using CMSMicroservice.Application.PruductTagCQ.Commands.UpdatePruductTag; -using CMSMicroservice.Application.PruductTagCQ.Commands.DeletePruductTag; -using CMSMicroservice.Application.PruductTagCQ.Queries.GetPruductTag; -using CMSMicroservice.Application.PruductTagCQ.Queries.GetAllPruductTagByFilter; -namespace CMSMicroservice.WebApi.Services; -public class PruductTagService : PruductTagContract.PruductTagContractBase -{ - private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; - - public PruductTagService(IDispatchRequestToCQRS dispatchRequestToCQRS) - { - _dispatchRequestToCQRS = dispatchRequestToCQRS; - } - public override async Task CreateNewPruductTag(CreateNewPruductTagRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task UpdatePruductTag(UpdatePruductTagRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task DeletePruductTag(DeletePruductTagRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetPruductTag(GetPruductTagRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetAllPruductTagByFilter(GetAllPruductTagByFilterRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } -} diff --git a/src/CMSMicroservice.WebApi/Services/TagService.cs b/src/CMSMicroservice.WebApi/Services/TagService.cs index 98080c9..b40df72 100644 --- a/src/CMSMicroservice.WebApi/Services/TagService.cs +++ b/src/CMSMicroservice.WebApi/Services/TagService.cs @@ -5,6 +5,8 @@ using CMSMicroservice.Application.TagCQ.Commands.UpdateTag; using CMSMicroservice.Application.TagCQ.Commands.DeleteTag; using CMSMicroservice.Application.TagCQ.Queries.GetTag; using CMSMicroservice.Application.TagCQ.Queries.GetAllTagByFilter; +using CMSMicroservice.Application.TagCQ.Queries.GetProductsByTag; + namespace CMSMicroservice.WebApi.Services; public class TagService : TagContract.TagContractBase { @@ -34,4 +36,9 @@ public class TagService : TagContract.TagContractBase { return await _dispatchRequestToCQRS.Handle(request, context); } + + public override async Task GetProductsByTag(GetProductsByTagRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } } diff --git a/src/CMSMicroservice.WebApi/appsettings.json b/src/CMSMicroservice.WebApi/appsettings.json index 835d25f..9a8f007 100644 --- a/src/CMSMicroservice.WebApi/appsettings.json +++ b/src/CMSMicroservice.WebApi/appsettings.json @@ -1,6 +1,5 @@ { "UseRealPaymentGateway": false, - "PaymentProvider": "BankMellat", "JwtSecurityKey": "TvlZVx5TJaHs8e9HgUdGzhGP2CIidoI444nAj+8+g7c=", "JwtIssuer": "https://localhost", "JwtAudience": "https://localhost", @@ -45,12 +44,6 @@ "BaseUrl": "https://api.daya.ir", "ApiKey": "YOUR_DAYA_API_KEY" }, - "BankMellat": { - "ServiceUrl": "https://bpm.shaparak.ir/pgwchannel/services/pgw", - "TerminalId": "YOUR_TERMINAL_ID", - "Username": "YOUR_USERNAME", - "Password": "YOUR_PASSWORD" - }, "AllowedHosts": "*", "Kestrel": { "EndpointDefaults": {