Beispiel #1
0
        public async Task <ActionResult> NewPageTemplate(string tabId, int parentId)
        {
            var template = _pageTemplateService.NewPageTemplateProperties(parentId);
            var model    = PageTemplateViewModel.Create(template, tabId, parentId, _pageTemplateService);

            return(await JsonHtml("Properties", model));
        }
Beispiel #2
0
        public async Task <ActionResult> PageTemplateProperties(string tabId, int parentId, int id, string successfulActionCode)
        {
            var template = _pageTemplateService.ReadPageTemplateProperties(id);

            ViewData[SpecialKeys.IsEntityReadOnly] = template.LockedByAnyoneElse;
            var model = PageTemplateViewModel.Create(template, tabId, parentId, _pageTemplateService);

            model.SuccesfulActionCode = successfulActionCode;
            return(await JsonHtml("Properties", model));
        }
Beispiel #3
0
        public async Task <ActionResult> PageTemplateProperties(string tabId, int parentId, int id, IFormCollection collection)
        {
            var template = _pageTemplateService.ReadPageTemplatePropertiesForUpdate(id);
            var model    = PageTemplateViewModel.Create(template, tabId, parentId, _pageTemplateService);

            await TryUpdateModelAsync(model);

            if (ModelState.IsValid)
            {
                model.Data = _pageTemplateService.UpdatePageTemplateProperties(model.Data);
                return(Redirect("PageTemplateProperties", new { tabId, parentId, id = model.Data.Id, successfulActionCode = ActionCode.UpdatePageTemplate }));
            }

            return(await JsonHtml("Properties", model));
        }
        public ActionResult NewPageTemplate(string tabId, int parentId, FormCollection collection)
        {
            var template = _pageTemplateService.NewPageTemplatePropertiesForUpdate(parentId);
            var model    = PageTemplateViewModel.Create(template, tabId, parentId, _pageTemplateService);

            TryUpdateModel(model);
            model.Validate(ModelState);
            if (ModelState.IsValid)
            {
                model.Data = _pageTemplateService.SavePageTemplateProperties(model.Data);
                PersistResultId(model.Data.Id);
                return(Redirect("PageTemplateProperties", new { tabId, parentId, id = model.Data.Id, successfulActionCode = ActionCode.SavePageTemplate }));
            }

            return(JsonHtml("Properties", model));
        }
Beispiel #5
0
        public virtual ActionResult Update(long id, PageTemplateViewModel model)
        {
            var pageTemplate = pageService.Find(id);

            if (pageTemplate == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity"));
            }

            if (ModelState.IsValid)
            {
                //UserHelper.Update(user, model);
                Success(Translate("Messages.PageTemplateUpdated"));
                return(RedirectToAction(MVC.Admin.PageTemplate.Index()));
            }

            Error(Translate("Messages.ValidationError"));
            return(View("Edit", model));
        }
Beispiel #6
0
        public virtual ActionResult Create(PageTemplateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var pageTemplate = new Page {
                    IsTemplate = true
                };
                pageTemplate.PageLayout = new PageLayout
                {
                    LayoutTemplate = LayoutHelper.DefaultLayoutTemplate,
                    Page           = pageTemplate
                };

                if (this.CorePrincipal() != null)
                {
                    pageTemplate.User = new User
                    {
                        Id = this.CorePrincipal().PrincipalId
                    };
                }

                pageTemplate = model.MapTo(pageTemplate);

                if (pageService.Save(pageTemplate))
                {
                    permissionService.SetupDefaultRolePermissions(
                        ResourcePermissionsHelper.GetResourceOperations(typeof(PageTemplate)), typeof(PageTemplate), pageTemplate.Id);
                    Success(Translate("Messages.PageTemplateCreated"));

                    return(RedirectToAction(MVC.Admin.PageTemplate.Index()));
                }
            }

            Error(Translate("Messages.ValidationError"));
            return(View("New", model));
        }
        public virtual ActionResult Update(long id, PageTemplateViewModel model)
        {
            var pageTemplate = pageService.Find(id);
            if (pageTemplate == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity"));
            }

            if (ModelState.IsValid)
            {
                //UserHelper.Update(user, model);
                Success(Translate("Messages.PageTemplateUpdated"));
                return RedirectToAction(MVC.Admin.PageTemplate.Index());
            }

            Error(Translate("Messages.ValidationError"));
            return View("Edit", model);
        }
        public virtual ActionResult Create(PageTemplateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var pageTemplate = new Page { IsTemplate = true };
                pageTemplate.PageLayout = new PageLayout
                {
                    LayoutTemplate = LayoutHelper.DefaultLayoutTemplate,
                    Page = pageTemplate
                };

                if (this.CorePrincipal() != null)
                {
                    pageTemplate.User = new User
                                    {
                                        Id = this.CorePrincipal().PrincipalId
                                    };
                }

                pageTemplate = model.MapTo(pageTemplate);

                if (pageService.Save(pageTemplate))
                {
                    permissionService.SetupDefaultRolePermissions(
                        ResourcePermissionsHelper.GetResourceOperations(typeof(PageTemplate)), typeof(PageTemplate), pageTemplate.Id);
                    Success(Translate("Messages.PageTemplateCreated"));

                    return RedirectToAction(MVC.Admin.PageTemplate.Index());
                }
            }

            Error(Translate("Messages.ValidationError"));
            return View("New", model);
        }