Skip to content

Commit

Permalink
check cart quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
thiennn committed Oct 27, 2021
1 parent 2bbdcde commit 2bce252
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Expand Up @@ -101,6 +101,10 @@ public async Task<IActionResult> List()
[HttpPost("cart/update-item-quantity")]
public async Task<IActionResult> UpdateQuantity([FromBody] CartQuantityUpdate model)
{
if(model.Quantity <= 0)
{
return Ok(new { Error = true, Message = _localizer["The quantity must be larger than zero"].Value });
}
var currentUser = await _workContext.GetCurrentUser();
var cart = await _cartService.GetActiveCart(currentUser.Id);

Expand Down
Expand Up @@ -59,6 +59,10 @@ public async Task<Result> AddToCart(long customerId, long productId, int quantit

public async Task<Result> AddToCart(long customerId, long createdById, long productId, int quantity)
{
if(quantity <= 0)
{
return Result.Fail(_localizer["The quantity must be larger than zero"].Value);
}
var cart = await GetActiveCart(customerId, createdById);
if (cart == null)
{
Expand Down

0 comments on commit 2bce252

Please sign in to comment.