public async Task <IActionResult> GetById(int id) { try { var evento = await _repository.GetEventoByIdAsync(id, true); var result = _mapper.Map <EventoDto>(evento); return(Ok(result)); } catch (ApplicationException e) { return(RedirectToAction(nameof(ErrorModel), new { message = e.Message })); } }
public async Task <IActionResult> Edit(int id, Palestrante palestrante) { try { var palestranteId = await _repository.GetEventoByIdAsync(id, false); if (palestranteId == null) { return(NotFound()); } _repository.Update(palestrante); if (await _repository.SaveChangesAsync()) { return(Created($"/api/palestrante/{palestrante.Id}", palestrante)); } } catch (ApplicationException e) { return(RedirectToAction(nameof(ErrorModel), new { message = e.Message })); } return(BadRequest()); }