public ActionResult DetailsView(int webPageId) { _logger.LogInformation(string.Format("WebPage-DetailsView {0}", webPageId)); WebPage entity = _webPageService.GetById(webPageId); if (entity != null) { if (!_webPageService.HasViewRights(entity.Id)) { entity = null; } } var languageId = _workContext.Current; if (entity == null) { entity = _webPageService.GetAll().FirstOrDefault(); } if (entity == null) { return(RedirectToRoute("Install")); } //if (!string.IsNullOrWhiteSpace(entity.Theme)) // _workContext.Current.WebSite.Theme = entity.Theme; //var sections = page.Sections.ToList(); var model = entity.ToModel(_webPageService, _sectionService); // meta's var website = _websiteService.GetAll().First(); //_workContext.Current.WebSite; ////customer attribute services //if (_customAttributeService != null && _customAttributeParser != null) //{ // //PrepareCustomWebPageAttributes(model, entity, _webPageAttributeService, _webPageAttributeParser, overrideAttributesXml); //} //if (addressAttributeFormatter != null && address != null) //{ // model.FormattedCustomAddressAttributes = addressAttributeFormatter.FormatAttributes(address.CustomAttributes); //} ViewBag.MetaTitle = !String.IsNullOrEmpty(entity.MetaTitle) ? entity.MetaTitle + " - " + website.Title : website.Title; ViewBag.MetaDescription = !String.IsNullOrEmpty(entity.MetaDescription) ? entity.MetaDescription : website.MetaDescription; ViewBag.MetaKeywords = !String.IsNullOrEmpty(entity.MetaKeywords) ? entity.MetaKeywords : website.MetaKeywords; return(View(model)); }
public ActionResult DetailsViewByVirtualPath(string virtualPath) { var entity = _webPageService.GetByVirtualPath(virtualPath); if (entity != null) { if (!_webPageService.HasViewRights(entity.Id)) { entity = null; } } if (entity == null) { entity = _webPageService.GetAll().FirstOrDefault(); } if (entity == null) { return(RedirectToRoute("Install")); } //var sections = page.Sections.ToList(); var model = entity.ToFrontEndModel(_webPageService, _sectionService, User, 1, _leService); // Todo: Get language id from user profile ////customer attribute services //if (_customAttributeService != null && _customAttributeParser != null) //{ // //PrepareCustomWebPageAttributes(model, entity, _webPageAttributeService, _webPageAttributeParser, overrideAttributesXml); //} ////if (addressAttributeFormatter != null && address != null) ////{ //// model.FormattedCustomAddressAttributes = addressAttributeFormatter.FormatAttributes(address.CustomAttributes); ////} ////ViewBag.MetaTitle = !String.IsNullOrEmpty(entity.MetaTitle) ? entity.MetaTitle + " - " + website.Title : website.Title; ////ViewBag.MetaDescription = !String.IsNullOrEmpty(entity.MetaDescription) ? entity.MetaDescription : website.MetaDescription; ////ViewBag.MetaKeywords = !String.IsNullOrEmpty(entity.MetaKeywords) ? entity.MetaKeywords : website.MetaKeywords; return(Ok(model)); }
private IList <NavigationModel> GetLinksByParentId(int parentId) { var pages = _webPageService.GetPagesByParentId(parentId); var allPages = _webPageService.GetAll(); List <NavigationModel> list = new List <NavigationModel>(); foreach (var page in pages) { if (_webPageService.HasViewRights(page.Id)) { var item = new NavigationModel(); item.Text = page.NavigationName; item.Value = page.Id.ToString(); item.Url = page.VirtualPath; // item.IconCssClass = page.IconCssClass; item.HasChildren = PageHasChildren(allPages, page.Id); //false; // default item.ChildLinks = GetLinksByParentId(page.Id).ToList(); list.Add(item); } } return(list); }