public JsonResult GetShippingMethods(GetShippingMethodsInputModel inputModel)
        {
            try
            {
                Assert.ArgumentNotNull(inputModel, "inputModel");

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

                var response = this.ShippingManager.GetShippingMethods(CurrentStorefront, CurrentVisitorContext, inputModel);
                var result   = new ShippingMethodsJsonResult(response.ServiceProviderResult);
                if (response.ServiceProviderResult.Success && response.Result != null)
                {
                    result.Initialize(response.ServiceProviderResult.ShippingMethods, response.ServiceProviderResult.ShippingMethodsPerItem);
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                CommerceLog.Current.Error("GetShippingMethods", this, e);
                return(Json(new BaseJsonResult("GetShippingMethods", e), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 2
0
        public ShippingMethodsBaseJsonResult GetShippingMethods(GetShippingMethodsInputModel inputModel)
        {
            var response = this._shippingManager.GetShippingMethods(CurrentStorefront, CurrentVisitorContext, inputModel);
            var result   = new ShippingMethodsJsonResult(response.ServiceProviderResult);

            if (response.ServiceProviderResult.Success && response.Result != null)
            {
                result.Initialize(response.ServiceProviderResult.ShippingMethods, response.ServiceProviderResult.ShippingMethodsPerItem);
            }

            return(result);
        }