コード例 #1
0
        public ActionResult Edit(DeliveryTimeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDeliveryTimes))
            {
                return(AccessDeniedView());
            }

            var deliveryTime = _deliveryTimeService.GetDeliveryTimeById(model.Id);

            if (deliveryTime == null)
            {
                //No currency found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                deliveryTime = model.ToEntity(deliveryTime);

                UpdateLocales(deliveryTime, model);
                _deliveryTimeService.UpdateDeliveryTime(deliveryTime);

                NotifySuccess(_localizationService.GetResource("Admin.Configuration.DeliveryTimes.Updated"));
                return(continueEditing ? RedirectToAction("Edit", new { id = deliveryTime.Id }) : RedirectToAction("List"));
            }

            return(View(model));
        }
コード例 #2
0
 public void UpdateLocales(DeliveryTime deliveryTime, DeliveryTimeModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(deliveryTime, x => x.Name, localized.Name, localized.LanguageId);
     }
 }
コード例 #3
0
        public ActionResult CreateDeliveryTimePopup(string btnId, DeliveryTimeModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = model.ToEntity();

                    _deliveryTimeService.InsertDeliveryTime(entity);

                    UpdateLocales(entity, model);

                    NotifySuccess(T("Admin.Configuration.DeliveryTime.Added"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(model));
                }

                ViewBag.RefreshPage = true;
                ViewBag.btnId       = btnId;
            }

            return(View(model));
        }
コード例 #4
0
        public ActionResult Edit(DeliveryTimeModel model, bool continueEditing)
        {
            if (!Services.Permissions.Authorize(StandardPermissionProvider.ManageDeliveryTimes))
            {
                return(AccessDeniedView());
            }

            var deliveryTime = _deliveryTimeService.GetDeliveryTimeById(model.Id);

            if (deliveryTime == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                deliveryTime = model.ToEntity(deliveryTime);

                // if this is the default delivery time set all other delivery times to non default
                if (model.IsDefault)
                {
                    _deliveryTimeService.SetToDefault(deliveryTime);
                }

                UpdateLocales(deliveryTime, model);
                _deliveryTimeService.UpdateDeliveryTime(deliveryTime);

                NotifySuccess(T("Admin.Configuration.DeliveryTimes.Updated"));
                return(continueEditing ? RedirectToAction("Edit", new { id = deliveryTime.Id }) : RedirectToAction("List"));
            }

            return(View(model));
        }
コード例 #5
0
        public ActionResult CreateDeliveryTimePopup()
        {
            var model = new DeliveryTimeModel();

            AddLocales(_languageService, model.Locales);

            return(View(model));
        }
コード例 #6
0
 public void UpdateLocales(DeliveryTime deliveryTime, DeliveryTimeModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(deliveryTime,
                                                        x => x.Name,
                                                        localized.Name,
                                                        localized.LanguageId);
     }
 }
コード例 #7
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDeliveryTimes))
                return AccessDeniedView();

            var model = new DeliveryTimeModel();
            //locales
            AddLocales(_languageService, model.Locales);

            return View(model);
        }
コード例 #8
0
        public ActionResult Create()
        {
            if (!Services.Permissions.Authorize(StandardPermissionProvider.ManageDeliveryTimes))
            {
                return(AccessDeniedView());
            }

            var model = new DeliveryTimeModel();

            AddLocales(_languageService, model.Locales);

            return(View(model));
        }
コード例 #9
0
        public ActionResult Create(DeliveryTimeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDeliveryTimes))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var deliveryTime = model.ToEntity();

                _deliveryTimeService.InsertDeliveryTime(deliveryTime);
                //locales
                UpdateLocales(deliveryTime, model);

                NotifySuccess(_localizationService.GetResource("Admin.Configuration.DeliveryTime.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = deliveryTime.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #10
0
        public ActionResult EditDeliveryTimePopup(string btnId, DeliveryTimeModel model)
        {
            var entity = _deliveryTimeService.GetDeliveryTimeById(model.Id);

            if (entity == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    entity = model.ToEntity(entity);

                    // If this is the default delivery time set all other delivery times to non default.
                    if (model.IsDefault)
                    {
                        _deliveryTimeService.SetToDefault(entity);
                    }

                    _deliveryTimeService.UpdateDeliveryTime(entity);
                    UpdateLocales(entity, model);

                    NotifySuccess(T("Admin.Configuration.DeliveryTimes.Updated"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(model));
                }

                ViewBag.RefreshPage = true;
                ViewBag.btnId       = btnId;
            }

            return(View(model));
        }
コード例 #11
0
 public static DeliveryTime ToEntity(this DeliveryTimeModel model, DeliveryTime destination)
 {
     return(Mapper.Map(model, destination));
 }
コード例 #12
0
 public static DeliveryTime ToEntity(this DeliveryTimeModel model)
 {
     return(Mapper.Map <DeliveryTimeModel, DeliveryTime>(model));
 }
コード例 #13
0
 public static DeliveryTime ToEntity(this DeliveryTimeModel model, DeliveryTime entity)
 {
     MapperFactory.Map(model, entity);
     return(entity);
 }
コード例 #14
0
        public ActionResult Create(DeliveryTimeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDeliveryTimes))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var deliveryTime = model.ToEntity();

                _deliveryTimeService.InsertDeliveryTime(deliveryTime);
                //locales
                UpdateLocales(deliveryTime, model);

                NotifySuccess(_localizationService.GetResource("Admin.Configuration.DeliveryTime.Added"));
                return continueEditing ? RedirectToAction("Edit", new { id = deliveryTime.Id }) : RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
コード例 #15
0
        public ActionResult Edit(DeliveryTimeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDeliveryTimes))
                return AccessDeniedView();

            var deliveryTime = _deliveryTimeService.GetDeliveryTimeById(model.Id);
            if (deliveryTime == null)
                //No currency found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                deliveryTime = model.ToEntity(deliveryTime);

                UpdateLocales(deliveryTime, model);
                _deliveryTimeService.UpdateDeliveryTime(deliveryTime);

                NotifySuccess(_localizationService.GetResource("Admin.Configuration.DeliveryTimes.Updated"));
                return continueEditing ? RedirectToAction("Edit", new { id = deliveryTime.Id }) : RedirectToAction("List");
            }

            return View(model);
        }
コード例 #16
0
 public static DeliveryTime ToEntity(this DeliveryTimeModel model)
 {
     return(AutoMapperConfiguration.Mapper.Map <DeliveryTimeModel, DeliveryTime>(model));
 }