public async Task <ActionResult> Change(int line, int quantity) { await _cartBuilder.GetOrCreateNewTransientCartAsync(WorkContext.CurrentStore, WorkContext.CurrentCustomer, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency); await _cartBuilder.ChangeItemQuantityAsync(line - 1, quantity); await _cartBuilder.SaveAsync(); return(StoreFrontRedirect("~/cart")); }
public async Task <ActionResult> Change(int line, int quantity) { EnsureThatCartExist(); using (await AsyncLock.GetLockByKey(GetAsyncLockCartKey(_workContext.CurrentCart)).LockAsync()) { await _cartBuilder.ChangeItemQuantityAsync(line - 1, quantity); await _cartBuilder.SaveAsync(); } return(StoreFrontRedirect("~/cart")); }
public async Task <ActionResult> ChangeItemJson(string lineItemId, int quantity) { await _cartBuilder.GetOrCreateNewTransientCartAsync(WorkContext.CurrentStore, WorkContext.CurrentCustomer, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency); await _cartBuilder.ChangeItemQuantityAsync(lineItemId, quantity); await _cartBuilder.SaveAsync(); return(Json(null, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> ChangeItemJson(string lineItemId, int quantity) { EnsureThatCartExist(); //Need lock to prevent concurrent access to same cart using (var lockObject = await AsyncLock.GetLockByKey(GetAsyncLockCartKey(WorkContext.CurrentCart.Id)).LockAsync()) { var lineItem = _cartBuilder.Cart.Items.FirstOrDefault(i => i.Id == lineItemId); if (lineItem != null) { await _cartBuilder.ChangeItemQuantityAsync(lineItemId, quantity); await _cartBuilder.SaveAsync(); } } return(Json(null, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> ChangeCartItem(string lineItemId, int quantity) { EnsureThatCartExist(); //Need lock to prevent concurrent access to same cart using (await AsyncLock.GetLockByKey(GetAsyncLockCartKey(WorkContext.CurrentCart)).LockAsync()) { var lineItem = _cartBuilder.Cart.Items.FirstOrDefault(i => i.Id == lineItemId); if (lineItem != null) { await _cartBuilder.ChangeItemQuantityAsync(lineItemId, quantity); await _cartBuilder.SaveAsync(); } } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }