public async Task <IActionResult> Delete(int id) { try { var evento = await _repository.GetEventoByIdAsync(id, false); if (evento == null) { return(NotFound()); } _repository.Delete(evento); if (await _repository.SaveChangesAsync()) { return(Ok()); } } catch (ApplicationException e) { return(RedirectToAction(nameof(ErrorModel), new { message = e.Message })); } return(BadRequest()); }