public async Task <IActionResult> Create(CategoriaViewModel model) { if (ModelState.IsValid) { Categoria categoria = new Categoria() { Descricao = model.Descricao, }; db.Add(categoria); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <IActionResult> Create(Municipio model) { if (ModelState.IsValid) { Municipio municipio = new Municipio() { Nome = model.Nome, Uf = model.Uf }; db.Add(municipio); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <IActionResult> Create(NoticiaViewModel model) { if (ModelState.IsValid) { Noticia noticia = new Noticia() { Titulo = model.Titulo, Corpo = model.Corpo, DataPublicacao = model.DataPublicacao, Autor = model.Autor, Destaque = model.Destaque, CategoriaId = model.CategoriaId }; db.Add(noticia); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }