Пример #1
0
        public JsonResult AddCartLine(AddCartLineInputModel inputModel)
        {
            try
            {
                Assert.ArgumentNotNull(inputModel, "inputModel");

                var validationResult = new BaseJsonResult();
                this.ValidateModel(validationResult);
                if (validationResult.HasErrors)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                var response = this.CartManager.AddLineItemsToCart(CurrentStorefront, CurrentVisitorContext, new List <AddCartLineInputModel> {
                    inputModel
                });
                var result = new BaseJsonResult(response.ServiceProviderResult);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                CommerceLog.Current.Error("AddCartLine", this);
                return(Json(new BaseJsonResult("AddCartLine", e), JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public BaseJsonResult AddCartLine(AddCartLineInputModel inputModel)
        {
            var response = _cartManager.AddLineItemsToCart(
                CurrentStorefront,
                CurrentVisitorContext,
                new List <AddCartLineInputModel> {
                inputModel
            });
            var result = new BaseJsonResult(response.ServiceProviderResult);

            return(result);
        }
        public JsonResult AddCartLine(AddCartLineInputModel inputModel)
        {
            try
            {
                Assert.ArgumentNotNull(inputModel, nameof(inputModel));

                var validationResult = this.CreateJsonResult();
                if (validationResult.HasErrors)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                var response = CartManager.AddLineItemsToCart(CommerceUserContext.Current.UserId, new List <AddCartLineInputModel> {
                    inputModel
                });
                var result = new BaseApiModel(response.ServiceProviderResult);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new ErrorApiModel("AddCartLine", e), JsonRequestBehavior.AllowGet));
            }
        }
Пример #4
0
        public JsonResult AddCartLine(AddCartLineInputModel inputModel)
        {
            try
            {
                Assert.ArgumentNotNull(inputModel, "inputModel");
                var validationResult = new BaseJsonResult();
                this.ValidateModel(validationResult);

                if (validationResult.HasErrors)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                var result = _cartRepository.AddCartLine(inputModel);

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                _logger.LogError("AddCartLine", this);
                return(Json(new BaseJsonResult("AddCartLine", e), JsonRequestBehavior.AllowGet));
            }
        }