public async Task <ActionResult> AddCouponJson(string couponCode) { await _cartBuilder.GetOrCreateNewTransientCartAsync(WorkContext.CurrentStore, WorkContext.CurrentCustomer, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency); await _cartBuilder.AddCouponAsync(couponCode); await _cartBuilder.SaveAsync(); return(Json(_cartBuilder.Cart.Coupon, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> AddCouponJson(string couponCode) { EnsureThatCartExist(); //Need lock to prevent concurrent access to same cart using (var lockObject = await AsyncLock.GetLockByKey(GetAsyncLockCartKey(WorkContext.CurrentCart.Id)).LockAsync()) { await _cartBuilder.AddCouponAsync(couponCode); await _cartBuilder.SaveAsync(); } return(Json(_cartBuilder.Cart.Coupon, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> AddCartCoupon(string couponCode) { await EnsureCartExistsAsync(); //Need lock to prevent concurrent access to same cart using (await AsyncLock.GetLockByKey(GetAsyncLockCartKey(WorkContext.CurrentCart)).LockAsync()) { await _cartBuilder.AddCouponAsync(couponCode); await _cartBuilder.SaveAsync(); } return(Json(_cartBuilder.Cart.Coupon)); }