Ejemplo n.º 1
0
        public ActionResult Create(StoreModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageStores))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var store = model.ToEntity();
                //ensure we have "/" at the end
                if (!store.Url.EndsWith("/"))
                    store.Url += "/";
                _storeService.InsertStore(store);
                //locales
                UpdateAttributeLocales(store, model);

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

            //If we got this far, something failed, redisplay form

            //languages
            PrepareLanguagesModel(model);
            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageStores))
                return AccessDeniedView();

            var model = new StoreModel();
            return View(model);
        }
Ejemplo n.º 3
0
 protected virtual void UpdateAttributeLocales(Store store, StoreModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(store,
             x => x.Name,
             localized.Name,
             localized.LanguageId);
     }
 }
Ejemplo n.º 4
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageStores))
                return AccessDeniedView();

            var model = new StoreModel();
            //languages
            PrepareLanguagesModel(model);
            //locales
            AddLocales(_languageService, model.Locales);
            return View(model);
        }
Ejemplo n.º 5
0
 protected virtual void PrepareLanguagesModel(StoreModel model)
 {
     if (model == null)
         throw new ArgumentNullException("model");
     
     model.AvailableLanguages.Add(new SelectListItem
     {
         Text = "---",
         Value = "0"
     });
     var languages = _languageService.GetAllLanguages(true);
     foreach (var language in languages)
     {
         model.AvailableLanguages.Add(new SelectListItem
         {
             Text = language.Name,
             Value = language.Id.ToString()
         });
     }
 }
Ejemplo n.º 6
0
        public ActionResult Edit(StoreModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageStores))
                return AccessDeniedView();

            var store = _storeService.GetStoreById(model.Id);
            if (store == null)
                //No store found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                store = model.ToEntity(store);
                //ensure we have "/" at the end
                if (!store.Url.EndsWith("/"))
                    store.Url += "/";
                _storeService.UpdateStore(store);
                //locales
                UpdateAttributeLocales(store, model);

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

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 7
0
 protected virtual List<LocalizedProperty> UpdateAttributeLocales(Store store, StoreModel model)
 {
     List<LocalizedProperty> localized = new List<LocalizedProperty>();
     foreach (var local in model.Locales)
     {
         localized.Add(new LocalizedProperty()
         {
             LanguageId = local.LanguageId,
             LocaleKey = "Name",
             LocaleValue = local.Name
         });
     }
     return localized;
 }