Exemplo n.º 1
0
        public ActionResult Edit()
        {
            StaticHtmlContent htmlContent =
                this._contentItemService.FindContentItemsBySection(CurrentSection).FirstOrDefault()
                ?? new StaticHtmlContent();

            return(View(new ModuleAdminViewModel <StaticHtmlContent>(CurrentNode, CurrentSection, CuyahogaContext, htmlContent)));
        }
Exemplo n.º 2
0
        public ActionResult SaveContent(string categoryids)
        {
            StaticHtmlContent htmlContent =
                this._contentItemService.FindContentItemsBySection(CurrentSection).FirstOrDefault()
                ?? new StaticHtmlContent();

            if (TryUpdateModel(htmlContent, new [] { "Content" }))
            {
                // TODO: handle Categories etc. more generic.
                // Categories
                htmlContent.Categories.Clear();
                if (!String.IsNullOrEmpty(categoryids))
                {
                    foreach (string categoryIdString in categoryids.Split(','))
                    {
                        htmlContent.Categories.Add(this._categoryService.GetCategoryById(Convert.ToInt32(categoryIdString)));
                    }
                }
                if (htmlContent.IsNew)
                {
                    htmlContent.Title   = CurrentSection.Title;
                    htmlContent.Section = CurrentSection;
                }
                try
                {
                    this._contentItemService.Save(htmlContent);
                    Messages.AddFlashMessage(Localizer.GetString("ContentSavedMessage"));
                    return(RedirectToAction("Edit", "ManageContent", GetNodeAndSectionParams()));
                }
                catch (Exception ex)
                {
                    Messages.AddException(ex);
                }
            }
            return(View("Edit", new ModuleAdminViewModel <StaticHtmlContent>(CurrentNode, CurrentSection, CuyahogaContext, htmlContent)));
        }