From 10d2ca20d1336f50cf6e46f9e00b27cd4dfbd524 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Fri, 27 Feb 2026 06:22:15 +0330 Subject: [PATCH] =?UTF-8?q?refactor:=20rename=20UserWalletChangeLog?= =?UTF-8?q?=E2=86=92UserWalletHistory,=20add=20History=20interceptor=20&?= =?UTF-8?q?=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename UserWalletChangeLog to UserWalletHistory across 54+ files (entities, configs, DTOs, commands, queries, protos, services) - Rename 34 files and 11 directories accordingly - Rename proto file userwalletchangelog.proto → userwallethistory.proto - Add IHasHistory generic interface for history auto-tracking - Implement IHasHistory on Package entity - Add HistoryTrackingSaveChangesInterceptor (reflection-based, auto-fills Old* values from OriginalValues) - Wire interceptor in DI and ApplicationDbContext - Add EF migration Q27_HistoryTables_And_RenameWalletHistory: * RenameTable UserWalletChangeLogs → UserWalletHistories (preserves data) * Rename PK, FK constraints and indexes via sp_rename * CreateTable ClubMembershipCycleHistories + PackageHistories --- ...ulateWeeklyCommissionPoolCommandHandler.cs | 10 +- .../Interfaces/IApplicationDbContext.cs | 2 +- .../Mappings/UserWalletChangeLogProfile.cs | 16 - .../Mappings/UserWalletHistoryProfile.cs | 16 + .../CheckAndProcessDayaLoansCommandHandler.cs | 8 +- .../CompleteOrderPaymentCommandHandler.cs | 2 +- .../PlaceOrder/PlaceOrderCommandHandler.cs | 2 +- .../ApproveManualPaymentCommandHandler.cs | 12 +- .../CreateManualPaymentCommandHandler.cs | 4 +- ...ssManualMembershipPaymentCommandHandler.cs | 4 +- .../CancelOrderByAdminCommandHandler.cs | 4 +- .../VerifyPackagePurchaseCommandHandler.cs | 8 +- .../GetCustomerReferralsQueryHandler.cs | 2 +- .../GetCustomerWalletHistoryQuery.cs} | 4 +- .../GetCustomerWalletHistoryQueryHandler.cs} | 14 +- .../GetCustomerWalletHistoryResponseDto.cs} | 4 +- ...ateNewUserWalletChangeLogCommandHandler.cs | 21 - ...CreateNewUserWalletChangeLogResponseDto.cs | 7 - .../DeleteUserWalletChangeLogCommand.cs | 7 - ...DeleteUserWalletChangeLogCommandHandler.cs | 22 - ...leteUserWalletChangeLogCommandValidator.cs | 16 - ...UpdateUserWalletChangeLogCommandHandler.cs | 22 - ...reateNewUserWalletChangeLogEventHandler.cs | 22 - .../DeleteUserWalletChangeLogEventHandler.cs | 22 - .../UpdateUserWalletChangeLogEventHandler.cs | 22 - ...erWalletChangeLogByFilterQueryValidator.cs | 14 - .../GetUserWalletChangeLogQuery.cs | 7 - .../GetUserWalletChangeLogQueryHandler.cs | 22 - .../CreateNewUserWalletHistoryCommand.cs} | 4 +- ...reateNewUserWalletHistoryCommandHandler.cs | 21 + ...teNewUserWalletHistoryCommandValidator.cs} | 8 +- .../CreateNewUserWalletHistoryResponseDto.cs | 7 + .../DeleteUserWalletHistoryCommand.cs | 7 + .../DeleteUserWalletHistoryCommandHandler.cs | 22 + ...DeleteUserWalletHistoryCommandValidator.cs | 16 + .../UpdateUserWalletHistoryCommand.cs} | 4 +- .../UpdateUserWalletHistoryCommandHandler.cs | 22 + ...pdateUserWalletHistoryCommandValidator.cs} | 8 +- .../CreateNewUserWalletHistoryEventHandler.cs | 22 + .../DeleteUserWalletHistoryEventHandler.cs | 22 + .../UpdateUserWalletHistoryEventHandler.cs | 22 + .../GetAllUserWalletHistoryByFilterQuery.cs} | 8 +- ...lUserWalletHistoryByFilterQueryHandler.cs} | 14 +- ...UserWalletHistoryByFilterQueryValidator.cs | 14 + ...llUserWalletHistoryByFilterResponseDto.cs} | 8 +- .../GetUserWalletHistoryQuery.cs | 7 + .../GetUserWalletHistoryQueryHandler.cs | 22 + .../GetUserWalletHistoryQueryValidator.cs} | 8 +- .../GetUserWalletHistoryResponseDto.cs} | 4 +- ...erifyDiscountWalletChargeCommandHandler.cs | 2 +- .../VerifyMagicWalletChargeCommandHandler.cs | 6 +- .../Common/IHasHistory.cs | 19 + .../Entities/Package.cs | 24 +- .../Entities/UserWallet.cs | 4 +- ...alletChangeLog.cs => UserWalletHistory.cs} | 2 +- .../CreateNewUserWalletChangeLogEvent.cs | 8 - .../DeleteUserWalletChangeLogEvent.cs | 8 - .../UpdateUserWalletChangeLogEvent.cs | 8 - .../CreateNewUserWalletHistoryEvent.cs | 8 + .../DeleteUserWalletHistoryEvent.cs | 8 + .../UpdateUserWalletHistoryEvent.cs | 8 + .../ConfigureServices.cs | 1 + .../Persistence/ApplicationDbContext.cs | 12 +- ...n.cs => UserWalletHistoryConfiguration.cs} | 6 +- .../HistoryTrackingSaveChangesInterceptor.cs | 150 + ...Tables_And_RenameWalletHistory.Designer.cs | 5203 +++++++++++++++++ ...7_HistoryTables_And_RenameWalletHistory.cs | 190 + .../ApplicationDbContextModelSnapshot.cs | 200 +- .../OrmCommissionCalculationStrategy.cs | 10 +- .../CMSMicroservice.Protobuf.csproj | 2 +- .../Protos/userwallet.proto | 12 +- ...hangelog.proto => userwallethistory.proto} | 50 +- ...leteUserWalletChangeLogRequestValidator.cs | 19 - ...WalletChangeLogByFilterRequestValidator.cs | 17 - ...teNewUserWalletHistoryRequestValidator.cs} | 10 +- ...DeleteUserWalletHistoryRequestValidator.cs | 19 + ...erWalletHistoryByFilterRequestValidator.cs | 17 + .../GetUserWalletHistoryRequestValidator.cs} | 10 +- ...pdateUserWalletHistoryRequestValidator.cs} | 10 +- ...Profile.cs => UserWalletHistoryProfile.cs} | 2 +- src/CMSMicroservice.WebApi/Program.cs | 2 +- .../Services/PackageService.cs | 4 +- .../Services/UserOrderService.cs | 6 +- .../Services/UserWalletChangeLogService.cs | 37 - .../Services/UserWalletHistoryService.cs | 37 + .../Services/UserWalletService.cs | 10 +- 86 files changed, 6255 insertions(+), 472 deletions(-) delete mode 100644 src/CMSMicroservice.Application/Common/Mappings/UserWalletChangeLogProfile.cs create mode 100644 src/CMSMicroservice.Application/Common/Mappings/UserWalletHistoryProfile.cs rename src/CMSMicroservice.Application/UserWalletCQ/Queries/{GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQuery.cs => GetCustomerWalletHistory/GetCustomerWalletHistoryQuery.cs} (76%) rename src/CMSMicroservice.Application/UserWalletCQ/Queries/{GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQueryHandler.cs => GetCustomerWalletHistory/GetCustomerWalletHistoryQueryHandler.cs} (77%) rename src/CMSMicroservice.Application/UserWalletCQ/Queries/{GetCustomerWalletChangeLog/GetCustomerWalletChangeLogResponseDto.cs => GetCustomerWalletHistory/GetCustomerWalletHistoryResponseDto.cs} (94%) delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandHandler.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogResponseDto.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommand.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandHandler.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandValidator.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandHandler.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/CreateNewUserWalletChangeLogEventHandlers/CreateNewUserWalletChangeLogEventHandler.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/DeleteUserWalletChangeLogEventHandlers/DeleteUserWalletChangeLogEventHandler.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/UpdateUserWalletChangeLogEventHandlers/UpdateUserWalletChangeLogEventHandler.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryValidator.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQuery.cs delete mode 100644 src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryHandler.cs rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommand.cs => UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommand.cs} (72%) create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandHandler.cs rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandValidator.cs => UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandValidator.cs} (64%) create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryResponseDto.cs create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommand.cs create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandHandler.cs create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandValidator.cs rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommand.cs => UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommand.cs} (78%) create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandHandler.cs rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandValidator.cs => UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandValidator.cs} (67%) create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/CreateNewUserWalletHistoryEventHandlers/CreateNewUserWalletHistoryEventHandler.cs create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/DeleteUserWalletHistoryEventHandlers/DeleteUserWalletHistoryEventHandler.cs create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/UpdateUserWalletHistoryEventHandlers/UpdateUserWalletHistoryEventHandler.cs rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQuery.cs => UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQuery.cs} (66%) rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryHandler.cs => UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryHandler.cs} (63%) create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryValidator.cs rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterResponseDto.cs => UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterResponseDto.cs} (70%) create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQuery.cs create mode 100644 src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryHandler.cs rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryValidator.cs => UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryValidator.cs} (51%) rename src/CMSMicroservice.Application/{UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogResponseDto.cs => UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryResponseDto.cs} (82%) create mode 100644 src/CMSMicroservice.Domain/Common/IHasHistory.cs rename src/CMSMicroservice.Domain/Entities/{UserWalletChangeLog.cs => UserWalletHistory.cs} (95%) delete mode 100644 src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/CreateNewUserWalletChangeLogEvent.cs delete mode 100644 src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/DeleteUserWalletChangeLogEvent.cs delete mode 100644 src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/UpdateUserWalletChangeLogEvent.cs create mode 100644 src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/CreateNewUserWalletHistoryEvent.cs create mode 100644 src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/DeleteUserWalletHistoryEvent.cs create mode 100644 src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/UpdateUserWalletHistoryEvent.cs rename src/CMSMicroservice.Infrastructure/Persistence/Configurations/{UserWalletChangeLogConfiguration.cs => UserWalletHistoryConfiguration.cs} (85%) create mode 100644 src/CMSMicroservice.Infrastructure/Persistence/Interceptors/HistoryTrackingSaveChangesInterceptor.cs create mode 100644 src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.Designer.cs create mode 100644 src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.cs rename src/CMSMicroservice.Protobuf/Protos/{userwalletchangelog.proto => userwallethistory.proto} (61%) delete mode 100644 src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/DeleteUserWalletChangeLogRequestValidator.cs delete mode 100644 src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/GetAllUserWalletChangeLogByFilterRequestValidator.cs rename src/CMSMicroservice.Protobuf/Validator/{UserWalletChangeLog/CreateNewUserWalletChangeLogRequestValidator.cs => UserWalletHistory/CreateNewUserWalletHistoryRequestValidator.cs} (64%) create mode 100644 src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/DeleteUserWalletHistoryRequestValidator.cs create mode 100644 src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/GetAllUserWalletHistoryByFilterRequestValidator.cs rename src/CMSMicroservice.Protobuf/Validator/{UserWalletChangeLog/GetUserWalletChangeLogRequestValidator.cs => UserWalletHistory/GetUserWalletHistoryRequestValidator.cs} (50%) rename src/CMSMicroservice.Protobuf/Validator/{UserWalletChangeLog/UpdateUserWalletChangeLogRequestValidator.cs => UserWalletHistory/UpdateUserWalletHistoryRequestValidator.cs} (66%) rename src/CMSMicroservice.WebApi/Common/Mappings/{UserWalletChangeLogProfile.cs => UserWalletHistoryProfile.cs} (83%) delete mode 100644 src/CMSMicroservice.WebApi/Services/UserWalletChangeLogService.cs create mode 100644 src/CMSMicroservice.WebApi/Services/UserWalletHistoryService.cs diff --git a/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyCommissionPool/CalculateWeeklyCommissionPoolCommandHandler.cs b/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyCommissionPool/CalculateWeeklyCommissionPoolCommandHandler.cs index 3435261..38e814f 100644 --- a/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyCommissionPool/CalculateWeeklyCommissionPoolCommandHandler.cs +++ b/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyCommissionPool/CalculateWeeklyCommissionPoolCommandHandler.cs @@ -192,7 +192,7 @@ public class CalculateWeeklyCommissionPoolCommandHandler : IRequestHandler w.UserId, cancellationToken); var newWallets = new List(); - var walletLogs = new List(); + var walletLogs = new List(); foreach (var payout in payouts) { @@ -241,7 +241,7 @@ public class CalculateWeeklyCommissionPoolCommandHandler : IRequestHandler l.RefrenceId.HasValue && oldPayoutIds.Contains(l.RefrenceId.Value)) .ToListAsync(cancellationToken); @@ -300,7 +300,7 @@ public class CalculateWeeklyCommissionPoolCommandHandler : IRequestHandler OrderVATs { get; } DbSet UserPackagePurchases { get; } DbSet UserWallets { get; } - DbSet UserWalletChangeLogs { get; } + DbSet UserWalletHistories { get; } DbSet ManualPayments { get; } DbSet PaymentTransactions { get; } DbSet PublicMessages { get; } diff --git a/src/CMSMicroservice.Application/Common/Mappings/UserWalletChangeLogProfile.cs b/src/CMSMicroservice.Application/Common/Mappings/UserWalletChangeLogProfile.cs deleted file mode 100644 index 5f7c28d..0000000 --- a/src/CMSMicroservice.Application/Common/Mappings/UserWalletChangeLogProfile.cs +++ /dev/null @@ -1,16 +0,0 @@ -using CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetAllUserWalletChangeLogByFilter; -using CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetUserWalletChangeLog; - -namespace CMSMicroservice.Application.Common.Mappings; - -public class UserWalletChangeLogProfile : IRegister -{ - void IRegister.Register(TypeAdapterConfig config) - { - config.NewConfig() - .Map(dest => dest.CreatedAt, src => src.Created); - - config.NewConfig() - .Map(dest => dest.CreatedAt, src => src.Created); - } -} diff --git a/src/CMSMicroservice.Application/Common/Mappings/UserWalletHistoryProfile.cs b/src/CMSMicroservice.Application/Common/Mappings/UserWalletHistoryProfile.cs new file mode 100644 index 0000000..a8cbfdb --- /dev/null +++ b/src/CMSMicroservice.Application/Common/Mappings/UserWalletHistoryProfile.cs @@ -0,0 +1,16 @@ +using CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetAllUserWalletHistoryByFilter; +using CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory; + +namespace CMSMicroservice.Application.Common.Mappings; + +public class UserWalletHistoryProfile : IRegister +{ + void IRegister.Register(TypeAdapterConfig config) + { + config.NewConfig() + .Map(dest => dest.CreatedAt, src => src.Created); + + config.NewConfig() + .Map(dest => dest.CreatedAt, src => src.Created); + } +} diff --git a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckAndProcessDayaLoans/CheckAndProcessDayaLoansCommandHandler.cs b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckAndProcessDayaLoans/CheckAndProcessDayaLoansCommandHandler.cs index 93d494a..fb0aa33 100644 --- a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckAndProcessDayaLoans/CheckAndProcessDayaLoansCommandHandler.cs +++ b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckAndProcessDayaLoans/CheckAndProcessDayaLoansCommandHandler.cs @@ -223,7 +223,7 @@ public class CheckAndProcessDayaLoansCommandHandler : IRequestHandler x.Wallet) .Where(x => x.Wallet.UserId == userId && x.Created >= startOfMonth) diff --git a/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQuery.cs b/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryQuery.cs similarity index 76% rename from src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQuery.cs rename to src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryQuery.cs index 87a3109..80037eb 100644 --- a/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQuery.cs +++ b/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryQuery.cs @@ -1,6 +1,6 @@ -namespace CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletChangeLog; +namespace CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletHistory; -public class GetCustomerWalletChangeLogQuery : IRequest> +public class GetCustomerWalletHistoryQuery : IRequest> { /// /// فیلتر بر اساس شناسه ارجاع (اختیاری) diff --git a/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQueryHandler.cs b/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryQueryHandler.cs similarity index 77% rename from src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQueryHandler.cs rename to src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryQueryHandler.cs index bb09d35..4c7fdaf 100644 --- a/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryQueryHandler.cs @@ -1,11 +1,11 @@ -namespace CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletChangeLog; +namespace CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletHistory; -public class GetCustomerWalletChangeLogQueryHandler : IRequestHandler> +public class GetCustomerWalletHistoryQueryHandler : IRequestHandler> { private readonly IApplicationDbContext _context; private readonly ICurrentUserService _currentUser; - public GetCustomerWalletChangeLogQueryHandler( + public GetCustomerWalletHistoryQueryHandler( IApplicationDbContext context, ICurrentUserService currentUser) { @@ -13,8 +13,8 @@ public class GetCustomerWalletChangeLogQueryHandler : IRequestHandler> Handle( - GetCustomerWalletChangeLogQuery request, + public async Task> Handle( + GetCustomerWalletHistoryQuery request, CancellationToken cancellationToken) { // Get current user's ID from JWT @@ -35,7 +35,7 @@ public class GetCustomerWalletChangeLogQueryHandler : IRequestHandler x.WalletId == userWallet.Id); @@ -53,7 +53,7 @@ public class GetCustomerWalletChangeLogQueryHandler : IRequestHandler x.Created) - .ProjectToType() + .ProjectToType() .ToListAsync(cancellationToken); return result; diff --git a/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogResponseDto.cs b/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryResponseDto.cs similarity index 94% rename from src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogResponseDto.cs rename to src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryResponseDto.cs index 0460c89..468e64d 100644 --- a/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletChangeLog/GetCustomerWalletChangeLogResponseDto.cs +++ b/src/CMSMicroservice.Application/UserWalletCQ/Queries/GetCustomerWalletHistory/GetCustomerWalletHistoryResponseDto.cs @@ -1,6 +1,6 @@ -namespace CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletChangeLog; +namespace CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletHistory; -public class GetCustomerWalletChangeLogResponseDto +public class GetCustomerWalletHistoryResponseDto { /// /// موجودی جاری diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandHandler.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandHandler.cs deleted file mode 100644 index 0e3cd6b..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.CreateNewUserWalletChangeLog; -public class CreateNewUserWalletChangeLogCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public CreateNewUserWalletChangeLogCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(CreateNewUserWalletChangeLogCommand request, - CancellationToken cancellationToken) - { - var entity = request.Adapt(); - await _context.UserWalletChangeLogs.AddAsync(entity, cancellationToken); - entity.AddDomainEvent(new CreateNewUserWalletChangeLogEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return entity.Adapt(); - } -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogResponseDto.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogResponseDto.cs deleted file mode 100644 index 5b83bf8..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogResponseDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.CreateNewUserWalletChangeLog; -public class CreateNewUserWalletChangeLogResponseDto -{ - //شناسه - public long Id { get; set; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommand.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommand.cs deleted file mode 100644 index 2c7e243..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommand.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.DeleteUserWalletChangeLog; -public record DeleteUserWalletChangeLogCommand : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandHandler.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandHandler.cs deleted file mode 100644 index 722888a..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.DeleteUserWalletChangeLog; -public class DeleteUserWalletChangeLogCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public DeleteUserWalletChangeLogCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(DeleteUserWalletChangeLogCommand request, CancellationToken cancellationToken) - { - var entity = await _context.UserWalletChangeLogs - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserWalletChangeLog), request.Id); - entity.IsDeleted = true; - _context.UserWalletChangeLogs.Update(entity); - entity.AddDomainEvent(new DeleteUserWalletChangeLogEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return Unit.Value; - } -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandValidator.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandValidator.cs deleted file mode 100644 index f4116a0..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/DeleteUserWalletChangeLog/DeleteUserWalletChangeLogCommandValidator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.DeleteUserWalletChangeLog; -public class DeleteUserWalletChangeLogCommandValidator : AbstractValidator -{ - public DeleteUserWalletChangeLogCommandValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteUserWalletChangeLogCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandHandler.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandHandler.cs deleted file mode 100644 index 4ab0f67..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.UpdateUserWalletChangeLog; -public class UpdateUserWalletChangeLogCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public UpdateUserWalletChangeLogCommandHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(UpdateUserWalletChangeLogCommand request, CancellationToken cancellationToken) - { - var entity = await _context.UserWalletChangeLogs - .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserWalletChangeLog), request.Id); - request.Adapt(entity); - _context.UserWalletChangeLogs.Update(entity); - entity.AddDomainEvent(new UpdateUserWalletChangeLogEvent(entity)); - await _context.SaveChangesAsync(cancellationToken); - return Unit.Value; - } -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/CreateNewUserWalletChangeLogEventHandlers/CreateNewUserWalletChangeLogEventHandler.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/CreateNewUserWalletChangeLogEventHandlers/CreateNewUserWalletChangeLogEventHandler.cs deleted file mode 100644 index 3a8f158..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/CreateNewUserWalletChangeLogEventHandlers/CreateNewUserWalletChangeLogEventHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.EventHandlers; - -public class CreateNewUserWalletChangeLogEventHandler : INotificationHandler -{ - private readonly ILogger< - CreateNewUserWalletChangeLogEventHandler> _logger; - - public CreateNewUserWalletChangeLogEventHandler(ILogger logger) - { - _logger = logger; - } - - public Task Handle(CreateNewUserWalletChangeLogEvent notification, CancellationToken cancellationToken) - { - _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); - - return Task.CompletedTask; - } -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/DeleteUserWalletChangeLogEventHandlers/DeleteUserWalletChangeLogEventHandler.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/DeleteUserWalletChangeLogEventHandlers/DeleteUserWalletChangeLogEventHandler.cs deleted file mode 100644 index e9cd2fa..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/DeleteUserWalletChangeLogEventHandlers/DeleteUserWalletChangeLogEventHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.EventHandlers; - -public class DeleteUserWalletChangeLogEventHandler : INotificationHandler -{ - private readonly ILogger< - DeleteUserWalletChangeLogEventHandler> _logger; - - public DeleteUserWalletChangeLogEventHandler(ILogger logger) - { - _logger = logger; - } - - public Task Handle(DeleteUserWalletChangeLogEvent notification, CancellationToken cancellationToken) - { - _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); - - return Task.CompletedTask; - } -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/UpdateUserWalletChangeLogEventHandlers/UpdateUserWalletChangeLogEventHandler.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/UpdateUserWalletChangeLogEventHandlers/UpdateUserWalletChangeLogEventHandler.cs deleted file mode 100644 index e2d5ff3..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/EventHandlers/UpdateUserWalletChangeLogEventHandlers/UpdateUserWalletChangeLogEventHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CMSMicroservice.Domain.Events; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.EventHandlers; - -public class UpdateUserWalletChangeLogEventHandler : INotificationHandler -{ - private readonly ILogger< - UpdateUserWalletChangeLogEventHandler> _logger; - - public UpdateUserWalletChangeLogEventHandler(ILogger logger) - { - _logger = logger; - } - - public Task Handle(UpdateUserWalletChangeLogEvent notification, CancellationToken cancellationToken) - { - _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); - - return Task.CompletedTask; - } -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryValidator.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryValidator.cs deleted file mode 100644 index a4d1626..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryValidator.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetAllUserWalletChangeLogByFilter; -public class GetAllUserWalletChangeLogByFilterQueryValidator : AbstractValidator -{ - public GetAllUserWalletChangeLogByFilterQueryValidator() - { - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllUserWalletChangeLogByFilterQuery)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQuery.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQuery.cs deleted file mode 100644 index 575a8d2..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQuery.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetUserWalletChangeLog; -public record GetUserWalletChangeLogQuery : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryHandler.cs b/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryHandler.cs deleted file mode 100644 index b731d47..0000000 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetUserWalletChangeLog; -public class GetUserWalletChangeLogQueryHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public GetUserWalletChangeLogQueryHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(GetUserWalletChangeLogQuery request, - CancellationToken cancellationToken) - { - var response = await _context.UserWalletChangeLogs - .AsNoTracking() - .Where(x => x.Id == request.Id) - .ProjectToType() - .FirstOrDefaultAsync(cancellationToken); - - return response ?? throw new NotFoundException(nameof(UserWalletChangeLog), request.Id); - } -} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommand.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommand.cs similarity index 72% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommand.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommand.cs index cb48da4..4598aaf 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommand.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommand.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.CreateNewUserWalletChangeLog; -public record CreateNewUserWalletChangeLogCommand : IRequest +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.CreateNewUserWalletHistory; +public record CreateNewUserWalletHistoryCommand : IRequest { //شناسه کیف پول public long WalletId { get; init; } diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandHandler.cs new file mode 100644 index 0000000..098230b --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandHandler.cs @@ -0,0 +1,21 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.CreateNewUserWalletHistory; +public class CreateNewUserWalletHistoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public CreateNewUserWalletHistoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CreateNewUserWalletHistoryCommand request, + CancellationToken cancellationToken) + { + var entity = request.Adapt(); + await _context.UserWalletHistories.AddAsync(entity, cancellationToken); + entity.AddDomainEvent(new CreateNewUserWalletHistoryEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return entity.Adapt(); + } +} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandValidator.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandValidator.cs similarity index 64% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandValidator.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandValidator.cs index bccc486..4587668 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/CreateNewUserWalletChangeLog/CreateNewUserWalletChangeLogCommandValidator.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryCommandValidator.cs @@ -1,7 +1,7 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.CreateNewUserWalletChangeLog; -public class CreateNewUserWalletChangeLogCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.CreateNewUserWalletHistory; +public class CreateNewUserWalletHistoryCommandValidator : AbstractValidator { - public CreateNewUserWalletChangeLogCommandValidator() + public CreateNewUserWalletHistoryCommandValidator() { RuleFor(model => model.WalletId) .NotNull(); @@ -18,7 +18,7 @@ public class CreateNewUserWalletChangeLogCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserWalletChangeLogCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserWalletHistoryCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryResponseDto.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryResponseDto.cs new file mode 100644 index 0000000..42e6f90 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/CreateNewUserWalletHistory/CreateNewUserWalletHistoryResponseDto.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.CreateNewUserWalletHistory; +public class CreateNewUserWalletHistoryResponseDto +{ + //شناسه + public long Id { get; set; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommand.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommand.cs new file mode 100644 index 0000000..b2513c3 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommand.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.DeleteUserWalletHistory; +public record DeleteUserWalletHistoryCommand : IRequest +{ + //شناسه + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandHandler.cs new file mode 100644 index 0000000..f22e9e6 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.DeleteUserWalletHistory; +public class DeleteUserWalletHistoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public DeleteUserWalletHistoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(DeleteUserWalletHistoryCommand request, CancellationToken cancellationToken) + { + var entity = await _context.UserWalletHistories + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserWalletHistory), request.Id); + entity.IsDeleted = true; + _context.UserWalletHistories.Update(entity); + entity.AddDomainEvent(new DeleteUserWalletHistoryEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandValidator.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandValidator.cs new file mode 100644 index 0000000..73fe3d5 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/DeleteUserWalletHistory/DeleteUserWalletHistoryCommandValidator.cs @@ -0,0 +1,16 @@ +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.DeleteUserWalletHistory; +public class DeleteUserWalletHistoryCommandValidator : AbstractValidator +{ + public DeleteUserWalletHistoryCommandValidator() + { + RuleFor(model => model.Id) + .NotNull(); + } + public Func>> ValidateValue => async (model, propertyName) => + { + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteUserWalletHistoryCommand)model, x => x.IncludeProperties(propertyName))); + if (result.IsValid) + return Array.Empty(); + return result.Errors.Select(e => e.ErrorMessage); + }; +} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommand.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommand.cs similarity index 78% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommand.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommand.cs index d41be96..adb8d32 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommand.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommand.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.UpdateUserWalletChangeLog; -public record UpdateUserWalletChangeLogCommand : IRequest +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.UpdateUserWalletHistory; +public record UpdateUserWalletHistoryCommand : IRequest { //شناسه public long Id { get; init; } diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandHandler.cs new file mode 100644 index 0000000..31ba567 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.UpdateUserWalletHistory; +public class UpdateUserWalletHistoryCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateUserWalletHistoryCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateUserWalletHistoryCommand request, CancellationToken cancellationToken) + { + var entity = await _context.UserWalletHistories + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(UserWalletHistory), request.Id); + request.Adapt(entity); + _context.UserWalletHistories.Update(entity); + entity.AddDomainEvent(new UpdateUserWalletHistoryEvent(entity)); + await _context.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandValidator.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandValidator.cs similarity index 67% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandValidator.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandValidator.cs index 3a6c32d..7159ef0 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Commands/UpdateUserWalletChangeLog/UpdateUserWalletChangeLogCommandValidator.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Commands/UpdateUserWalletHistory/UpdateUserWalletHistoryCommandValidator.cs @@ -1,7 +1,7 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.UpdateUserWalletChangeLog; -public class UpdateUserWalletChangeLogCommandValidator : AbstractValidator +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Commands.UpdateUserWalletHistory; +public class UpdateUserWalletHistoryCommandValidator : AbstractValidator { - public UpdateUserWalletChangeLogCommandValidator() + public UpdateUserWalletHistoryCommandValidator() { RuleFor(model => model.Id) .NotNull(); @@ -20,7 +20,7 @@ public class UpdateUserWalletChangeLogCommandValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateUserWalletChangeLogCommand)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateUserWalletHistoryCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/CreateNewUserWalletHistoryEventHandlers/CreateNewUserWalletHistoryEventHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/CreateNewUserWalletHistoryEventHandlers/CreateNewUserWalletHistoryEventHandler.cs new file mode 100644 index 0000000..d1640dc --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/CreateNewUserWalletHistoryEventHandlers/CreateNewUserWalletHistoryEventHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.UserWalletHistoryCQ.EventHandlers; + +public class CreateNewUserWalletHistoryEventHandler : INotificationHandler +{ + private readonly ILogger< + CreateNewUserWalletHistoryEventHandler> _logger; + + public CreateNewUserWalletHistoryEventHandler(ILogger logger) + { + _logger = logger; + } + + public Task Handle(CreateNewUserWalletHistoryEvent notification, CancellationToken cancellationToken) + { + _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); + + return Task.CompletedTask; + } +} diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/DeleteUserWalletHistoryEventHandlers/DeleteUserWalletHistoryEventHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/DeleteUserWalletHistoryEventHandlers/DeleteUserWalletHistoryEventHandler.cs new file mode 100644 index 0000000..a9b244e --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/DeleteUserWalletHistoryEventHandlers/DeleteUserWalletHistoryEventHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.UserWalletHistoryCQ.EventHandlers; + +public class DeleteUserWalletHistoryEventHandler : INotificationHandler +{ + private readonly ILogger< + DeleteUserWalletHistoryEventHandler> _logger; + + public DeleteUserWalletHistoryEventHandler(ILogger logger) + { + _logger = logger; + } + + public Task Handle(DeleteUserWalletHistoryEvent notification, CancellationToken cancellationToken) + { + _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); + + return Task.CompletedTask; + } +} diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/UpdateUserWalletHistoryEventHandlers/UpdateUserWalletHistoryEventHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/UpdateUserWalletHistoryEventHandlers/UpdateUserWalletHistoryEventHandler.cs new file mode 100644 index 0000000..02a7758 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/EventHandlers/UpdateUserWalletHistoryEventHandlers/UpdateUserWalletHistoryEventHandler.cs @@ -0,0 +1,22 @@ +using CMSMicroservice.Domain.Events; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Application.UserWalletHistoryCQ.EventHandlers; + +public class UpdateUserWalletHistoryEventHandler : INotificationHandler +{ + private readonly ILogger< + UpdateUserWalletHistoryEventHandler> _logger; + + public UpdateUserWalletHistoryEventHandler(ILogger logger) + { + _logger = logger; + } + + public Task Handle(UpdateUserWalletHistoryEvent notification, CancellationToken cancellationToken) + { + _logger.LogInformation("Domain Event: {DomainEvent}", notification.GetType().Name); + + return Task.CompletedTask; + } +} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQuery.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQuery.cs similarity index 66% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQuery.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQuery.cs index 22bf531..840a661 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQuery.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQuery.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetAllUserWalletChangeLogByFilter; -public record GetAllUserWalletChangeLogByFilterQuery : IRequest +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetAllUserWalletHistoryByFilter; +public record GetAllUserWalletHistoryByFilterQuery : IRequest { //موقعیت صفحه بندی public PaginationState? PaginationState { get; init; } //مرتب سازی بر اساس public string? SortBy { get; init; } //فیلتر - public GetAllUserWalletChangeLogByFilterFilter? Filter { get; init; } + public GetAllUserWalletHistoryByFilterFilter? Filter { get; init; } -}public class GetAllUserWalletChangeLogByFilterFilter +}public class GetAllUserWalletHistoryByFilterFilter { //شناسه public long? Id { get; set; } diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryHandler.cs similarity index 63% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryHandler.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryHandler.cs index 2989c8b..ce0c96d 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterQueryHandler.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryHandler.cs @@ -1,16 +1,16 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetAllUserWalletChangeLogByFilter; -public class GetAllUserWalletChangeLogByFilterQueryHandler : IRequestHandler +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetAllUserWalletHistoryByFilter; +public class GetAllUserWalletHistoryByFilterQueryHandler : IRequestHandler { private readonly IApplicationDbContext _context; - public GetAllUserWalletChangeLogByFilterQueryHandler(IApplicationDbContext context) + public GetAllUserWalletHistoryByFilterQueryHandler(IApplicationDbContext context) { _context = context; } - public async Task Handle(GetAllUserWalletChangeLogByFilterQuery request, CancellationToken cancellationToken) + public async Task Handle(GetAllUserWalletHistoryByFilterQuery request, CancellationToken cancellationToken) { - var query = _context.UserWalletChangeLogs + var query = _context.UserWalletHistories .Include(i=>i.Wallet) .ApplyOrder(sortBy: request.SortBy) .AsNoTracking() @@ -27,11 +27,11 @@ public class GetAllUserWalletChangeLogByFilterQueryHandler : IRequestHandler request.Filter.UserId == null || x.Wallet.UserId == request.Filter.UserId) ; } - return new GetAllUserWalletChangeLogByFilterResponseDto + return new GetAllUserWalletHistoryByFilterResponseDto { 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/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryValidator.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryValidator.cs new file mode 100644 index 0000000..5b59f37 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterQueryValidator.cs @@ -0,0 +1,14 @@ +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetAllUserWalletHistoryByFilter; +public class GetAllUserWalletHistoryByFilterQueryValidator : AbstractValidator +{ + public GetAllUserWalletHistoryByFilterQueryValidator() + { + } + public Func>> ValidateValue => async (model, propertyName) => + { + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllUserWalletHistoryByFilterQuery)model, x => x.IncludeProperties(propertyName))); + if (result.IsValid) + return Array.Empty(); + return result.Errors.Select(e => e.ErrorMessage); + }; +} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterResponseDto.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterResponseDto.cs similarity index 70% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterResponseDto.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterResponseDto.cs index d145fe4..81cfc31 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetAllUserWalletChangeLogByFilter/GetAllUserWalletChangeLogByFilterResponseDto.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetAllUserWalletHistoryByFilter/GetAllUserWalletHistoryByFilterResponseDto.cs @@ -1,12 +1,12 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetAllUserWalletChangeLogByFilter; -public class GetAllUserWalletChangeLogByFilterResponseDto +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetAllUserWalletHistoryByFilter; +public class GetAllUserWalletHistoryByFilterResponseDto { //متادیتا public MetaData MetaData { get; set; } //مدل خروجی - public List? Models { get; set; } + public List? Models { get; set; } -}public class GetAllUserWalletChangeLogByFilterResponseModel +}public class GetAllUserWalletHistoryByFilterResponseModel { //شناسه public long Id { get; set; } diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQuery.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQuery.cs new file mode 100644 index 0000000..a71c939 --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQuery.cs @@ -0,0 +1,7 @@ +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory; +public record GetUserWalletHistoryQuery : IRequest +{ + //شناسه + public long Id { get; init; } + +} \ No newline at end of file diff --git a/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryHandler.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryHandler.cs new file mode 100644 index 0000000..13c58cd --- /dev/null +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryHandler.cs @@ -0,0 +1,22 @@ +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory; +public class GetUserWalletHistoryQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetUserWalletHistoryQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetUserWalletHistoryQuery request, + CancellationToken cancellationToken) + { + var response = await _context.UserWalletHistories + .AsNoTracking() + .Where(x => x.Id == request.Id) + .ProjectToType() + .FirstOrDefaultAsync(cancellationToken); + + return response ?? throw new NotFoundException(nameof(UserWalletHistory), request.Id); + } +} diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryValidator.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryValidator.cs similarity index 51% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryValidator.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryValidator.cs index 69d3282..df18151 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogQueryValidator.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryQueryValidator.cs @@ -1,14 +1,14 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetUserWalletChangeLog; -public class GetUserWalletChangeLogQueryValidator : AbstractValidator +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory; +public class GetUserWalletHistoryQueryValidator : AbstractValidator { - public GetUserWalletChangeLogQueryValidator() + public GetUserWalletHistoryQueryValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetUserWalletChangeLogQuery)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetUserWalletHistoryQuery)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); diff --git a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogResponseDto.cs b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryResponseDto.cs similarity index 82% rename from src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogResponseDto.cs rename to src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryResponseDto.cs index 28896ae..d2e672f 100644 --- a/src/CMSMicroservice.Application/UserWalletChangeLogCQ/Queries/GetUserWalletChangeLog/GetUserWalletChangeLogResponseDto.cs +++ b/src/CMSMicroservice.Application/UserWalletHistoryCQ/Queries/GetUserWalletHistory/GetUserWalletHistoryResponseDto.cs @@ -1,5 +1,5 @@ -namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetUserWalletChangeLog; -public class GetUserWalletChangeLogResponseDto +namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory; +public class GetUserWalletHistoryResponseDto { //شناسه public long Id { get; set; } diff --git a/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs b/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs index 3dac1d8..400b8dd 100644 --- a/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs +++ b/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyDiscountWalletCharge/VerifyDiscountWalletChargeCommandHandler.cs @@ -115,7 +115,7 @@ public class VerifyDiscountWalletChargeCommandHandler await _context.SaveChangesAsync(cancellationToken); // ثبت لاگ تغییرات کیف پول (بعد از ایجاد Transaction برای داشتن TransactionId) - _context.UserWalletChangeLogs.Add(new Domain.Entities.UserWalletChangeLog + _context.UserWalletHistories.Add(new Domain.Entities.UserWalletHistory { WalletId = wallet.Id, CurrentBalance = wallet.Balance, diff --git a/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyMagicWalletCharge/VerifyMagicWalletChargeCommandHandler.cs b/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyMagicWalletCharge/VerifyMagicWalletChargeCommandHandler.cs index ab78b4e..17425b6 100644 --- a/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyMagicWalletCharge/VerifyMagicWalletChargeCommandHandler.cs +++ b/src/CMSMicroservice.Application/WalletCQ/Commands/VerifyMagicWalletCharge/VerifyMagicWalletChargeCommandHandler.cs @@ -167,8 +167,8 @@ public class VerifyMagicWalletChargeCommandHandler wallet.MagicTotalDeposited += depositAmount; wallet.MagicTotalCredited += creditAmount; - // 9. ثبت WalletChangeLog (اجباری) - var walletLog = new UserWalletChangeLog + // 9. ثبت WalletHistory (اجباری) + var walletLog = new UserWalletHistory { WalletId = wallet.Id, CurrentBalance = wallet.Balance, @@ -181,7 +181,7 @@ public class VerifyMagicWalletChargeCommandHandler RefrenceId = depositTransaction.Id }; - _context.UserWalletChangeLogs.Add(walletLog); + _context.UserWalletHistories.Add(walletLog); // 10. لینک PaymentTransaction به Transaction داخلی paymentTx.TransactionId = depositTransaction.Id; diff --git a/src/CMSMicroservice.Domain/Common/IHasHistory.cs b/src/CMSMicroservice.Domain/Common/IHasHistory.cs new file mode 100644 index 0000000..dfa52ca --- /dev/null +++ b/src/CMSMicroservice.Domain/Common/IHasHistory.cs @@ -0,0 +1,19 @@ +namespace CMSMicroservice.Domain.Common; + +/// +/// اینترفیس مارکر برای entityهایی که تاریخچه تغییرات خودکار دارند (Q27). +/// هر entity که این اینترفیس رو implement کنه، در SaveChanges interceptor +/// به‌صورت خودکار یک snapshot از تغییرات ثبت می‌شه. +/// +/// نوع entity تاریخچه (مثلاً PackageHistory) +public interface IHasHistory where THistory : BaseAuditableEntity, new() +{ + /// + /// ساخت snapshot تاریخچه از وضعیت فعلی entity. + /// اطلاعات Original (قبل از تغییر) و Current (بعد از تغییر) باید مقایسه شوند. + /// + /// نوع عملیات (Created, Updated, etc.) — as string to be generic + /// چه کسی انجام داده + /// یک رکورد تاریخچه آماده ذخیره + THistory CreateHistorySnapshot(string action, string? performedBy); +} diff --git a/src/CMSMicroservice.Domain/Entities/Package.cs b/src/CMSMicroservice.Domain/Entities/Package.cs index 9950886..158a150 100644 --- a/src/CMSMicroservice.Domain/Entities/Package.cs +++ b/src/CMSMicroservice.Domain/Entities/Package.cs @@ -1,9 +1,12 @@ +using CMSMicroservice.Domain.Common; +using CMSMicroservice.Domain.Enums; + namespace CMSMicroservice.Domain.Entities; /// /// پکیج — هر پکیج قیمت، ویژگی‌ها و تنظیمات مستقل دارد /// -public class Package : BaseAuditableEntity +public class Package : BaseAuditableEntity, IHasHistory { // === فیلدهای فعلی (حفظ) === @@ -76,4 +79,23 @@ public class Package : BaseAuditableEntity /// تاریخچه تغییرات پکیج (Q27) public virtual ICollection? PackageHistories { get; set; } + + /// + /// ساخت snapshot تاریخچه — Q27 auto-tracking + /// + public History.PackageHistory CreateHistorySnapshot(string action, string? performedBy) + { + return new History.PackageHistory + { + PackageId = Id, + NewPrice = Price, + NewActivationFee = ActivationFee, + NewMagicMultiplier = MagicWalletMultiplier, + NewMagicMaxDeposit = MagicWalletMaxDeposit, + NewMaxBalancesPerLeg = MaxBalancesPerLeg, + NewIsActive = IsActive, + Action = Enum.TryParse(action, out var a) ? a : PackageAction.Updated, + PerformedBy = performedBy + }; + } } diff --git a/src/CMSMicroservice.Domain/Entities/UserWallet.cs b/src/CMSMicroservice.Domain/Entities/UserWallet.cs index ce14154..a6dd001 100644 --- a/src/CMSMicroservice.Domain/Entities/UserWallet.cs +++ b/src/CMSMicroservice.Domain/Entities/UserWallet.cs @@ -48,6 +48,6 @@ public class UserWallet : BaseAuditableEntity #endregion - //UserWalletChangeLog Collection Navigation Reference - public virtual ICollection UserWalletChangeLogs { get; set; } + //UserWalletHistory Collection Navigation Reference + public virtual ICollection UserWalletHistories { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/UserWalletChangeLog.cs b/src/CMSMicroservice.Domain/Entities/UserWalletHistory.cs similarity index 95% rename from src/CMSMicroservice.Domain/Entities/UserWalletChangeLog.cs rename to src/CMSMicroservice.Domain/Entities/UserWalletHistory.cs index a5b6471..c4faf01 100644 --- a/src/CMSMicroservice.Domain/Entities/UserWalletChangeLog.cs +++ b/src/CMSMicroservice.Domain/Entities/UserWalletHistory.cs @@ -1,6 +1,6 @@ namespace CMSMicroservice.Domain.Entities; //آدرس کاربر -public class UserWalletChangeLog : BaseAuditableEntity +public class UserWalletHistory : BaseAuditableEntity { //شناسه کیف پول public long WalletId { get; set; } diff --git a/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/CreateNewUserWalletChangeLogEvent.cs b/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/CreateNewUserWalletChangeLogEvent.cs deleted file mode 100644 index 8e268c6..0000000 --- a/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/CreateNewUserWalletChangeLogEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class CreateNewUserWalletChangeLogEvent : BaseEvent -{ - public CreateNewUserWalletChangeLogEvent(UserWalletChangeLog item) - { - } - public UserWalletChangeLog Item { get; } -} diff --git a/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/DeleteUserWalletChangeLogEvent.cs b/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/DeleteUserWalletChangeLogEvent.cs deleted file mode 100644 index 742f8d8..0000000 --- a/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/DeleteUserWalletChangeLogEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class DeleteUserWalletChangeLogEvent : BaseEvent -{ - public DeleteUserWalletChangeLogEvent(UserWalletChangeLog item) - { - } - public UserWalletChangeLog Item { get; } -} diff --git a/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/UpdateUserWalletChangeLogEvent.cs b/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/UpdateUserWalletChangeLogEvent.cs deleted file mode 100644 index 4a4a903..0000000 --- a/src/CMSMicroservice.Domain/Events/UserWalletChangeLogEvents/UpdateUserWalletChangeLogEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CMSMicroservice.Domain.Events; -public class UpdateUserWalletChangeLogEvent : BaseEvent -{ - public UpdateUserWalletChangeLogEvent(UserWalletChangeLog item) - { - } - public UserWalletChangeLog Item { get; } -} diff --git a/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/CreateNewUserWalletHistoryEvent.cs b/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/CreateNewUserWalletHistoryEvent.cs new file mode 100644 index 0000000..41d38ef --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/CreateNewUserWalletHistoryEvent.cs @@ -0,0 +1,8 @@ +namespace CMSMicroservice.Domain.Events; +public class CreateNewUserWalletHistoryEvent : BaseEvent +{ + public CreateNewUserWalletHistoryEvent(UserWalletHistory item) + { + } + public UserWalletHistory Item { get; } +} diff --git a/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/DeleteUserWalletHistoryEvent.cs b/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/DeleteUserWalletHistoryEvent.cs new file mode 100644 index 0000000..bb87753 --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/DeleteUserWalletHistoryEvent.cs @@ -0,0 +1,8 @@ +namespace CMSMicroservice.Domain.Events; +public class DeleteUserWalletHistoryEvent : BaseEvent +{ + public DeleteUserWalletHistoryEvent(UserWalletHistory item) + { + } + public UserWalletHistory Item { get; } +} diff --git a/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/UpdateUserWalletHistoryEvent.cs b/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/UpdateUserWalletHistoryEvent.cs new file mode 100644 index 0000000..83cf2e2 --- /dev/null +++ b/src/CMSMicroservice.Domain/Events/UserWalletHistoryEvents/UpdateUserWalletHistoryEvent.cs @@ -0,0 +1,8 @@ +namespace CMSMicroservice.Domain.Events; +public class UpdateUserWalletHistoryEvent : BaseEvent +{ + public UpdateUserWalletHistoryEvent(UserWalletHistory item) + { + } + public UserWalletHistory Item { get; } +} diff --git a/src/CMSMicroservice.Infrastructure/ConfigureServices.cs b/src/CMSMicroservice.Infrastructure/ConfigureServices.cs index edd7a68..63a7707 100644 --- a/src/CMSMicroservice.Infrastructure/ConfigureServices.cs +++ b/src/CMSMicroservice.Infrastructure/ConfigureServices.cs @@ -31,6 +31,7 @@ public static class ConfigureServices services.Configure(configuration.GetSection(SmsSettings.SectionName)); services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs index 3d8b33a..4216ee8 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs @@ -18,6 +18,7 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext { private readonly IMediator? _mediator; private readonly AuditableEntitySaveChangesInterceptor? _auditableEntitySaveChangesInterceptor; + private readonly HistoryTrackingSaveChangesInterceptor? _historyTrackingInterceptor; /// /// Constructor برای design-time (migrations) @@ -33,11 +34,13 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext public ApplicationDbContext( DbContextOptions options, IMediator mediator, - AuditableEntitySaveChangesInterceptor auditableEntitySaveChangesInterceptor) + AuditableEntitySaveChangesInterceptor auditableEntitySaveChangesInterceptor, + HistoryTrackingSaveChangesInterceptor historyTrackingInterceptor) : base(options) { _mediator = mediator; _auditableEntitySaveChangesInterceptor = auditableEntitySaveChangesInterceptor; + _historyTrackingInterceptor = historyTrackingInterceptor; } protected override void OnModelCreating(ModelBuilder builder) { @@ -57,6 +60,11 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext optionsBuilder.AddInterceptors(_auditableEntitySaveChangesInterceptor); } + if (_historyTrackingInterceptor != null) + { + optionsBuilder.AddInterceptors(_historyTrackingInterceptor); + } + // Suppress PendingModelChangesWarning in EF Core 9 optionsBuilder.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning)); } @@ -89,7 +97,7 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext public DbSet OrderVATs => Set(); public DbSet UserPackagePurchases => Set(); public DbSet UserWallets => Set(); - public DbSet UserWalletChangeLogs => Set(); + public DbSet UserWalletHistories => Set(); public DbSet DayaLoanContracts => Set(); // Payment diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletChangeLogConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletHistoryConfiguration.cs similarity index 85% rename from src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletChangeLogConfiguration.cs rename to src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletHistoryConfiguration.cs index f06d48f..2ee1304 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletChangeLogConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletHistoryConfiguration.cs @@ -3,9 +3,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace CMSMicroservice.Infrastructure.Persistence.Configurations; //آدرس کاربر -public class UserWalletChangeLogConfiguration : IEntityTypeConfiguration +public class UserWalletHistoryConfiguration : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.HasQueryFilter(p => !p.IsDeleted); builder.Ignore(entity => entity.DomainEvents); @@ -13,7 +13,7 @@ public class UserWalletChangeLogConfiguration : IEntityTypeConfiguration entity.Id).UseIdentityColumn(); builder .HasOne(entity => entity.Wallet) - .WithMany(entity => entity.UserWalletChangeLogs) + .WithMany(entity => entity.UserWalletHistories) .HasForeignKey(entity => entity.WalletId) .IsRequired(true); builder.Property(entity => entity.CurrentBalance).IsRequired(true); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Interceptors/HistoryTrackingSaveChangesInterceptor.cs b/src/CMSMicroservice.Infrastructure/Persistence/Interceptors/HistoryTrackingSaveChangesInterceptor.cs new file mode 100644 index 0000000..c67cf1d --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Interceptors/HistoryTrackingSaveChangesInterceptor.cs @@ -0,0 +1,150 @@ +using System.Collections.Generic; +using System.Linq; +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Common; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.Extensions.Logging; + +namespace CMSMicroservice.Infrastructure.Persistence.Interceptors; + +/// +/// Interceptor ثبت خودکار تاریخچه تغییرات (Q27). +/// هر entity که IHasHistory<T> رو implement کرده باشه، +/// هنگام Modified یا Added شدن یک رکورد history ثبت می‌شه. +/// +public class HistoryTrackingSaveChangesInterceptor : SaveChangesInterceptor +{ + private readonly ICurrentUserService _currentUserService; + private readonly ILogger _logger; + + public HistoryTrackingSaveChangesInterceptor( + ICurrentUserService currentUserService, + ILogger logger) + { + _currentUserService = currentUserService; + _logger = logger; + } + + public override InterceptionResult SavingChanges( + DbContextEventData eventData, + InterceptionResult result) + { + TrackHistoryChanges(eventData.Context); + return base.SavingChanges(eventData, result); + } + + public override ValueTask> SavingChangesAsync( + DbContextEventData eventData, + InterceptionResult result, + CancellationToken cancellationToken = default) + { + TrackHistoryChanges(eventData.Context); + return base.SavingChangesAsync(eventData, result, cancellationToken); + } + + private void TrackHistoryChanges(DbContext? context) + { + if (context == null) return; + + var performedBy = _currentUserService.GetPerformedBy(); + var historyEntries = new List(); + + foreach (var entry in context.ChangeTracker.Entries()) + { + // فقط Modified و Added — Deleted رو ignore می‌کنیم (soft delete) + if (entry.State != EntityState.Modified && entry.State != EntityState.Added) + continue; + + var entityType = entry.Entity.GetType(); + + // بررسی اینکه entity آیا IHasHistory رو implement کرده + var historyInterface = entityType.GetInterfaces() + .FirstOrDefault(i => i.IsGenericType + && i.GetGenericTypeDefinition() == typeof(IHasHistory<>)); + + if (historyInterface == null) + continue; + + // تعیین نوع عملیات + var action = entry.State == EntityState.Added ? "Created" : "Updated"; + + try + { + // فراخوانی CreateHistorySnapshot از طریق reflection + var method = historyInterface.GetMethod("CreateHistorySnapshot"); + if (method == null) continue; + + var historyEntity = method.Invoke(entry.Entity, new object?[] { action, performedBy }); + if (historyEntity == null) continue; + + // برای Modified: مقادیر Original رو ست کنیم + if (entry.State == EntityState.Modified) + { + SetOriginalValues(entry, historyEntity); + } + + historyEntries.Add(historyEntity); + } + catch (Exception ex) + { + _logger.LogWarning(ex, + "Failed to create history snapshot for {EntityType} (Id={Id})", + entityType.Name, + entry.Property("Id").CurrentValue); + } + } + + // اضافه کردن history entities به context + foreach (var historyEntry in historyEntries) + { + context.Add(historyEntry); + } + + if (historyEntries.Count > 0) + { + _logger.LogDebug("HistoryTrackingInterceptor: {Count} history records queued", historyEntries.Count); + } + } + + /// + /// ست کردن مقادیر Original (قبل از تغییر) روی history entity. + /// از روی نام property: "OldX" ← OriginalValue("X"), "NewX" ← CurrentValue("X") + /// + private static void SetOriginalValues( + Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry entry, + object historyEntity) + { + var historyType = historyEntity.GetType(); + var historyProps = historyType.GetProperties(); + + foreach (var historyProp in historyProps) + { + // الگو: OldPrice ← entry.OriginalValues["Price"] + if (!historyProp.Name.StartsWith("Old") || !historyProp.CanWrite) + continue; + + var sourcePropertyName = historyProp.Name[3..]; // "OldPrice" → "Price" + + try + { + var entryProperty = entry.Properties + .FirstOrDefault(p => p.Metadata.Name == sourcePropertyName); + + if (entryProperty != null) + { + var originalValue = entryProperty.OriginalValue; + // تبدیل نوع اگه nullable باشه + if (originalValue != null || Nullable.GetUnderlyingType(historyProp.PropertyType) != null) + { + historyProp.SetValue(historyEntity, originalValue); + } + } + } + catch + { + // اگه property match نداشت، skip — ممکنه OldIsActive با bool? باشه + } + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.Designer.cs new file mode 100644 index 0000000..9a5a420 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.Designer.cs @@ -0,0 +1,5203 @@ +// +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("20260227024734_Q27_HistoryTables_And_RenameWalletHistory")] + partial class Q27_HistoryTables_And_RenameWalletHistory + { + /// + 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.Blog.BlogCategory", 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(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IconName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + 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("Slug") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_BlogCategories_IsActive"); + + b.HasIndex("Slug") + .IsUnique() + .HasDatabaseName("IX_BlogCategories_Slug"); + + b.ToTable("BlogCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AuthorUserId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("FeaturedImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("FeaturedImageThumbnailPath") + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsFeatured") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PublishedAt") + .HasColumnType("datetime2"); + + b.Property("ScheduledPublishAt") + .HasColumnType("datetime2"); + + b.Property("Slug") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Summary") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ViewCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("AuthorUserId") + .HasDatabaseName("IX_BlogPosts_AuthorUserId"); + + b.HasIndex("IsFeatured") + .HasDatabaseName("IX_BlogPosts_IsFeatured"); + + b.HasIndex("PublishedAt") + .HasDatabaseName("IX_BlogPosts_PublishedAt"); + + b.HasIndex("Slug") + .IsUnique() + .HasDatabaseName("IX_BlogPosts_Slug"); + + b.HasIndex("Status") + .HasDatabaseName("IX_BlogPosts_Status"); + + b.HasIndex("Status", "PublishedAt") + .HasDatabaseName("IX_BlogPosts_Status_PublishedAt"); + + b.ToTable("BlogPosts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPostCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BlogCategoryId") + .HasColumnType("bigint"); + + b.Property("BlogPostId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BlogCategoryId"); + + b.HasIndex("BlogPostId"); + + b.ToTable("BlogPostCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPostImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AltText") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("BlogPostId") + .HasColumnType("bigint"); + + b.Property("Caption") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .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("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("BlogPostId"); + + b.ToTable("BlogPostImages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BlogPostId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BlogPostId"); + + b.HasIndex("TagId"); + + b.ToTable("BlogPostTags", "CMS"); + }); + + 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("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("FirstActivationDate") + .HasColumnType("datetime2"); + + b.Property("FirstPackageId") + .HasColumnType("bigint"); + + b.Property("GiftValue") + .HasColumnType("bigint"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastActivationDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastPackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("FirstPackageId"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_ClubMembership_IsActive"); + + b.HasIndex("LastActivationDate") + .HasDatabaseName("IX_ClubMembership_LastActivationDate"); + + b.HasIndex("LastPackageId"); + + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("IX_ClubMembership_UserId"); + + b.ToTable("ClubMemberships", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembershipCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CycleNumber") + .HasColumnType("int"); + + b.Property("IsCurrentCycle") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("MagicCompletedAt") + .HasColumnType("datetime2"); + + b.Property("MagicStartedAt") + .HasColumnType("datetime2"); + + b.Property("PackageAmount") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PackagePurchasedAt") + .HasColumnType("datetime2"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ClubMembershipId"); + + b.HasIndex("PackageId"); + + b.HasIndex("PackagePurchasedAt") + .HasDatabaseName("IX_ClubMembershipCycle_PackagePurchasedAt"); + + b.HasIndex("UserId", "IsCurrentCycle") + .HasDatabaseName("IX_ClubMembershipCycle_UserId_IsCurrentCycle"); + + b.ToTable("ClubMembershipCycles", "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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + 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("PackageId") + .HasColumnType("bigint"); + + 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("WeekDefinitionId") + .HasColumnType("bigint"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("WithdrawnAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("Status") + .HasDatabaseName("IX_UserCommissionPayout_Status"); + + b.HasIndex("WeekDefinitionId"); + + b.HasIndex("WeeklyPoolId") + .HasDatabaseName("IX_UserCommissionPayout_WeeklyPoolId"); + + b.HasIndex("UserId", "WeekDefinitionId", "PackageId") + .IsUnique() + .HasDatabaseName("IX_UserCommissionPayout_User_WeekDef_Package"); + + 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("PackageId") + .HasColumnType("bigint"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekDefinitionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsCalculated") + .HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated"); + + b.HasIndex("PackageId"); + + b.HasIndex("WeekDefinitionId", "PackageId") + .IsUnique() + .HasDatabaseName("IX_WeeklyCommissionPool_WeekDef_Package"); + + 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("WeekDefinitionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekDefinitionId"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.AppVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AppName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentVersion") + .IsRequired() + .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("MinRequiredVersion") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ReleaseNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiresFullCacheClear") + .HasColumnType("bit"); + + b.Property("UpdateMessage") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AppVersions", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Content.SitePage", 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("HeroImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("HeroSubtitle") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("HeroTitle") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + 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("MetaDescription") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("PageKey") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("PageKey") + .IsUnique() + .HasDatabaseName("IX_SitePages_PageKey"); + + b.ToTable("SitePages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Content.SitePageImage", 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("IconName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ImageGroup") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + 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("LinkUrl") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("SitePageSettingsId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Subtitle") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("ThumbnailPath") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("SitePageSettingsId", "ImageGroup") + .HasDatabaseName("IX_SitePageImages_SettingsId_Group"); + + b.ToTable("SitePageImages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Content.SitePageSection", 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("ExtraData") + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .HasColumnType("nvarchar(max)"); + + b.Property("IconName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .HasColumnType("nvarchar(max)"); + + 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("SectionKey") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SitePageId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Subtitle") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("SitePageId", "SectionKey") + .HasDatabaseName("IX_SitePageSections_PageId_SectionKey"); + + b.ToTable("SitePageSections", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Content.SitePageSettings", 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("HeroImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("HeroSubtitle") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("HeroTitle") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + 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("MetaDescription") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("PageKey") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SettingsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("PageKey") + .IsUnique() + .HasDatabaseName("IX_SitePageSettings_PageKey"); + + b.ToTable("SitePageSettings", "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") + .HasColumnType("nvarchar(max)"); + + 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() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + 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() + .HasColumnType("nvarchar(max)"); + + 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.DiscountProductImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AltText") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountProductId") + .HasColumnType("bigint"); + + b.Property("ImagePath") + .IsRequired() + .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("SortOrder") + .HasColumnType("int"); + + b.Property("ThumbnailPath") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("DiscountProductId"); + + b.HasIndex("DiscountProductId", "SortOrder"); + + b.ToTable("DiscountProductImages", "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.Geography.City", 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("ExternalId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Latitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Longitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Native") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)") + .HasDefaultValue(""); + + b.Property("StateId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("StateId") + .HasDatabaseName("IX_Cities_StateId"); + + b.ToTable("Cities", "GMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Capital") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CurrencyName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CurrencySymbol") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Emoji") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("EmojiU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ExternalId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("Iso2") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("nvarchar(2)"); + + b.Property("Iso3") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Latitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Longitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Native") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("NumericCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("PhoneCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Region") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Subregion") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Tld") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.ToTable("Countries", "GMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.State", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CountryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExternalId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Latitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Longitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Native") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)") + .HasDefaultValue(""); + + b.Property("StateCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("CountryId") + .HasDatabaseName("IX_States_CountryId"); + + b.ToTable("States", "GMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipCycleHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipCycleId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CycleNumber") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewIsCurrentCycle") + .HasColumnType("bit"); + + b.Property("NewMagicCompletedAt") + .HasColumnType("datetime2"); + + b.Property("NewMagicStartedAt") + .HasColumnType("datetime2"); + + b.Property("OldIsCurrentCycle") + .HasColumnType("bit"); + + b.Property("OldMagicCompletedAt") + .HasColumnType("datetime2"); + + b.Property("OldMagicStartedAt") + .HasColumnType("datetime2"); + + 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_ClubMembershipCycleHistory_Action"); + + b.HasIndex("ClubMembershipCycleId") + .HasDatabaseName("IX_ClubMembershipCycleHistory_CycleId"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_ClubMembershipCycleHistory_UserId_Created"); + + b.ToTable("ClubMembershipCycleHistories", "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("WeekDefinitionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_CommissionPayoutHistory_Action"); + + b.HasIndex("UserCommissionPayoutId") + .HasDatabaseName("IX_CommissionPayoutHistory_PayoutId"); + + b.HasIndex("WeekDefinitionId") + .HasDatabaseName("IX_CommissionPayoutHistory_WeekDefinitionId"); + + 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.PackageHistory", 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("NewActivationFee") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("NewMagicMaxDeposit") + .HasColumnType("bigint"); + + b.Property("NewMagicMultiplier") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("NewMaxBalancesPerLeg") + .HasColumnType("int"); + + b.Property("NewPrice") + .HasColumnType("bigint"); + + b.Property("OldActivationFee") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("OldMagicMaxDeposit") + .HasColumnType("bigint"); + + b.Property("OldMagicMultiplier") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("OldMaxBalancesPerLeg") + .HasColumnType("int"); + + b.Property("OldPrice") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_PackageHistory_Action"); + + b.HasIndex("PackageId", "Created") + .HasDatabaseName("IX_PackageHistory_PackageId_Created"); + + b.ToTable("PackageHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", 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("DiscountProductId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastRestockedAt") + .HasColumnType("datetime2"); + + b.Property("LastSoldAt") + .HasColumnType("datetime2"); + + b.Property("LowStockThreshold") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(10); + + b.Property("MaxStockLevel") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1000); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Quantity") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("ReorderPoint") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(5); + + b.Property("ReservedQuantity") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("WarehouseId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(1L); + + b.HasKey("Id"); + + b.HasIndex("DiscountProductId") + .HasDatabaseName("IX_InventoryItems_DiscountProductId"); + + b.HasIndex("ProductId") + .HasDatabaseName("IX_InventoryItems_ProductId"); + + b.HasIndex("WarehouseId") + .HasDatabaseName("IX_InventoryItems_WarehouseId"); + + b.HasIndex("ProductType", "Quantity") + .HasDatabaseName("IX_InventoryItems_ProductType_Quantity"); + + b.ToTable("InventoryItems", "CMS", t => + { + t.HasCheckConstraint("CK_InventoryItem_ProductReference", "(ProductId IS NOT NULL AND DiscountProductId IS NULL) OR (ProductId IS NULL AND DiscountProductId IS NOT NULL)"); + + t.HasCheckConstraint("CK_InventoryItem_ProductType_Match", "(ProductType = 1 AND ProductId IS NOT NULL) OR (ProductType = 2 AND DiscountProductId IS NOT NULL)"); + + t.HasCheckConstraint("CK_InventoryItem_Quantity_NonNegative", "Quantity >= 0"); + + t.HasCheckConstraint("CK_InventoryItem_ReservedQuantity_LessOrEqualQuantity", "ReservedQuantity <= Quantity"); + + t.HasCheckConstraint("CK_InventoryItem_ReservedQuantity_NonNegative", "ReservedQuantity >= 0"); + }); + }); + + 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("FlushedPerSide") + .HasColumnType("int"); + + 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("PackageId") + .HasColumnType("bigint"); + + 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("SubordinateBalances") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalFlushed") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekDefinitionId") + .HasColumnType("bigint"); + + b.Property("WeeklyPoolContribution") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsExpired") + .HasDatabaseName("IX_NetworkWeeklyBalance_IsExpired"); + + b.HasIndex("PackageId"); + + b.HasIndex("WeekDefinitionId") + .HasDatabaseName("IX_NetworkWeeklyBalance_WeekDefinitionId"); + + b.HasIndex("UserId", "WeekDefinitionId", "PackageId") + .IsUnique() + .HasDatabaseName("IX_NetworkWeeklyBalance_User_WeekDef_Package"); + + 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("ActivationFee") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountMultiplier") + .ValueGeneratedOnAdd() + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)") + .HasDefaultValue(2.0m); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsBasePackage") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("MagicWalletMaxCredit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(2500000000L); + + b.Property("MagicWalletMaxDeposit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(1000000000L); + + b.Property("MagicWalletMultiplier") + .ValueGeneratedOnAdd() + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)") + .HasDefaultValue(2.5m); + + b.Property("MaxBalancesPerLeg") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(300); + + b.Property("MaxNetworkLevel") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(15); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("SupportsDayaPurchase") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("SupportsDirectPurchase") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_Package_IsActive"); + + b.HasIndex("SortOrder") + .HasDatabaseName("IX_Package_SortOrder"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PackageFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncluded") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ClubFeatureId"); + + b.HasIndex("PackageId", "ClubFeatureId") + .IsUnique() + .HasDatabaseName("IX_PackageFeature_PackageId_ClubFeatureId"); + + b.ToTable("PackageFeatures", "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("ImageDocumentId") + .HasColumnType("bigint"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + 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.Payment.PaymentTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Authority") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CallbackUrl") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CardHash") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CardPan") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("GatewayProvider") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("MerchantId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Mobile") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("OrderId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("PaymentStatus") + .HasColumnType("bit"); + + b.Property("RefId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RequestStatusCode") + .HasColumnType("int"); + + b.Property("RequestStatusMessage") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("VerificationStatusCode") + .HasColumnType("int"); + + b.Property("VerificationStatusMessage") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("Authority"); + + b.HasIndex("GatewayProvider"); + + b.HasIndex("RefId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("PaymentTransactions", "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.PublicMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ArchivedAt") + .HasColumnType("datetime2"); + + 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("EndDate") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsArchived") + .HasColumnType("bit"); + + 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("PublishedAt") + .HasColumnType("datetime2"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + 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.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.StockMovement", 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("DiscountOrderId") + .HasColumnType("bigint"); + + b.Property("InventoryItemId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("MovementType") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PerformedByUserId") + .HasColumnType("bigint"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("QuantityAfter") + .HasColumnType("int"); + + b.Property("QuantityBefore") + .HasColumnType("int"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("Created") + .HasDatabaseName("IX_StockMovements_Created"); + + b.HasIndex("DiscountOrderId") + .HasDatabaseName("IX_StockMovements_DiscountOrderId") + .HasFilter("[DiscountOrderId] IS NOT NULL"); + + b.HasIndex("InventoryItemId") + .HasDatabaseName("IX_StockMovements_InventoryItemId"); + + b.HasIndex("MovementType") + .HasDatabaseName("IX_StockMovements_MovementType"); + + b.HasIndex("OrderId") + .HasDatabaseName("IX_StockMovements_OrderId") + .HasFilter("[OrderId] IS NOT NULL"); + + b.HasIndex("ReferenceNumber") + .HasDatabaseName("IX_StockMovements_ReferenceNumber") + .HasFilter("[ReferenceNumber] IS NOT NULL"); + + b.HasIndex("InventoryItemId", "MovementType", "Created") + .HasDatabaseName("IX_StockMovements_Item_Type_Date"); + + b.ToTable("StockMovements", "CMS", t => + { + t.HasCheckConstraint("CK_StockMovement_QuantityAfter_Calculation", "QuantityAfter = QuantityBefore + Quantity"); + + t.HasCheckConstraint("CK_StockMovement_QuantityAfter_NonNegative", "QuantityAfter >= 0"); + + t.HasCheckConstraint("CK_StockMovement_QuantityBefore_NonNegative", "QuantityBefore >= 0"); + }); + }); + + 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("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("MagicActivatedAt") + .HasColumnType("datetime2"); + + b.Property("MagicCompletedAt") + .HasColumnType("datetime2"); + + b.Property("MagicTotalCredited") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L); + + b.Property("MagicTotalDeposited") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WalletMode") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletHistory", 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("PackageId") + .HasColumnType("bigint"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Warehouse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDefault") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique() + .HasDatabaseName("IX_Warehouses_Code_Unique"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_Warehouses_IsActive"); + + b.HasIndex("IsDefault") + .HasDatabaseName("IX_Warehouses_IsDefault") + .HasFilter("[IsDefault] = 1"); + + b.ToTable("Warehouses", "CMS"); + + b.HasData( + new + { + Id = 1L, + Address = "تهران - انبار مرکزی فروشگاه", + Code = "WH-001", + Created = new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + CreatedBy = "System", + IsActive = true, + IsDefault = true, + IsDeleted = false, + Name = "انبار اصلی" + }); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.WeekDefinition", 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("DisplayName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("GregorianWeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("GregorianYear") + .HasColumnType("int"); + + 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("PersianWeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PersianYear") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("WeekOrder") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("GregorianWeekNumber") + .IsUnique() + .HasDatabaseName("IX_WeekDefinition_GregorianWeekNumber"); + + b.HasIndex("GregorianYear") + .HasDatabaseName("IX_WeekDefinition_GregorianYear"); + + b.HasIndex("PersianWeekNumber") + .HasDatabaseName("IX_WeekDefinition_PersianWeekNumber"); + + b.HasIndex("PersianYear") + .HasDatabaseName("IX_WeekDefinition_PersianYear"); + + b.HasIndex("StartDate") + .HasDatabaseName("IX_WeekDefinition_StartDate"); + + b.ToTable("WeekDefinitions", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPostCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Blog.BlogCategory", "BlogCategory") + .WithMany("BlogPostCategories") + .HasForeignKey("BlogCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Blog.BlogPost", "BlogPost") + .WithMany("BlogPostCategories") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BlogCategory"); + + b.Navigation("BlogPost"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPostImage", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Blog.BlogPost", "BlogPost") + .WithMany("BlogPostImages") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BlogPost"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPostTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Blog.BlogPost", "BlogPost") + .WithMany("BlogPostTags") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BlogPost"); + + b.Navigation("Tag"); + }); + + 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.Package", "FirstPackage") + .WithMany() + .HasForeignKey("FirstPackageId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "LastPackage") + .WithMany() + .HasForeignKey("LastPackageId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithOne("ClubMembership") + .HasForeignKey("CMSMicroservice.Domain.Entities.Club.ClubMembership", "UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("FirstPackage"); + + b.Navigation("LastPackage"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembershipCycle", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership") + .WithMany("Cycles") + .HasForeignKey("ClubMembershipId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ClubMembership"); + + b.Navigation("Package"); + + 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.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("CommissionPayouts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("UserCommissionPayouts") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", "WeeklyPool") + .WithMany("UserCommissionPayouts") + .HasForeignKey("WeeklyPoolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("User"); + + b.Navigation("WeekDefinition"); + + b.Navigation("WeeklyPool"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("WeeklyCommissionPools") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WorkerExecutionLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("WorkerExecutionLogs") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Content.SitePageImage", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Content.SitePageSettings", "SitePageSettings") + .WithMany("Images") + .HasForeignKey("SitePageSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SitePageSettings"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Content.SitePageSection", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Content.SitePage", "SitePage") + .WithMany("Sections") + .HasForeignKey("SitePageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SitePage"); + }); + + 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.DiscountProductImage", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "DiscountProduct") + .WithMany("Images") + .HasForeignKey("DiscountProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DiscountProduct"); + }); + + 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.Geography.City", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Geography.State", "State") + .WithMany("Cities") + .HasForeignKey("StateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("State"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.State", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Geography.Country", "Country") + .WithMany("States") + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Country"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipCycleHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembershipCycle", "ClubMembershipCycle") + .WithMany("CycleHistories") + .HasForeignKey("ClubMembershipCycleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ClubMembershipCycle"); + }); + + 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.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("CommissionPayoutHistories") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("UserCommissionPayout"); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.PackageHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("PackageHistories") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "DiscountProduct") + .WithMany() + .HasForeignKey("DiscountProductId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("CMSMicroservice.Domain.Entities.Warehouse", "Warehouse") + .WithMany("InventoryItems") + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DiscountProduct"); + + b.Navigation("Product"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("NetworkWeeklyBalances") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("NetworkWeeklyBalances") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("User"); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Order.OrderVAT", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithOne("OrderVAT") + .HasForeignKey("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PackageFeature", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubFeature", "ClubFeature") + .WithMany() + .HasForeignKey("ClubFeatureId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("PackageFeatures") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClubFeature"); + + b.Navigation("Package"); + }); + + 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.StockMovement", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.InventoryItem", "InventoryItem") + .WithMany("StockMovements") + .HasForeignKey("InventoryItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InventoryItem"); + }); + + 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.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("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("Purchases") + .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.UserWalletHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletHistories") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogCategory", b => + { + b.Navigation("BlogPostCategories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Blog.BlogPost", b => + { + b.Navigation("BlogPostCategories"); + + b.Navigation("BlogPostImages"); + + b.Navigation("BlogPostTags"); + }); + + 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("Cycles"); + + b.Navigation("UserClubFeatures"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembershipCycle", b => + { + b.Navigation("CycleHistories"); + }); + + 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.Content.SitePage", b => + { + b.Navigation("Sections"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Content.SitePageSettings", b => + { + b.Navigation("Images"); + }); + + 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("Images"); + + b.Navigation("OrderDetails"); + + b.Navigation("ProductCategories"); + + b.Navigation("ShoppingCarts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.Country", b => + { + b.Navigation("States"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.State", b => + { + b.Navigation("Cities"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", b => + { + b.Navigation("StockMovements"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("PackageFeatures"); + + b.Navigation("PackageHistories"); + + b.Navigation("Purchases"); + + 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"); + + b.Navigation("OrderVAT"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletHistories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Warehouse", b => + { + b.Navigation("InventoryItems"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.WeekDefinition", b => + { + b.Navigation("CommissionPayoutHistories"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserCommissionPayouts"); + + b.Navigation("WeeklyCommissionPools"); + + b.Navigation("WorkerExecutionLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.cs new file mode 100644 index 0000000..c4498c2 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20260227024734_Q27_HistoryTables_And_RenameWalletHistory.cs @@ -0,0 +1,190 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class Q27_HistoryTables_And_RenameWalletHistory : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameTable( + name: "UserWalletChangeLogs", + schema: "CMS", + newName: "UserWalletHistories", + newSchema: "CMS"); + + migrationBuilder.RenameIndex( + name: "IX_UserWalletChangeLogs_PackageId", + schema: "CMS", + table: "UserWalletHistories", + newName: "IX_UserWalletHistories_PackageId"); + + migrationBuilder.RenameIndex( + name: "IX_UserWalletChangeLogs_WalletId", + schema: "CMS", + table: "UserWalletHistories", + newName: "IX_UserWalletHistories_WalletId"); + + migrationBuilder.Sql( + "EXEC sp_rename N'CMS.PK_UserWalletChangeLogs', N'PK_UserWalletHistories', N'OBJECT'"); + + migrationBuilder.Sql( + "EXEC sp_rename N'CMS.FK_UserWalletChangeLogs_Packages_PackageId', N'FK_UserWalletHistories_Packages_PackageId', N'OBJECT'"); + + migrationBuilder.Sql( + "EXEC sp_rename N'CMS.FK_UserWalletChangeLogs_UserWallets_WalletId', N'FK_UserWalletHistories_UserWallets_WalletId', N'OBJECT'"); + + migrationBuilder.CreateTable( + name: "ClubMembershipCycleHistories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClubMembershipCycleId = table.Column(type: "bigint", nullable: false), + UserId = table.Column(type: "bigint", nullable: false), + CycleNumber = table.Column(type: "int", nullable: false), + OldIsCurrentCycle = table.Column(type: "bit", nullable: false), + NewIsCurrentCycle = table.Column(type: "bit", nullable: false), + OldMagicStartedAt = table.Column(type: "datetime2", nullable: true), + NewMagicStartedAt = table.Column(type: "datetime2", nullable: true), + OldMagicCompletedAt = table.Column(type: "datetime2", nullable: true), + NewMagicCompletedAt = table.Column(type: "datetime2", nullable: true), + Action = table.Column(type: "int", nullable: false), + PerformedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Reason = 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_ClubMembershipCycleHistories", x => x.Id); + table.ForeignKey( + name: "FK_ClubMembershipCycleHistories_ClubMembershipCycles_ClubMembershipCycleId", + column: x => x.ClubMembershipCycleId, + principalSchema: "CMS", + principalTable: "ClubMembershipCycles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "PackageHistories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PackageId = table.Column(type: "bigint", nullable: false), + OldPrice = table.Column(type: "bigint", nullable: true), + NewPrice = table.Column(type: "bigint", nullable: true), + OldActivationFee = table.Column(type: "bigint", nullable: true), + NewActivationFee = table.Column(type: "bigint", nullable: true), + OldMagicMultiplier = table.Column(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true), + NewMagicMultiplier = table.Column(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true), + OldMagicMaxDeposit = table.Column(type: "bigint", nullable: true), + NewMagicMaxDeposit = table.Column(type: "bigint", nullable: true), + OldMaxBalancesPerLeg = table.Column(type: "int", nullable: true), + NewMaxBalancesPerLeg = table.Column(type: "int", nullable: true), + OldIsActive = table.Column(type: "bit", nullable: true), + NewIsActive = table.Column(type: "bit", nullable: true), + Action = table.Column(type: "int", nullable: false), + PerformedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Reason = 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_PackageHistories", x => x.Id); + table.ForeignKey( + name: "FK_PackageHistories_Packages_PackageId", + column: x => x.PackageId, + principalSchema: "CMS", + principalTable: "Packages", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembershipCycleHistory_Action", + schema: "CMS", + table: "ClubMembershipCycleHistories", + column: "Action"); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembershipCycleHistory_CycleId", + schema: "CMS", + table: "ClubMembershipCycleHistories", + column: "ClubMembershipCycleId"); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembershipCycleHistory_UserId_Created", + schema: "CMS", + table: "ClubMembershipCycleHistories", + columns: new[] { "UserId", "Created" }); + + migrationBuilder.CreateIndex( + name: "IX_PackageHistory_Action", + schema: "CMS", + table: "PackageHistories", + column: "Action"); + + migrationBuilder.CreateIndex( + name: "IX_PackageHistory_PackageId_Created", + schema: "CMS", + table: "PackageHistories", + columns: new[] { "PackageId", "Created" }); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ClubMembershipCycleHistories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "PackageHistories", + schema: "CMS"); + + migrationBuilder.RenameTable( + name: "UserWalletHistories", + schema: "CMS", + newName: "UserWalletChangeLogs", + newSchema: "CMS"); + + migrationBuilder.RenameIndex( + name: "IX_UserWalletHistories_PackageId", + schema: "CMS", + table: "UserWalletChangeLogs", + newName: "IX_UserWalletChangeLogs_PackageId"); + + migrationBuilder.RenameIndex( + name: "IX_UserWalletHistories_WalletId", + schema: "CMS", + table: "UserWalletChangeLogs", + newName: "IX_UserWalletChangeLogs_WalletId"); + + migrationBuilder.Sql( + "EXEC sp_rename N'CMS.PK_UserWalletHistories', N'PK_UserWalletChangeLogs', N'OBJECT'"); + + migrationBuilder.Sql( + "EXEC sp_rename N'CMS.FK_UserWalletHistories_Packages_PackageId', N'FK_UserWalletChangeLogs_Packages_PackageId', N'OBJECT'"); + + migrationBuilder.Sql( + "EXEC sp_rename N'CMS.FK_UserWalletHistories_UserWallets_WalletId', N'FK_UserWalletChangeLogs_UserWallets_WalletId', N'OBJECT'"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index 2c65473..20a6ee8 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1935,6 +1935,81 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("States", "GMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipCycleHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipCycleId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CycleNumber") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewIsCurrentCycle") + .HasColumnType("bit"); + + b.Property("NewMagicCompletedAt") + .HasColumnType("datetime2"); + + b.Property("NewMagicStartedAt") + .HasColumnType("datetime2"); + + b.Property("OldIsCurrentCycle") + .HasColumnType("bit"); + + b.Property("OldMagicCompletedAt") + .HasColumnType("datetime2"); + + b.Property("OldMagicStartedAt") + .HasColumnType("datetime2"); + + 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_ClubMembershipCycleHistory_Action"); + + b.HasIndex("ClubMembershipCycleId") + .HasDatabaseName("IX_ClubMembershipCycleHistory_CycleId"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_ClubMembershipCycleHistory_UserId_Created"); + + b.ToTable("ClubMembershipCycleHistories", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => { b.Property("Id") @@ -2133,6 +2208,92 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("NetworkMembershipHistories", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.PackageHistory", 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("NewActivationFee") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("NewMagicMaxDeposit") + .HasColumnType("bigint"); + + b.Property("NewMagicMultiplier") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("NewMaxBalancesPerLeg") + .HasColumnType("int"); + + b.Property("NewPrice") + .HasColumnType("bigint"); + + b.Property("OldActivationFee") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("OldMagicMaxDeposit") + .HasColumnType("bigint"); + + b.Property("OldMagicMultiplier") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("OldMaxBalancesPerLeg") + .HasColumnType("int"); + + b.Property("OldPrice") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_PackageHistory_Action"); + + b.HasIndex("PackageId", "Created") + .HasDatabaseName("IX_PackageHistory_PackageId_Created"); + + b.ToTable("PackageHistories", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", b => { b.Property("Id") @@ -3826,7 +3987,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("UserWallets", "CMS"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletHistory", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -3885,7 +4046,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasIndex("WalletId"); - b.ToTable("UserWalletChangeLogs", "CMS"); + b.ToTable("UserWalletHistories", "CMS"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.Warehouse", b => @@ -4430,6 +4591,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Country"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipCycleHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembershipCycle", "ClubMembershipCycle") + .WithMany("CycleHistories") + .HasForeignKey("ClubMembershipCycleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ClubMembershipCycle"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => { b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership") @@ -4460,6 +4632,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("WeekDefinition"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.PackageHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("PackageHistories") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Package"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", b => { b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "DiscountProduct") @@ -4781,7 +4964,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("User"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletHistory", b => { b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") .WithMany() @@ -4789,7 +4972,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations .OnDelete(DeleteBehavior.Restrict); b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") - .WithMany("UserWalletChangeLogs") + .WithMany("UserWalletHistories") .HasForeignKey("WalletId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -4834,6 +5017,11 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("UserClubFeatures"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembershipCycle", b => + { + b.Navigation("CycleHistories"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b => { b.Navigation("CommissionPayoutHistories"); @@ -4901,6 +5089,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations { b.Navigation("PackageFeatures"); + b.Navigation("PackageHistories"); + b.Navigation("Purchases"); b.Navigation("UserOrders"); @@ -4984,7 +5174,7 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => { - b.Navigation("UserWalletChangeLogs"); + b.Navigation("UserWalletHistories"); }); modelBuilder.Entity("CMSMicroservice.Domain.Entities.Warehouse", b => diff --git a/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs b/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs index 48a7378..b6c4010 100644 --- a/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs +++ b/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs @@ -471,7 +471,7 @@ public class OrmCommissionCalculationStrategy : ICommissionCalculationStrategy .ToDictionaryAsync(w => w.UserId, cancellationToken); var newWallets = new List(); - var walletLogs = new List(); + var walletLogs = new List(); foreach (var payout in payouts) { @@ -510,7 +510,7 @@ public class OrmCommissionCalculationStrategy : ICommissionCalculationStrategy var wallet = existingWallets[payout.UserId]; wallet.NetworkBalance += payout.TotalAmount; - var walletLog = new UserWalletChangeLog + var walletLog = new UserWalletHistory { WalletId = wallet.Id, CurrentBalance = wallet.Balance, @@ -526,7 +526,7 @@ public class OrmCommissionCalculationStrategy : ICommissionCalculationStrategy walletLogs.Add(walletLog); } - await _context.UserWalletChangeLogs.AddRangeAsync(walletLogs, cancellationToken); + await _context.UserWalletHistories.AddRangeAsync(walletLogs, cancellationToken); await _context.SaveChangesAsync(cancellationToken); } @@ -534,7 +534,7 @@ public class OrmCommissionCalculationStrategy : ICommissionCalculationStrategy List oldPayoutIds, CancellationToken cancellationToken) { - var oldWalletLogs = await _context.UserWalletChangeLogs + var oldWalletLogs = await _context.UserWalletHistories .Where(l => l.RefrenceId.HasValue && oldPayoutIds.Contains(l.RefrenceId.Value)) .ToListAsync(cancellationToken); @@ -557,7 +557,7 @@ public class OrmCommissionCalculationStrategy : ICommissionCalculationStrategy } } - _context.UserWalletChangeLogs.RemoveRange(oldWalletLogs); + _context.UserWalletHistories.RemoveRange(oldWalletLogs); await _context.SaveChangesAsync(cancellationToken); } diff --git a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj index d87bd05..672fe4f 100644 --- a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj +++ b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/CMSMicroservice.Protobuf/Protos/userwallet.proto b/src/CMSMicroservice.Protobuf/Protos/userwallet.proto index bd7ff2c..096f3ea 100644 --- a/src/CMSMicroservice.Protobuf/Protos/userwallet.proto +++ b/src/CMSMicroservice.Protobuf/Protos/userwallet.proto @@ -51,9 +51,9 @@ service UserWalletContract get: "/Customer/GetWallet" }; }; - rpc GetCustomerWalletChangeLog(GetCustomerWalletChangeLogRequest) returns (GetCustomerWalletChangeLogResponse){ + rpc GetCustomerWalletHistory(GetCustomerWalletHistoryRequest) returns (GetCustomerWalletHistoryResponse){ option (google.api.http) = { - post: "/Customer/GetWalletChangeLog" + post: "/Customer/GetWalletHistory" body: "*" }; }; @@ -167,19 +167,19 @@ message GetCustomerWalletResponse int32 wallet_mode = 4; // 0=Normal, 1=Magic } -message GetCustomerWalletChangeLogRequest +message GetCustomerWalletHistoryRequest { google.protobuf.Int64Value reference_id = 1; google.protobuf.BoolValue is_increase = 2; } -message GetCustomerWalletChangeLogResponse +message GetCustomerWalletHistoryResponse { messages.MetaData meta_data = 1; - repeated CustomerWalletChangeLogModel models = 2; + repeated CustomerWalletHistoryModel models = 2; } -message CustomerWalletChangeLogModel +message CustomerWalletHistoryModel { int64 current_balance = 1; int64 change_value = 2; diff --git a/src/CMSMicroservice.Protobuf/Protos/userwalletchangelog.proto b/src/CMSMicroservice.Protobuf/Protos/userwallethistory.proto similarity index 61% rename from src/CMSMicroservice.Protobuf/Protos/userwalletchangelog.proto rename to src/CMSMicroservice.Protobuf/Protos/userwallethistory.proto index 7749f46..010841f 100644 --- a/src/CMSMicroservice.Protobuf/Protos/userwalletchangelog.proto +++ b/src/CMSMicroservice.Protobuf/Protos/userwallethistory.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package userwalletchangelog; +package userwallethistory; import "public_messages.proto"; import "google/protobuf/empty.proto"; @@ -9,42 +9,42 @@ import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto"; -option csharp_namespace = "CMSMicroservice.Protobuf.Protos.UserWalletChangeLog"; +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.UserWalletHistory"; -service UserWalletChangeLogContract +service UserWalletHistoryContract { - rpc CreateNewUserWalletChangeLog(CreateNewUserWalletChangeLogRequest) returns (CreateNewUserWalletChangeLogResponse){ + rpc CreateNewUserWalletHistory(CreateNewUserWalletHistoryRequest) returns (CreateNewUserWalletHistoryResponse){ option (google.api.http) = { - post: "/CreateNewUserWalletChangeLog" + post: "/CreateNewUserWalletHistory" body: "*" }; }; - rpc UpdateUserWalletChangeLog(UpdateUserWalletChangeLogRequest) returns (google.protobuf.Empty){ + rpc UpdateUserWalletHistory(UpdateUserWalletHistoryRequest) returns (google.protobuf.Empty){ option (google.api.http) = { - put: "/UpdateUserWalletChangeLog" + put: "/UpdateUserWalletHistory" body: "*" }; }; - rpc DeleteUserWalletChangeLog(DeleteUserWalletChangeLogRequest) returns (google.protobuf.Empty){ + rpc DeleteUserWalletHistory(DeleteUserWalletHistoryRequest) returns (google.protobuf.Empty){ option (google.api.http) = { - delete: "/DeleteUserWalletChangeLog" + delete: "/DeleteUserWalletHistory" body: "*" }; }; - rpc GetUserWalletChangeLog(GetUserWalletChangeLogRequest) returns (GetUserWalletChangeLogResponse){ + rpc GetUserWalletHistory(GetUserWalletHistoryRequest) returns (GetUserWalletHistoryResponse){ option (google.api.http) = { - get: "/GetUserWalletChangeLog" + get: "/GetUserWalletHistory" }; }; - rpc GetAllUserWalletChangeLogByFilter(GetAllUserWalletChangeLogByFilterRequest) returns (GetAllUserWalletChangeLogByFilterResponse){ + rpc GetAllUserWalletHistoryByFilter(GetAllUserWalletHistoryByFilterRequest) returns (GetAllUserWalletHistoryByFilterResponse){ option (google.api.http) = { - get: "/GetAllUserWalletChangeLogByFilter" + get: "/GetAllUserWalletHistoryByFilter" }; }; } -message CreateNewUserWalletChangeLogRequest +message CreateNewUserWalletHistoryRequest { int64 wallet_id = 1; int64 current_balance = 2; @@ -54,11 +54,11 @@ message CreateNewUserWalletChangeLogRequest bool is_increase = 6; google.protobuf.Int64Value refrence_id = 7; } -message CreateNewUserWalletChangeLogResponse +message CreateNewUserWalletHistoryResponse { int64 id = 1; } -message UpdateUserWalletChangeLogRequest +message UpdateUserWalletHistoryRequest { int64 id = 1; int64 wallet_id = 2; @@ -69,15 +69,15 @@ message UpdateUserWalletChangeLogRequest bool is_increase = 7; google.protobuf.Int64Value refrence_id = 8; } -message DeleteUserWalletChangeLogRequest +message DeleteUserWalletHistoryRequest { int64 id = 1; } -message GetUserWalletChangeLogRequest +message GetUserWalletHistoryRequest { int64 id = 1; } -message GetUserWalletChangeLogResponse +message GetUserWalletHistoryResponse { int64 id = 1; int64 wallet_id = 2; @@ -89,13 +89,13 @@ message GetUserWalletChangeLogResponse google.protobuf.Int64Value refrence_id = 8; google.protobuf.Timestamp created_at = 9; } -message GetAllUserWalletChangeLogByFilterRequest +message GetAllUserWalletHistoryByFilterRequest { messages.PaginationState pagination_state = 1; google.protobuf.StringValue sort_by = 2; - GetAllUserWalletChangeLogByFilterFilter filter = 3; + GetAllUserWalletHistoryByFilterFilter filter = 3; } -message GetAllUserWalletChangeLogByFilterFilter +message GetAllUserWalletHistoryByFilterFilter { google.protobuf.Int64Value id = 1; google.protobuf.Int64Value wallet_id = 2; @@ -105,12 +105,12 @@ message GetAllUserWalletChangeLogByFilterFilter google.protobuf.Int64Value refrence_id = 6; google.protobuf.Int64Value user_id = 7; } -message GetAllUserWalletChangeLogByFilterResponse +message GetAllUserWalletHistoryByFilterResponse { messages.MetaData meta_data = 1; - repeated GetAllUserWalletChangeLogByFilterResponseModel models = 2; + repeated GetAllUserWalletHistoryByFilterResponseModel models = 2; } -message GetAllUserWalletChangeLogByFilterResponseModel +message GetAllUserWalletHistoryByFilterResponseModel { int64 id = 1; int64 wallet_id = 2; diff --git a/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/DeleteUserWalletChangeLogRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/DeleteUserWalletChangeLogRequestValidator.cs deleted file mode 100644 index 1f7f8e0..0000000 --- a/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/DeleteUserWalletChangeLogRequestValidator.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentValidation; -using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; -namespace CMSMicroservice.Protobuf.Validator.UserWalletChangeLog; - -public class DeleteUserWalletChangeLogRequestValidator : AbstractValidator -{ - public DeleteUserWalletChangeLogRequestValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteUserWalletChangeLogRequest)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/UserWalletChangeLog/GetAllUserWalletChangeLogByFilterRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/GetAllUserWalletChangeLogByFilterRequestValidator.cs deleted file mode 100644 index 5c4305f..0000000 --- a/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/GetAllUserWalletChangeLogByFilterRequestValidator.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentValidation; -using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; -namespace CMSMicroservice.Protobuf.Validator.UserWalletChangeLog; - -public class GetAllUserWalletChangeLogByFilterRequestValidator : AbstractValidator -{ - public GetAllUserWalletChangeLogByFilterRequestValidator() - { - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllUserWalletChangeLogByFilterRequest)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/UserWalletChangeLog/CreateNewUserWalletChangeLogRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/CreateNewUserWalletHistoryRequestValidator.cs similarity index 64% rename from src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/CreateNewUserWalletChangeLogRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/CreateNewUserWalletHistoryRequestValidator.cs index e3535ba..f8364c4 100644 --- a/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/CreateNewUserWalletChangeLogRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/CreateNewUserWalletHistoryRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; -namespace CMSMicroservice.Protobuf.Validator.UserWalletChangeLog; +using CMSMicroservice.Protobuf.Protos.UserWalletHistory; +namespace CMSMicroservice.Protobuf.Validator.UserWalletHistory; -public class CreateNewUserWalletChangeLogRequestValidator : AbstractValidator +public class CreateNewUserWalletHistoryRequestValidator : AbstractValidator { - public CreateNewUserWalletChangeLogRequestValidator() + public CreateNewUserWalletHistoryRequestValidator() { RuleFor(model => model.WalletId) .NotNull(); @@ -21,7 +21,7 @@ public class CreateNewUserWalletChangeLogRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserWalletChangeLogRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserWalletHistoryRequest)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/UserWalletHistory/DeleteUserWalletHistoryRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/DeleteUserWalletHistoryRequestValidator.cs new file mode 100644 index 0000000..d73bce3 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/DeleteUserWalletHistoryRequestValidator.cs @@ -0,0 +1,19 @@ +using FluentValidation; +using CMSMicroservice.Protobuf.Protos.UserWalletHistory; +namespace CMSMicroservice.Protobuf.Validator.UserWalletHistory; + +public class DeleteUserWalletHistoryRequestValidator : AbstractValidator +{ + public DeleteUserWalletHistoryRequestValidator() + { + RuleFor(model => model.Id) + .NotNull(); + } + public Func>> ValidateValue => async (model, propertyName) => + { + var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteUserWalletHistoryRequest)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/UserWalletHistory/GetAllUserWalletHistoryByFilterRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/GetAllUserWalletHistoryByFilterRequestValidator.cs new file mode 100644 index 0000000..a79cd62 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/GetAllUserWalletHistoryByFilterRequestValidator.cs @@ -0,0 +1,17 @@ +using FluentValidation; +using CMSMicroservice.Protobuf.Protos.UserWalletHistory; +namespace CMSMicroservice.Protobuf.Validator.UserWalletHistory; + +public class GetAllUserWalletHistoryByFilterRequestValidator : AbstractValidator +{ + public GetAllUserWalletHistoryByFilterRequestValidator() + { + } + public Func>> ValidateValue => async (model, propertyName) => + { + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllUserWalletHistoryByFilterRequest)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/UserWalletChangeLog/GetUserWalletChangeLogRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/GetUserWalletHistoryRequestValidator.cs similarity index 50% rename from src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/GetUserWalletChangeLogRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/GetUserWalletHistoryRequestValidator.cs index 5b9e205..11894c7 100644 --- a/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/GetUserWalletChangeLogRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/GetUserWalletHistoryRequestValidator.cs @@ -1,17 +1,17 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; -namespace CMSMicroservice.Protobuf.Validator.UserWalletChangeLog; +using CMSMicroservice.Protobuf.Protos.UserWalletHistory; +namespace CMSMicroservice.Protobuf.Validator.UserWalletHistory; -public class GetUserWalletChangeLogRequestValidator : AbstractValidator +public class GetUserWalletHistoryRequestValidator : AbstractValidator { - public GetUserWalletChangeLogRequestValidator() + public GetUserWalletHistoryRequestValidator() { RuleFor(model => model.Id) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetUserWalletChangeLogRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetUserWalletHistoryRequest)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/UserWalletChangeLog/UpdateUserWalletChangeLogRequestValidator.cs b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/UpdateUserWalletHistoryRequestValidator.cs similarity index 66% rename from src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/UpdateUserWalletChangeLogRequestValidator.cs rename to src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/UpdateUserWalletHistoryRequestValidator.cs index 004b2e5..11020bf 100644 --- a/src/CMSMicroservice.Protobuf/Validator/UserWalletChangeLog/UpdateUserWalletChangeLogRequestValidator.cs +++ b/src/CMSMicroservice.Protobuf/Validator/UserWalletHistory/UpdateUserWalletHistoryRequestValidator.cs @@ -1,10 +1,10 @@ using FluentValidation; -using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; -namespace CMSMicroservice.Protobuf.Validator.UserWalletChangeLog; +using CMSMicroservice.Protobuf.Protos.UserWalletHistory; +namespace CMSMicroservice.Protobuf.Validator.UserWalletHistory; -public class UpdateUserWalletChangeLogRequestValidator : AbstractValidator +public class UpdateUserWalletHistoryRequestValidator : AbstractValidator { - public UpdateUserWalletChangeLogRequestValidator() + public UpdateUserWalletHistoryRequestValidator() { RuleFor(model => model.Id) .NotNull(); @@ -23,7 +23,7 @@ public class UpdateUserWalletChangeLogRequestValidator : AbstractValidator>> ValidateValue => async (model, propertyName) => { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateUserWalletChangeLogRequest)model, x => x.IncludeProperties(propertyName))); + var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateUserWalletHistoryRequest)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/UserWalletChangeLogProfile.cs b/src/CMSMicroservice.WebApi/Common/Mappings/UserWalletHistoryProfile.cs similarity index 83% rename from src/CMSMicroservice.WebApi/Common/Mappings/UserWalletChangeLogProfile.cs rename to src/CMSMicroservice.WebApi/Common/Mappings/UserWalletHistoryProfile.cs index ad2c16d..b91a7ee 100644 --- a/src/CMSMicroservice.WebApi/Common/Mappings/UserWalletChangeLogProfile.cs +++ b/src/CMSMicroservice.WebApi/Common/Mappings/UserWalletHistoryProfile.cs @@ -1,6 +1,6 @@ namespace CMSMicroservice.WebApi.Common.Mappings; -public class UserWalletChangeLogProfile : IRegister +public class UserWalletHistoryProfile : IRegister { void IRegister.Register(TypeAdapterConfig config) { diff --git a/src/CMSMicroservice.WebApi/Program.cs b/src/CMSMicroservice.WebApi/Program.cs index c674c6f..55f800b 100644 --- a/src/CMSMicroservice.WebApi/Program.cs +++ b/src/CMSMicroservice.WebApi/Program.cs @@ -281,7 +281,7 @@ static bool IsCustomerService(string serviceName) "User", "UserAddress", "Commission", "NetworkMembership", "ClubMembership", "UserOrder", "UserWallet", "UserCarts", "DiscountShoppingCart", "City", "Package", "Transactions", - "UserContract", "UserWalletChangeLog" + "UserContract", "UserWalletHistory" }; return customerServices.Any(customer => serviceName.Contains(customer, StringComparison.OrdinalIgnoreCase)) && diff --git a/src/CMSMicroservice.WebApi/Services/PackageService.cs b/src/CMSMicroservice.WebApi/Services/PackageService.cs index 2effbe3..0942b26 100644 --- a/src/CMSMicroservice.WebApi/Services/PackageService.cs +++ b/src/CMSMicroservice.WebApi/Services/PackageService.cs @@ -321,7 +321,7 @@ public class PackageService : PackageContract.PackageContractBase wallet.DiscountBalance += discountAmount; // ثبت لاگ کیف پول - var walletLog = new CMSMicroservice.Domain.Entities.UserWalletChangeLog + var walletLog = new CMSMicroservice.Domain.Entities.UserWalletHistory { WalletId = wallet.Id, CurrentBalance = wallet.Balance, @@ -333,7 +333,7 @@ public class PackageService : PackageContract.PackageContractBase IsIncrease = true, RefrenceId = transaction.Id }; - _context.UserWalletChangeLogs.Add(walletLog); + _context.UserWalletHistories.Add(walletLog); // به‌روزرسانی کاربر var user = await _context.Users diff --git a/src/CMSMicroservice.WebApi/Services/UserOrderService.cs b/src/CMSMicroservice.WebApi/Services/UserOrderService.cs index 2c87922..38681c7 100644 --- a/src/CMSMicroservice.WebApi/Services/UserOrderService.cs +++ b/src/CMSMicroservice.WebApi/Services/UserOrderService.cs @@ -322,7 +322,7 @@ public class UserOrderService : UserOrderContract.UserOrderContractBase wallet.Balance -= totalAmount; // Create wallet change log - var walletLog = new UserWalletChangeLog + var walletLog = new UserWalletHistory { WalletId = wallet.Id, CurrentBalance = wallet.Balance, @@ -335,7 +335,7 @@ public class UserOrderService : UserOrderContract.UserOrderContractBase RefrenceId = transaction.Id }; - _context.UserWalletChangeLogs.Add(walletLog); + _context.UserWalletHistories.Add(walletLog); // ═══ Magic Wallet: Entry / Exit Trigger ═══ // Q24: آستانه <= 1,000,000 ریال به جای == 0 (چون قیمت محصولات متفاوت است) @@ -833,7 +833,7 @@ public class UserOrderService : UserOrderContract.UserOrderContractBase if (wallet != null) { wallet.Balance += refundAmount; - _context.UserWalletChangeLogs.Add(new UserWalletChangeLog + _context.UserWalletHistories.Add(new UserWalletHistory { WalletId = wallet.Id, CurrentBalance = wallet.Balance, diff --git a/src/CMSMicroservice.WebApi/Services/UserWalletChangeLogService.cs b/src/CMSMicroservice.WebApi/Services/UserWalletChangeLogService.cs deleted file mode 100644 index 91b230b..0000000 --- a/src/CMSMicroservice.WebApi/Services/UserWalletChangeLogService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; -using CMSMicroservice.WebApi.Common.Services; -using CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.CreateNewUserWalletChangeLog; -using CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.UpdateUserWalletChangeLog; -using CMSMicroservice.Application.UserWalletChangeLogCQ.Commands.DeleteUserWalletChangeLog; -using CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetUserWalletChangeLog; -using CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetAllUserWalletChangeLogByFilter; -namespace CMSMicroservice.WebApi.Services; -public class UserWalletChangeLogService : UserWalletChangeLogContract.UserWalletChangeLogContractBase -{ - private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; - - public UserWalletChangeLogService(IDispatchRequestToCQRS dispatchRequestToCQRS) - { - _dispatchRequestToCQRS = dispatchRequestToCQRS; - } - public override async Task CreateNewUserWalletChangeLog(CreateNewUserWalletChangeLogRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task UpdateUserWalletChangeLog(UpdateUserWalletChangeLogRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task DeleteUserWalletChangeLog(DeleteUserWalletChangeLogRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetUserWalletChangeLog(GetUserWalletChangeLogRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetAllUserWalletChangeLogByFilter(GetAllUserWalletChangeLogByFilterRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } -} diff --git a/src/CMSMicroservice.WebApi/Services/UserWalletHistoryService.cs b/src/CMSMicroservice.WebApi/Services/UserWalletHistoryService.cs new file mode 100644 index 0000000..99c8917 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/UserWalletHistoryService.cs @@ -0,0 +1,37 @@ +using CMSMicroservice.Protobuf.Protos.UserWalletHistory; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.UserWalletHistoryCQ.Commands.CreateNewUserWalletHistory; +using CMSMicroservice.Application.UserWalletHistoryCQ.Commands.UpdateUserWalletHistory; +using CMSMicroservice.Application.UserWalletHistoryCQ.Commands.DeleteUserWalletHistory; +using CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory; +using CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetAllUserWalletHistoryByFilter; +namespace CMSMicroservice.WebApi.Services; +public class UserWalletHistoryService : UserWalletHistoryContract.UserWalletHistoryContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public UserWalletHistoryService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + public override async Task CreateNewUserWalletHistory(CreateNewUserWalletHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task UpdateUserWalletHistory(UpdateUserWalletHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task DeleteUserWalletHistory(DeleteUserWalletHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetUserWalletHistory(GetUserWalletHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + public override async Task GetAllUserWalletHistoryByFilter(GetAllUserWalletHistoryByFilterRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/UserWalletService.cs b/src/CMSMicroservice.WebApi/Services/UserWalletService.cs index 5c8fc70..8ce2b1e 100644 --- a/src/CMSMicroservice.WebApi/Services/UserWalletService.cs +++ b/src/CMSMicroservice.WebApi/Services/UserWalletService.cs @@ -7,7 +7,7 @@ using CMSMicroservice.Application.WalletCQ.Commands.ChargeMagicWallet; using CMSMicroservice.Application.WalletCQ.Commands.ChargeDiscountWallet; using CMSMicroservice.Application.UserWalletCQ.Queries.GetUserWallet; using CMSMicroservice.Application.UserWalletCQ.Queries.GetAllUserWalletByFilter; -using CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletChangeLog; +using CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletHistory; using CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWithdrawals; using CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWithdrawalSettings; using CMSMicroservice.Application.Common.Interfaces; @@ -102,9 +102,9 @@ public class UserWalletService : UserWalletContract.UserWalletContractBase }; } - public override async Task GetCustomerWalletChangeLog(GetCustomerWalletChangeLogRequest request, ServerCallContext context) + public override async Task GetCustomerWalletHistory(GetCustomerWalletHistoryRequest request, ServerCallContext context) { - var query = new GetCustomerWalletChangeLogQuery + var query = new GetCustomerWalletHistoryQuery { ReferenceId = request.ReferenceId, IsIncrease = request.IsIncrease @@ -112,7 +112,7 @@ public class UserWalletService : UserWalletContract.UserWalletContractBase var changeLogs = await _sender.Send(query, context.CancellationToken); - var response = new GetCustomerWalletChangeLogResponse + var response = new GetCustomerWalletHistoryResponse { MetaData = new CMSMicroservice.Protobuf.Protos.MetaData { @@ -127,7 +127,7 @@ public class UserWalletService : UserWalletContract.UserWalletContractBase foreach (var log in changeLogs) { - response.Models.Add(new CustomerWalletChangeLogModel + response.Models.Add(new CustomerWalletHistoryModel { CurrentBalance = log.CurrentBalance, ChangeValue = log.ChangeValue,