public async Task <ActionResult> CartJson() { EnsureThatCartExist(); await _cartBuilder.EvaluatePromotionsAsync(); await _cartValidator.ValidateAsync(_cartBuilder.Cart); return(Json(_cartBuilder.Cart, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> ValidateCoupon([FromBody] Coupon coupon) { EnsureCartExists(); //Need lock to prevent concurrent access to same cart using (await AsyncLock.GetLockByKey(WorkContext.CurrentCart.Value.GetCacheKey()).LockAsync()) { await _cartBuilder.TakeCartAsync(WorkContext.CurrentCart.Value.Clone() as ShoppingCart); _cartBuilder.Cart.Coupons = new[] { coupon }; await _cartBuilder.EvaluatePromotionsAsync(); return(Ok(coupon)); } }