public static MvcHtmlString CreateMenuPropostas(this HtmlHelper helper) { String li = ""; var dao = new ArosDAO(); var categorias = dao.ListarCategoriasDeDocumento(); List <DDLDTO> propostas = null; categorias.ForEach(categoria => { propostas = dao.ListarDocumentos(Convert.ToInt32(categoria.Id)); if (propostas.Count > 0) { li += String.Format("<li class=\"dropdown-header\">{0}</li>", categoria.Desc); } propostas.ForEach(proposta => { li += String.Format("<li><a href=\"/Template/StartView/View_{0}_edt\">{1}</a></li>", proposta.Id, proposta.Desc); }); if (propostas.Count > 0) { li += "<li role=\"separator\" class=\"divider\"></li>"; } }); return(MvcHtmlString.Create(String.Format("<ul class=\"dropdown-menu\">{0}</ul>", li))); }
public ActionResult Atualizar(TemplateViewModel model) { var dao = new ArosDAO(); model.ListaTemplates = dao.ListarDocumentos(); model.Categorias = dao.ListarCategoriasDeDocumento(); model.Cabecalho = LoadHtml(this.Cabecalho); model.Rodape = LoadHtml(this.Rodape); if (model.Id != null) { var obj = new ArosDAO().ObterDocumento((int)model.Id); model.Html = obj.Html; // Microsoft.Security.Application.Sanitizer.GetSafeHtml(new ArosDAO().ObterDocumento((int)model.Id)); model.Categoria = obj.Categoria; var tg = model.ListaTemplates.Where(i => i.Id.Equals(model.Id.ToString())).FirstOrDefault(); model.Nome = tg.Desc; } else { model.Nome = String.Empty; model.Html = String.Empty; } model.ListaTemplates.Insert(0, new Core.DTO.DDLDTO(null, null, "Criar Novo Tamplate")); ModelState.Remove("Categoria"); ModelState.Remove("Nome"); ModelState.Remove("Html"); return(View("Index", model)); }
public ActionResult Index() { var dao = new ArosDAO(); var model = new TemplateViewModel(); model.ListaTemplates = dao.ListarDocumentos(); model.ListaTemplates.Insert(0, new Core.DTO.DDLDTO(null, null, "Criar Novo Tamplate")); model.Categorias = dao.ListarCategoriasDeDocumento(); model.Cabecalho = LoadHtml(this.Cabecalho); model.Rodape = LoadHtml(this.Rodape); return(View("Index", model)); }
public ActionResult Salvar(TemplateViewModel model) { var dao = new ArosDAO(); model.ListaTemplates = dao.ListarDocumentos(); model.Categorias = dao.ListarCategoriasDeDocumento(); model.Cabecalho = LoadHtml(this.Cabecalho); model.Rodape = LoadHtml(this.Rodape); if (ModelState.IsValid) { if (model.Id == null) { ModelState.Remove("Id"); } var id = new ArosDAO().SalvarDocumento( new Core.DTO.ModeloDocumentoDTO(null) { Id = model.Id, Categoria = model.Categoria, Nome = model.Nome, Html = model.Html }); //Só Seta o ID na Model, se ele não existir ainda (Novo Resgistro) if (id > 0 && model.Id == null) { model.Id = id; } CreateViews(model); //Atualiza a lista model.ListaTemplates = new ArosDAO().ListarDocumentos(); } ModelState.Remove("Categoria"); ModelState.Remove("Nome"); ModelState.Remove("Html"); //model.Html = Microsoft.Security.Application.Sanitizer.GetSafeHtml(model.Html); model.ListaTemplates.Insert(0, new Core.DTO.DDLDTO(null, null, "Criar Novo Tamplate")); return(View("Index", model)); }
public ActionResult Deletar(TemplateViewModel model) { var dao = new ArosDAO(); model.ListaTemplates = dao.ListarDocumentos(); model.Categorias = dao.ListarCategoriasDeDocumento(); model.Cabecalho = LoadHtml(this.Cabecalho); model.Rodape = LoadHtml(this.Rodape); if (ModelState.IsValid) { if (model.Id == null) { ModelState.Remove("Id"); } var id = new ArosDAO().DeletarDocumento( new Core.DTO.ModeloDocumentoDTO(null) { Id = model.Id, }); DeleteViews(model); //Atualiza a lista model.ListaTemplates = new ArosDAO().ListarDocumentos(); } ModelState.Remove("Categoria"); ModelState.Remove("Nome"); ModelState.Remove("Html"); //model.Html = Microsoft.Security.Application.Sanitizer.GetSafeHtml(model.Html); model.ListaTemplates.Insert(0, new Core.DTO.DDLDTO(null, null, "Criar Novo Tamplate")); return(RedirectToAction("Index")); }