public ActionResult Edit(string id, string navigationMenuData) { try { if (string.IsNullOrWhiteSpace(navigationMenuData) && !string.IsNullOrWhiteSpace(id)) { ViewBag.NavigationMenu = NavigationMenuDAO.LoadById(id); } else if (string.IsNullOrWhiteSpace(navigationMenuData) && string.IsNullOrWhiteSpace(id)) { ViewBag.NavigationMenu = new NavigationMenu(); } else { ViewBag.NavigationMenu = JsonConvert.DeserializeObject <NavigationMenu>(navigationMenuData); } ViewBag.PageTypeList = PageDAO.LoadPageTypes(); } catch (Exception e) { CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.NavMenuController.Edit() " + e.Message); } return(View()); }
/// <summary> /// Create a new page model. /// </summary> /// <param name="friendlyURL"></param> /// <param name="request"></param> public PageModel(string friendlyURL, HttpRequestBase request) { string id = !string.IsNullOrWhiteSpace(request["id"]) ? request["id"] : string.Empty; AdminUser AdminUser = SiteContext.User; //if a bson id was passed, and the admin user is not null, and they have the page edit role if (!string.IsNullOrWhiteSpace(id) && AdminUser != null && SiteContext.CanAdminUserAccess("page-edit")) { InEditMode = true; Page = PageDAO.LoadByBsonId(id) ?? new Page(); } else { InEditMode = Helpers.AppSettings.InDeveloperEditMode; //only continue if this is a regular page view outside of edit mode if (Page != null && !string.IsNullOrWhiteSpace(Page.Id) && !InEditMode) { ChimeraWebsite.Helpers.SiteContext.RecordPageView(friendlyURL); } Page = ChimeraWebsite.Helpers.AppCache.GetPageFromCache(friendlyURL); } }
public async Task <JsonResult> SavePagina([FromBody] Page page, string token) { if (await Seguranca.validaTokenAsync(token)) { Page pagina = new Page(); if (page.idCliente != 0) { if (PageDAO.Save(page)) { return(Json("Pagina salva com sucesso")); } else { return(Json("Encontramos algum problema ao salvar a pagina. Entre em contato com o suporte")); } } else { return(Json("Encontramos algum problema ao salvar a pagina. Entre em contato com o suporte")); } } else { return(Json("Você nao tem acesso neste plugin")); } }
public void EditPageTest() { var obj = PageDAO.GetAll().Find(x => x.ID == 1); obj.Nome = "Teste3"; obj.Descricao = "Teste3"; obj.Conteudo = "Teste3"; var result = PageDAO.Save(obj); }
public async Task <IEnumerable <Page> > GetPagina(int idcliente, int idpage, string token) { if (await Seguranca.validaTokenAsync(token)) { return(PageDAO.GetAll().Where(x => x.idCliente == idcliente && x.ID == idpage).ToList()); } else { return(new List <Page>()); } }
public ActionResult ViewPageHistory(string pageId) { try { ViewBag.PageRevisionList = PageDAO.LoadRevisionHistory(new Guid(pageId)); } catch (Exception e) { Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PageController.ViewPageHistory()" + e.Message); } return(View()); }
public ActionResult ViewAllPageTypes() { try { ViewBag.PageTypeList = PageDAO.LoadPageTypes(); } catch (Exception e) { Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PageController.ViewAllPageTypes()" + e.Message); } return(View()); }
public ActionResult Edit_Post(string id, string pageTitle, string pageFriendlyURL, string published) { Page Page = new Page(); bool SavedIt = false; try { if (!string.IsNullOrWhiteSpace(id)) { Page = PageDAO.LoadByBsonId(id); } else { Page.CreateDefaultNewPage(); } Page.PageTitle = pageTitle; Page.PageFriendlyURL = pageFriendlyURL; Page.Published = Boolean.Parse(published); Page PageFriendlyURLExists = PageDAO.LoadByURL(Page.PageFriendlyURL); //can only save if another page type does not have the same page friendly url if (PageFriendlyURLExists == null || PageFriendlyURLExists.PageId.Equals(Page.PageId)) { SavedIt = true; AddWebUserMessageToSession(Request, String.Format("Successfully saved/updated page."), SUCCESS_MESSAGE_TYPE); PageDAO.Save(Page); } else { AddWebUserMessageToSession(Request, String.Format("Unable to save page, there is already a page type published with the friendly URL \"{0}\"", Page.PageFriendlyURL), FAILED_MESSAGE_TYPE); } } catch (Exception e) { Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PageController.Edit_Post()" + e.Message); } //if we were trying to add a new page and were unable to save it if (string.IsNullOrWhiteSpace(id) && !SavedIt) { return(RedirectToAction("Dashboard", "Home")); } return(RedirectToAction("ViewPageHistory", "Page", new { pageId = Page.PageId })); }
public async Task <JsonResult> DeletarPagina([FromBody] object page, string token) { dynamic objEn = page; string a = objEn.idPagina.ToString(); if (await Seguranca.validaTokenAsync(token)) { Page obj = PageDAO.GetAll().Where(x => x.ID == Convert.ToInt32(a)).FirstOrDefault(); return(Json(new { msg = PageDAO.Remove(obj) })); //return Json(new { msg = false }); } else { return(Json(new { msg = false })); } }
public ActionResult Editor_Save(string pageData) { Page Page = new Page(); try { Page = JsonConvert.DeserializeObject <Page>(pageData); Page.Published = false; PageDAO.Save(Page); } catch (Exception e) { Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PageController.Editor_Save()" + e.Message); } return(RedirectToAction("ViewPageHistory", "Page", new { pageId = Page.PageId })); }
public void CreatePageTest() { var page = new Page { Nome = "Teste3", Descricao = "Teste3", Titulo = "Teste3", Url = "Teste3", Conteudo = "Teste3", UsuarioCriacao = 1, UsuarioEdicao = 1, DataCriacao = DateTime.Now, DateAlteracao = DateTime.Now, Ativo = true.ToString(), Status = 1 }; var result = PageDAO.Save(page); }
public ActionResult Edit(string id) { try { Page Page = new Page(); if (!string.IsNullOrWhiteSpace(id)) { Page = PageDAO.LoadByBsonId(id); } ViewBag.Page = Page; } catch (Exception e) { Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PageController.Edit()" + e.Message); } return(View()); }
/// <summary> /// Load the requested page from the app cache /// </summary> /// <param name="friendlyURL"></param> /// <returns></returns> public static Page GetPageFromCache(string friendlyURL) { Page Page = new Page(); Dictionary <string, Page> CurrentPageDictionary = PageDictionary; if (!PageDictionary.ContainsKey(friendlyURL)) { Page = PageDAO.LoadByURL(friendlyURL); if (!string.IsNullOrWhiteSpace(Page.Id)) { CurrentPageDictionary.Add(Page.PageFriendlyURL, Page); PageDictionary = CurrentPageDictionary; } } else { Page = CurrentPageDictionary[friendlyURL]; } return(Page); }
public void RemovePageTest() { var obj = PageDAO.GetAll().Find(x => x.ID == 1); var result = PageDAO.Remove(obj); }
public void GetAllPageTest() { var resut = PageDAO.GetAll(); }