fix: Remove RemainingCount property from CreateDiscountProduct and related commands, initializing inventory with zero
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m56s

This commit is contained in:
masoodafar-web
2026-01-04 23:51:35 +03:30
parent f9c90bb871
commit d03fbe0a98
8 changed files with 5 additions and 17 deletions
@@ -11,6 +11,5 @@ public class CreateDiscountProductCommand : IRequest<long>
public int MaxDiscountPercent { get; set; }
public string ImagePath { get; set; }
public string ThumbnailPath { get; set; }
public int RemainingCount { get; set; }
public List<long> CategoryIds { get; set; } = new();
}
@@ -30,7 +30,7 @@ public class CreateDiscountProductCommandHandler : IRequestHandler<CreateDiscoun
MaxDiscountPercent = request.MaxDiscountPercent,
ImagePath = request.ImagePath,
ThumbnailPath = request.ThumbnailPath,
RemainingCount = request.RemainingCount,
RemainingCount = 0, // موجودی اولیه صفر - باید از طریق Inventory اضافه شود
Rate = 0,
SaleCount = 0,
ViewCount = 0,
@@ -40,11 +40,11 @@ public class CreateDiscountProductCommandHandler : IRequestHandler<CreateDiscoun
_context.DiscountProducts.Add(product);
await _context.SaveChangesAsync(cancellationToken);
// ایجاد رکورد موجودی در سیستم انبارداری
// ایجاد رکورد موجودی در سیستم انبارداری با موجودی اولیه صفر
await _inventoryService.InitializeInventoryAsync(
product.Id,
ProductType.DiscountProduct,
request.RemainingCount,
0, // موجودی اولیه صفر - باید از طریق Inventory اضافه شود
ct: cancellationToken);
// Add product categories
@@ -24,9 +24,6 @@ public class CreateDiscountProductCommandValidator : AbstractValidator<CreateDis
RuleFor(v => v.MaxDiscountPercent)
.InclusiveBetween(0, 100).WithMessage("درصد تخفیف باید بین 0 تا 100 باشد");
RuleFor(v => v.RemainingCount)
.GreaterThanOrEqualTo(0).WithMessage("موجودی نمی‌تواند منفی باشد");
RuleFor(v => v.ImagePath)
.NotEmpty().WithMessage("تصویر محصول الزامی است");