public async Task <ActionResult> Delete(int id, IFormCollection collection) { if (id == 0) { return(NotFound()); } var entity = await _vacinaService.GetByIdAsync(id); if (entity == null) { return(NotFound()); } try { await _vacinaService.DisableAsync(entity); return(RedirectToAction(nameof(Index))); } catch (Exception) { return(BadRequest( new { Error = "Ocorreu um erro para salvar os dados. Tente novamente mais tarde! Se o problema persistir entre em contato com o suporte técnico." } )); } }
public async Task <ActionResult> Disable(long id) { var entity = await _vacinaService.GetByIdAsync(id); if (entity == null) { return(NotFound()); } try { await _vacinaService.DisableAsync(entity); } catch (Exception) { return(BadRequest( new { Error = "Ocorreu um erro para salvar os dados. Tente novamente mais tarde! Se o problema persistir entre em contato com o suporte técnico." } )); } return(Ok()); }