public async Task <IActionResult> Put(int EventoId, Evento model) { try { var evento = await _repo.GetEventoAsyncById(EventoId, false); if (evento == null) { return(NotFound()); } _repo.Update(model); if (await _repo.SaveChangesAsync()) { return(Created($"/api/evento/{model.Id}", model)); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou ")); } return(BadRequest()); }
public async Task <IActionResult> Put(int id, [FromBody] Evento model) { try { var evento = await _context.GetEventoAsyncById(id, false); if (evento == null) { return(NotFound()); } model.Id = id; _context.Update(model); if (await _context.SaveChangesAsync()) { return(Created($"/api/evento/{model.Id}", model)); //return Ok(); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco Dados Falhou")); } return(BadRequest()); }