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
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m56s
This commit is contained in:
-1
@@ -11,6 +11,5 @@ public class CreateDiscountProductCommand : IRequest<long>
|
|||||||
public int MaxDiscountPercent { get; set; }
|
public int MaxDiscountPercent { get; set; }
|
||||||
public string ImagePath { get; set; }
|
public string ImagePath { get; set; }
|
||||||
public string ThumbnailPath { get; set; }
|
public string ThumbnailPath { get; set; }
|
||||||
public int RemainingCount { get; set; }
|
|
||||||
public List<long> CategoryIds { get; set; } = new();
|
public List<long> CategoryIds { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -30,7 +30,7 @@ public class CreateDiscountProductCommandHandler : IRequestHandler<CreateDiscoun
|
|||||||
MaxDiscountPercent = request.MaxDiscountPercent,
|
MaxDiscountPercent = request.MaxDiscountPercent,
|
||||||
ImagePath = request.ImagePath,
|
ImagePath = request.ImagePath,
|
||||||
ThumbnailPath = request.ThumbnailPath,
|
ThumbnailPath = request.ThumbnailPath,
|
||||||
RemainingCount = request.RemainingCount,
|
RemainingCount = 0, // موجودی اولیه صفر - باید از طریق Inventory اضافه شود
|
||||||
Rate = 0,
|
Rate = 0,
|
||||||
SaleCount = 0,
|
SaleCount = 0,
|
||||||
ViewCount = 0,
|
ViewCount = 0,
|
||||||
@@ -40,11 +40,11 @@ public class CreateDiscountProductCommandHandler : IRequestHandler<CreateDiscoun
|
|||||||
_context.DiscountProducts.Add(product);
|
_context.DiscountProducts.Add(product);
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
// ایجاد رکورد موجودی در سیستم انبارداری
|
// ایجاد رکورد موجودی در سیستم انبارداری با موجودی اولیه صفر
|
||||||
await _inventoryService.InitializeInventoryAsync(
|
await _inventoryService.InitializeInventoryAsync(
|
||||||
product.Id,
|
product.Id,
|
||||||
ProductType.DiscountProduct,
|
ProductType.DiscountProduct,
|
||||||
request.RemainingCount,
|
0, // موجودی اولیه صفر - باید از طریق Inventory اضافه شود
|
||||||
ct: cancellationToken);
|
ct: cancellationToken);
|
||||||
|
|
||||||
// Add product categories
|
// Add product categories
|
||||||
|
|||||||
-3
@@ -24,9 +24,6 @@ public class CreateDiscountProductCommandValidator : AbstractValidator<CreateDis
|
|||||||
RuleFor(v => v.MaxDiscountPercent)
|
RuleFor(v => v.MaxDiscountPercent)
|
||||||
.InclusiveBetween(0, 100).WithMessage("درصد تخفیف باید بین 0 تا 100 باشد");
|
.InclusiveBetween(0, 100).WithMessage("درصد تخفیف باید بین 0 تا 100 باشد");
|
||||||
|
|
||||||
RuleFor(v => v.RemainingCount)
|
|
||||||
.GreaterThanOrEqualTo(0).WithMessage("موجودی نمیتواند منفی باشد");
|
|
||||||
|
|
||||||
RuleFor(v => v.ImagePath)
|
RuleFor(v => v.ImagePath)
|
||||||
.NotEmpty().WithMessage("تصویر محصول الزامی است");
|
.NotEmpty().WithMessage("تصویر محصول الزامی است");
|
||||||
|
|
||||||
|
|||||||
-2
@@ -23,8 +23,6 @@ public record CreateNewProductsCommand : IRequest<CreateNewProductsResponseDto>
|
|||||||
public int SaleCount { get; init; }
|
public int SaleCount { get; init; }
|
||||||
//
|
//
|
||||||
public int ViewCount { get; init; }
|
public int ViewCount { get; init; }
|
||||||
//
|
|
||||||
public int RemainingCount { get; init; }
|
|
||||||
// لیست شناسه دستهبندیهای محصول
|
// لیست شناسه دستهبندیهای محصول
|
||||||
public ICollection<long>? CategoryIds { get; init; }
|
public ICollection<long>? CategoryIds { get; init; }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -25,11 +25,11 @@ public class CreateNewProductsCommandHandler : IRequestHandler<CreateNewProducts
|
|||||||
await _context.Products.AddAsync(entity, cancellationToken);
|
await _context.Products.AddAsync(entity, cancellationToken);
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
// ایجاد رکورد موجودی در سیستم انبارداری
|
// ایجاد رکورد موجودی در سیستم انبارداری با موجودی اولیه صفر
|
||||||
await _inventoryService.InitializeInventoryAsync(
|
await _inventoryService.InitializeInventoryAsync(
|
||||||
entity.Id,
|
entity.Id,
|
||||||
ProductType.RegularProduct,
|
ProductType.RegularProduct,
|
||||||
request.RemainingCount,
|
0, // موجودی اولیه صفر - باید از طریق Inventory اضافه شود
|
||||||
ct: cancellationToken);
|
ct: cancellationToken);
|
||||||
|
|
||||||
// ثبت دستهبندیهای محصول (در صورت ارسال)
|
// ثبت دستهبندیهای محصول (در صورت ارسال)
|
||||||
|
|||||||
-2
@@ -25,8 +25,6 @@ public class CreateNewProductsCommandValidator : AbstractValidator<CreateNewProd
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.ViewCount)
|
RuleFor(model => model.ViewCount)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.RemainingCount)
|
|
||||||
.NotNull();
|
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
-2
@@ -25,8 +25,6 @@ public record UpdateProductsCommand : IRequest<Unit>
|
|||||||
public int SaleCount { get; init; }
|
public int SaleCount { get; init; }
|
||||||
//
|
//
|
||||||
public int ViewCount { get; init; }
|
public int ViewCount { get; init; }
|
||||||
//
|
|
||||||
public int RemainingCount { get; init; }
|
|
||||||
// لیست شناسه دستهبندیهای محصول
|
// لیست شناسه دستهبندیهای محصول
|
||||||
public ICollection<long>? CategoryIds { get; init; }
|
public ICollection<long>? CategoryIds { get; init; }
|
||||||
|
|
||||||
|
|||||||
-2
@@ -27,8 +27,6 @@ public class UpdateProductsCommandValidator : AbstractValidator<UpdateProductsCo
|
|||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.ViewCount)
|
RuleFor(model => model.ViewCount)
|
||||||
.NotNull();
|
.NotNull();
|
||||||
RuleFor(model => model.RemainingCount)
|
|
||||||
.NotNull();
|
|
||||||
}
|
}
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user