public ActionResult Edit(StaticContentType contentType)
        {
            CheckIfSiteAdmin();

            var staticContentViewModel = new StaticContentViewModel();
            var staticContent          = _staticContentService.GetStaticContent(contentType);

            staticContentViewModel.Content = staticContent.Content;

            try
            {
                // Format the HTML returned by Telerik control so that indented HTML will be shown in HTML editor.
                staticContentViewModel.Content = XElement.Parse(staticContentViewModel.Content).ToString();
            }
            catch (XmlException)
            {
                try
                {
                    // In case if the HTML doesn't have a root, add a <p> tag as wrapper.
                    staticContentViewModel.Content = XElement.Parse(string.Format(CultureInfo.CurrentCulture, "<p>{0}</p>", staticContentViewModel.Content)).ToString();
                }
                catch (XmlException)
                {
                    // Consume any other Xml exception with parsing and try to load the string as is.
                    // There could be problem like the text is not a valid XML.
                }
            }

            return(View("Save", staticContentViewModel));
        }
Exemplo n.º 2
0
        private StaticContent PrepareStaticContent(int menuId, string virtualId, string title)
        {
            var breadCrumbs = new List <BreadCrumb>();
            var virtualIds  = virtualId.Split('/');

            for (var i = 0; i < virtualIds.Length; i++)
            {
                var vrId     = virtualIds[i];
                var menuLink = _menuLinkService.GetByParentId(menuId, vrId);

                if (menuLink != null)
                {
                    breadCrumbs.Add(new BreadCrumb
                    {
                        Title   = menuLink.GetLocalized(x => x.MenuName, menuLink.Id),
                        Current = false,
                        Url     = Url.Action("GetContent", "Menu", new { area = "", menu = menuLink.SeoUrl })
                    });
                }
            }

            breadCrumbs.Add(new BreadCrumb
            {
                Current = true,
                Title   = title
            });
            ViewBag.BreadCrumb = breadCrumbs;

            var staticContent = _staticContentService.GetStaticContent(menuId);

            if (staticContent != null)
            {
                //var viewCount = staticContent;
                //viewCount.ViewCount = viewCount.ViewCount + 1;
                //_staticContentService.Update(staticContent);

                staticContent = staticContent.ToModel();

                //Lấy bannerId từ post để hiển thị banner trên post
                ViewBag.BannerId = staticContent.MenuId;
                ViewBag.Title    = staticContent.Title;
            }

            ViewBag.MenuId = menuId;

            return(staticContent);
        }