コード例 #1
0
        public ActionResult UpdateOrderShippingMethod(VendrUpdateOrderShippingMethodDto model)
        {
            try
            {
                using (var uow = _vendrApi.Uow.Create())
                {
                    var checkoutPage = CurrentPage.GetCheckoutPage();
                    var store        = CurrentPage.GetStore();
                    var order        = _vendrApi.GetCurrentOrder(store.Id)
                                       .AsWritable(uow)
                                       .SetShippingMethod(model.ShippingMethod);

                    _vendrApi.SaveOrder(order);

                    uow.Complete();
                }
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError("", "Failed to update shipping method: " + ex.Message);

                return(IsAjaxRequest()
                    ? (ActionResult)Json(new { success = false, errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage) })
                    : CurrentUmbracoPage());
            }

            return(IsAjaxRequest()
                ? (ActionResult)Json(new { success = true })
                : model.NextStep.HasValue
                    ? RedirectToUmbracoPage(model.NextStep.Value)
                    : RedirectToCurrentUmbracoPage());
        }
コード例 #2
0
        public ActionResult UpdateOrderShippingMethod(VendrUpdateOrderShippingMethodDto model)
        {
            try
            {
                using (var uow = _vendrApi.Uow.Create())
                {
                    var checkoutPage = CurrentPage.GetCheckoutPage();
                    var store        = CurrentPage.GetStore();
                    var order        = _vendrApi.GetCurrentOrder(store.Id)
                                       .AsWritable(uow)
                                       .SetShippingMethod(model.ShippingMethod);

                    _vendrApi.SaveOrder(order);

                    uow.Complete();
                }
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError("", "Failed to update shipping method: " + ex.Message);

                return(CurrentUmbracoPage());
            }

            if (model.NextStep.HasValue)
            {
                return(RedirectToUmbracoPage(model.NextStep.Value));
            }

            return(RedirectToCurrentUmbracoPage());
        }