public async Task <IActionResult> Delete(int id) { try { if (await _eventoService.DeleteEventos(id)) { return(Ok("Excluído com sucesso")); } return(BadRequest($"Erro ao excluir o evento id: {id}")); } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Erro ao tentar excluir um evento. Erro: {e.Message}")); } }
public async Task <IActionResult> Delete(int id) { try { var evento = await _eventoService.GetEventoByIdAsync(id, true); if (evento == null) { return(NoContent()); } return(await _eventoService.DeleteEventos(id) ? Ok(new { message = "Deletado" }) : throw new Exception("Ocorreu um problema não específico ao tentar deletar o evento")); } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Erro ao tentar deletar o evento. Erro: {ex.Message}")); } }