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
@@ -23,8 +23,6 @@ public record CreateNewProductsCommand : IRequest<CreateNewProductsResponseDto>
public int SaleCount { get; init; }
//
public int ViewCount { get; init; }
//
public int RemainingCount { get; init; }
// لیست شناسه دسته‌بندی‌های محصول
public ICollection<long>? CategoryIds { get; init; }
@@ -25,11 +25,11 @@ public class CreateNewProductsCommandHandler : IRequestHandler<CreateNewProducts
await _context.Products.AddAsync(entity, cancellationToken);
await _context.SaveChangesAsync(cancellationToken);
// ایجاد رکورد موجودی در سیستم انبارداری
// ایجاد رکورد موجودی در سیستم انبارداری با موجودی اولیه صفر
await _inventoryService.InitializeInventoryAsync(
entity.Id,
ProductType.RegularProduct,
request.RemainingCount,
0, // موجودی اولیه صفر - باید از طریق Inventory اضافه شود
ct: cancellationToken);
// ثبت دسته‌بندی‌های محصول (در صورت ارسال)
@@ -25,8 +25,6 @@ public class CreateNewProductsCommandValidator : AbstractValidator<CreateNewProd
.NotNull();
RuleFor(model => model.ViewCount)
.NotNull();
RuleFor(model => model.RemainingCount)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
@@ -25,8 +25,6 @@ public record UpdateProductsCommand : IRequest<Unit>
public int SaleCount { get; init; }
//
public int ViewCount { get; init; }
//
public int RemainingCount { get; init; }
// لیست شناسه دسته‌بندی‌های محصول
public ICollection<long>? CategoryIds { get; init; }
@@ -27,8 +27,6 @@ public class UpdateProductsCommandValidator : AbstractValidator<UpdateProductsCo
.NotNull();
RuleFor(model => model.ViewCount)
.NotNull();
RuleFor(model => model.RemainingCount)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{