public ActionResult CreateEdit(long Id = 0) { NccPage page = new NccPage(); page.PublishDate = DateTime.Now; page.PageStatus = NccPageStatus.Draft; NccPageDetails nccPageDetails = new NccPageDetails(); nccPageDetails.Language = GlobalContext.WebSite.Language; page.PageDetails.Add(nccPageDetails); if (Id > 0) { page = _pageService.Get(Id); } if (GlobalContext.WebSite.IsMultiLangual) { foreach (var item in SupportedCultures.Cultures) { var count = page.PageDetails.Where(x => x.Language == item.TwoLetterISOLanguageName).Count(); if (count <= 0) { NccPageDetails _nccPageDetails = new NccPageDetails(); _nccPageDetails.Language = item.TwoLetterISOLanguageName; page.PageDetails.Add(_nccPageDetails); } } } SetPageViewData(page); return(View(page)); }
public override object PrepareViewModel(params object[] paramiters) { var id = paramiters[0].ToString().Trim(); var model = _nccPageService.Get(long.Parse(id)); return(model); }
public ActionResult CreateEdit(long Id = 0) { ViewBag.DomainName = (Request.IsHttps == true ? "https://" : "http://") + Request.Host + "/CmsPage/"; ViewBag.Layouts = GlobalConfig.ActiveTheme.Layouts; ViewBag.AllPages = _pageService.LoadAll().Where(p => p.Status == (int)NccPage.NccPageStatus.Published && p.Id != Id); NccPage page = new NccPage(); page.Content = ""; page.PublishDate = DateTime.Now; page.PageStatus = NccPage.NccPageStatus.Draft; if (Id > 0) { page = _pageService.Get(Id); } return(View(page)); }
public string Render(params object[] paramiters) { var content = ""; try { var id = paramiters[0].ToString().Trim(); var slider = _nccPageService.Get(long.Parse(id)); if (slider != null) { content = _viewRenderService.RenderToStringAsync <CmsHomeController>(ViewFileName, slider).Result; } } catch (Exception ex) { } return(content); }
public ActionResult Startup(StartupViewModel vmodel) { try { var setupConfig = SetupHelper.LoadSetup(); setupConfig.StartupType = vmodel.StartupType; if (vmodel.StartupType == StartupTypeText.Url) { setupConfig.StartupData = vmodel.Url; setupConfig.StartupUrl = vmodel.Url; } else if (vmodel.StartupType == StartupTypeText.Page) { setupConfig.StartupData = vmodel.PageId; var page = _pageService.Get(long.Parse(vmodel.PageId)); if (page == null) { ShowMessage("Page not found.", MessageType.Error); } var pageDetails = page.PageDetails.Where(x => x.Language == GlobalContext.WebSite.Language).FirstOrDefault(); if (pageDetails == null) { ShowMessage("Page for default language not found.", MessageType.Error); } else { setupConfig.StartupUrl = "/" + pageDetails.Slug; } } else if (vmodel.StartupType == StartupTypeText.Post) { setupConfig.StartupData = vmodel.PostId; var post = _postService.Get(long.Parse(vmodel.PostId)); if (post == null) { ShowMessage("Post not found.", MessageType.Error); } var postDetails = post.PostDetails.Where(x => x.Language == GlobalContext.WebSite.Language).FirstOrDefault(); if (postDetails == null) { ShowMessage("Post for default language not found.", MessageType.Error); } else { setupConfig.StartupUrl = "/Post/" + postDetails.Slug; } } else if (vmodel.StartupType == StartupTypeText.Category) { setupConfig.StartupData = vmodel.CategoryId; var category = _categoryService.Get(long.Parse(vmodel.CategoryId)); if (category == null) { ShowMessage("Category not found.", MessageType.Error); } var categoryDetails = category.CategoryDetails.Where(x => x.Language == GlobalContext.WebSite.Language).FirstOrDefault(); if (categoryDetails == null) { ShowMessage("Category for default language not found.", MessageType.Error); } else { setupConfig.StartupUrl = "/Category/" + categoryDetails.Slug; } } else if (vmodel.StartupType == StartupTypeText.Module) { setupConfig.StartupData = vmodel.ModuleSiteMenuUrl; setupConfig.StartupUrl = vmodel.ModuleSiteMenuUrl; } else { setupConfig.StartupType = StartupTypeText.Url; setupConfig.StartupData = "/CmsHome"; setupConfig.StartupUrl = "/CmsHome"; } if (setupConfig.StartupData.Trim('/') == "" || setupConfig.StartupData.Trim().Trim('/').ToLower() == "home") { ShowMessage("Incorrect value", MessageType.Error); return(View(vmodel)); } SetupHelper.UpdateSetup(setupConfig); GlobalContext.SetupConfig = setupConfig; } catch (Exception ex) { return(View(vmodel)); } ShowMessage("Config save successful.", MessageType.Success); var model = PrepareStartupViewData(); return(View(model)); }