public ActionResult Create(EventoViewModel evento) { if (ModelState.IsValid) { var eventoDomain = Mapper.Map <EventoViewModel, Evento>(evento); eventoDomain.UsuarioId = User.Identity.GetUserId(); eventoDomain.DataCancelamento = null; _eventoApp.Add(eventoDomain); return(RedirectToAction("Index")); } CarregarDropDownTipoEvento(); return(View(evento)); }
public async Task <IActionResult> Post([FromBody] EventoViewModel model) { try { var evento = eventoAppService.Add(model); if (await eventoAppService.SaveChangesAsync()) { return(Created($"/api/evento/{model.Id}", model)); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados Falhou!")); } return(BadRequest()); }