예제 #1
0
        public ActionResult BasicInfo(ShippingMethodEditorModel model)
        {
            var method = model.Id > 0 ? _shippingMethodService.Find(model.Id) : new ShippingMethod();

            method.Name = model.Name;
            method.Description = model.Description;
            method.ShippingRateProviderName = model.ShippingRateProviderName;

            if (model.Id == 0)
            {
                _shippingMethodService.Create(method);
            }

            var shippingRateProvider = _shippingRateProviderFactory.FindByName(method.ShippingRateProviderName);
            string redirectUrl = null;

            var editor = shippingRateProvider as IHasCustomShippingRateProviderConfigEditor;
            if (editor != null || shippingRateProvider.ConfigType != null)
            {
                redirectUrl = Url.Action("ShippingRateProvider", RouteValues.From(Request.QueryString).Merge("id", method.Id));
            }
            else
            {
                redirectUrl = Url.Action("Complete", RouteValues.From(Request.QueryString).Merge("id", method.Id));
            }

            return AjaxForm().RedirectTo(redirectUrl);
        }
예제 #2
0
        public ActionResult BasicInfo(int? id)
        {
            var model = new ShippingMethodEditorModel
            {
                AvailableShippingRateProviders = _shippingRateProviderFactory.All().ToSelectList().ToList()
            };
            if (model.AvailableShippingRateProviders.Count > 0)
            {
                model.ShippingRateProviderName = model.AvailableShippingRateProviders[0].Value;
            }

            if (id != null)
            {
                var method = _shippingMethodService.Find(id.Value);
                model.Id = method.Id;
                model.Name = method.Name;
                model.Description = method.Description;
                model.ShippingRateProviderName = method.ShippingRateProviderName;
            }

            return View(model);
        }