public ActionResult Create()
        {
            var model = new ShippingMethodEditViewModel();
            ViewBag.ShippingZoneId = new SelectList(shippingZoneService.FindAll().ToList(), "Id", "Name");

            return View(model);
        }
        public ActionResult Create()
        {
            var model = new ShippingMethodEditViewModel();

            ViewBag.ShippingZoneId = new SelectList(shippingZoneService.FindAll().ToList(), "Id", "Name");

            return(View(model));
        }
        public ActionResult Edit(ShippingMethodEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                shippingMethodService.AddOrUpdate(model);
                return(RedirectToAction("Index")
                       .WithSuccess(string.Format("The shipping method \"{0}\" has been updated".TA(), model.Name)));
            }

            ViewBag.ShippingZoneId = new SelectList(shippingZoneService.FindAll().ToList(), "Id", "Name");
            return(View(model));
        }
        public ShippingMethod AddOrUpdate(ShippingMethodEditViewModel model)
        {
            ShippingMethod shippingMethod;

            if (model.Id == 0)
            {
                shippingMethod = Mapper.Map<ShippingMethod>(model);
                db.ShippingMethods.Add(shippingMethod);
            }
            else
            {
                shippingMethod = Find(model.Id);
                shippingMethod = Mapper.Map(model, shippingMethod);
            }
            db.SaveChanges();

            return shippingMethod;
        }
        public ShippingMethod AddOrUpdate(ShippingMethodEditViewModel model)
        {
            ShippingMethod shippingMethod;

            if (model.Id == 0)
            {
                shippingMethod = Mapper.Map <ShippingMethod>(model);
                db.ShippingMethods.Add(shippingMethod);
            }
            else
            {
                shippingMethod = Find(model.Id);
                shippingMethod = Mapper.Map(model, shippingMethod);
            }
            db.SaveChanges();

            return(shippingMethod);
        }
        public ActionResult Create(ShippingMethodEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                shippingMethodService.AddOrUpdate(model);

                var action = RedirectToAction("Index");

                if (settingService.Get<bool>(SettingField.ShowShippingRateTutorial))
                {
                    settingService.Set(SettingField.ShowShippingRateTutorial, false);
                    action = RedirectToAction("Welcome", "Home");
                }

                return action.WithSuccess(string.Format("The shipping method \"{0}\" has been added".TA(), model.Name));
            }
            ViewBag.ShippingZoneId = new SelectList(shippingZoneService.FindAll().ToList(), "Id", "Name");
            return View(model);
        }
        public ActionResult Create(ShippingMethodEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                shippingMethodService.AddOrUpdate(model);

                var action = RedirectToAction("Index");

                if (settingService.Get <bool>(SettingField.ShowShippingRateTutorial))
                {
                    settingService.Set(SettingField.ShowShippingRateTutorial, false);
                    action = RedirectToAction("Welcome", "Home");
                }

                return(action.WithSuccess(string.Format("The shipping method \"{0}\" has been added".TA(), model.Name)));
            }
            ViewBag.ShippingZoneId = new SelectList(shippingZoneService.FindAll().ToList(), "Id", "Name");
            return(View(model));
        }
        public ActionResult Edit(ShippingMethodEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                shippingMethodService.AddOrUpdate(model);
                return RedirectToAction("Index")
                    .WithSuccess(string.Format("The shipping method \"{0}\" has been updated".TA(), model.Name));
            }

            ViewBag.ShippingZoneId = new SelectList(shippingZoneService.FindAll().ToList(), "Id", "Name");
            return View(model);
        }