Exemplo n.º 1
0
        public ActionResult Create(RegionalContentModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageRegionalContents))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var regionalContent = model.ToEntity();
                regionalContent.AddEntitySysParam();
                _regionalContentService.InsertRegionalContent(regionalContent);
                //Sites
                _siteMappingService.SaveSiteMappings <RegionalContent>(regionalContent, model.SelectedSiteIds);
                NotifySuccess(_localizationService.GetResource("Admin.ContentManagement.RegionalContents.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = regionalContent.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);

            //Sites
            PrepareSitesMappingModel(model, null, true);
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Edit(RegionalContentModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageRegionalContents))
            {
                return(AccessDeniedView());
            }

            var regionalContent = _regionalContentService.GetRegionalContentById(model.Id);

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

            if (ModelState.IsValid)
            {
                regionalContent = model.ToEntity(regionalContent);
                regionalContent.AddEntitySysParam(false, true);
                _regionalContentService.UpdateRegionalContent(regionalContent);

                //Sites
                _siteMappingService.SaveSiteMappings <RegionalContent>(regionalContent, model.SelectedSiteIds);
                NotifySuccess(_localizationService.GetResource("Admin.ContentManagement.RegionalContents.Updated"));
                return(continueEditing ? RedirectToAction("Edit", regionalContent.Id) : RedirectToAction("List"));
            }


            //If we got this far, something failed, redisplay form
            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);

            //sites
            PrepareSitesMappingModel(model, regionalContent, true);

            return(View(model));
        }