From d03fbe0a9844a34a73a8d7767734e5052eb5b7fe Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Sun, 4 Jan 2026 23:51:35 +0330 Subject: [PATCH] fix: Remove RemainingCount property from CreateDiscountProduct and related commands, initializing inventory with zero --- .../CreateDiscountProduct/CreateDiscountProductCommand.cs | 1 - .../CreateDiscountProductCommandHandler.cs | 6 +++--- .../CreateDiscountProductCommandValidator.cs | 3 --- .../Commands/CreateNewProducts/CreateNewProductsCommand.cs | 2 -- .../CreateNewProducts/CreateNewProductsCommandHandler.cs | 4 ++-- .../CreateNewProducts/CreateNewProductsCommandValidator.cs | 2 -- .../Commands/UpdateProducts/UpdateProductsCommand.cs | 2 -- .../UpdateProducts/UpdateProductsCommandValidator.cs | 2 -- 8 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommand.cs index 9549145..a75ef52 100644 --- a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommand.cs +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommand.cs @@ -11,6 +11,5 @@ public class CreateDiscountProductCommand : IRequest public int MaxDiscountPercent { get; set; } public string ImagePath { get; set; } public string ThumbnailPath { get; set; } - public int RemainingCount { get; set; } public List CategoryIds { get; set; } = new(); } diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandHandler.cs index 7e9885a..27ee7f8 100644 --- a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandHandler.cs +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/CreateDiscountProduct/CreateDiscountProductCommandHandler.cs @@ -30,7 +30,7 @@ public class CreateDiscountProductCommandHandler : IRequestHandler v.MaxDiscountPercent) .InclusiveBetween(0, 100).WithMessage("درصد تخفیف باید بین 0 تا 100 باشد"); - RuleFor(v => v.RemainingCount) - .GreaterThanOrEqualTo(0).WithMessage("موجودی نمی‌تواند منفی باشد"); - RuleFor(v => v.ImagePath) .NotEmpty().WithMessage("تصویر محصول الزامی است"); diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommand.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommand.cs index 4f7ec10..c482d00 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommand.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommand.cs @@ -23,8 +23,6 @@ public record CreateNewProductsCommand : IRequest public int SaleCount { get; init; } // public int ViewCount { get; init; } - // - public int RemainingCount { get; init; } // لیست شناسه دسته‌بندی‌های محصول public ICollection? CategoryIds { get; init; } diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs index e4d778d..0251a82 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommandHandler.cs @@ -25,11 +25,11 @@ public class CreateNewProductsCommandHandler : IRequestHandler model.ViewCount) .NotNull(); - RuleFor(model => model.RemainingCount) - .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommand.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommand.cs index a562980..25f4698 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommand.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommand.cs @@ -25,8 +25,6 @@ public record UpdateProductsCommand : IRequest public int SaleCount { get; init; } // public int ViewCount { get; init; } - // - public int RemainingCount { get; init; } // لیست شناسه دسته‌بندی‌های محصول public ICollection? CategoryIds { get; init; } diff --git a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandValidator.cs b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandValidator.cs index ef07175..390c24b 100644 --- a/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandValidator.cs +++ b/src/CMSMicroservice.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommandValidator.cs @@ -27,8 +27,6 @@ public class UpdateProductsCommandValidator : AbstractValidator model.ViewCount) .NotNull(); - RuleFor(model => model.RemainingCount) - .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => {