public async Task <IActionResult> Put(int EventoId, EventoDtos model) { try { var evento = await _repo.GetAllEventoAsyncById(EventoId, false); if (evento == null) { return(NotFound()); } _mapper.Map(model, evento); _repo.Update(evento); if (await _repo.SaveChangesAsync()) { return(Created($"/api/evento/{model.Id}", _mapper.Map <EventoDtos>(evento))); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados Falhou! :(")); } return(BadRequest()); }
public async Task <IActionResult> Post(EventoDtos model) { try { var evento = _mapper.Map <Evento>(model); _repo.Add(evento); if (await _repo.SaveChangesAsync()) { return(Created($"/api/evento/{model.Id}", _mapper.Map <EventoDtos>(evento))); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados Falhou! :(")); } return(BadRequest()); }