public ActionResult ListarNoticias() { _repositorio = new NoticiaRepository(); _repositorio.ListarNoticias(); ModelState.Clear(); return(View(_repositorio.ListarNoticias())); }
public void GravarNoticia(Noticia noticia) { INoticiaRepository noticiaRepository = new NoticiaRepository(); Domain.Interfaces.Services.INoticiaService noticiaService = new Domain.Services.NoticiaService(noticiaRepository); NoticiaAppService noticiaAppService = new NoticiaAppService(noticiaService); noticiaAppService.Add(noticia); }
public ActionResult DeNoticia(int codNoticia) { try { _repositorio = new NoticiaRepository(); if (_repositorio.DeletarNoticia(codNoticia)) { ViewBag.Mesagem = "Noticia Deletada com Sucesso!"; } return(RedirectToAction("ListarNoticias")); } catch (Exception e) { return(View("ListarNoticias")); } }
public ActionResult UpNoticia(int codNoticia, NoticiaModel noticia) { try { if (ModelState.IsValid) { _repositorio = new NoticiaRepository(); //Metodo para excluri imagem. ExcluirImagem(noticia); //Esse metodo Que salva o nome da imagem(com mais um monte de validacoes) SalvarImagem(noticia); _repositorio.AtualizarNoticia(noticia); } return(RedirectToAction("ListarNoticias")); } catch (Exception e) { return(View("ListarNoticias")); } }
public ActionResult InNoticia(NoticiaModel noticia) { try { if (ModelState.IsValid) { _repositorio = new NoticiaRepository(); //Esse metodo Que salva o nome da imagem(com mais um monte de validacoes) SalvarImagem(noticia); if (_repositorio.InserirNoticia(noticia)) { ViewBag.MessageCadastroSucesso = "Noticia Cadastrada com Sucesso!"; } } return(View()); } catch (Exception e) { return(View("ListarNoticias")); } }
/// <summary> /// Action para renderizar a página inicial do projeto. /// </summary> /// <returns></returns> public ActionResult Index() { IndexNoticiasViewModel model = new IndexNoticiasViewModel(); NoticiaRepository _noticiaRepository = new NoticiaRepository(); model.NoticiaList = _noticiaRepository.FindAll().ToList(); return View(model); }
public ActionResult UpNoticia(int codNoticia) { _repositorio = new NoticiaRepository(); return(View(_repositorio.ListarNoticias().Find(l => l.cod_noticia.Equals(codNoticia)))); }
public NoticiaController(NoticiaRepository repo, IMapper mapper, PortalNoticiasContext context) { _repo = repo; _mapper = mapper; _context = context; }