public ActionResult DeleteConfirmed(int id) { try { var payload = _instructorService.findById(id); if (payload == null) { return(NotFound()); } if (_instructorService.Remove(payload)) { var mMessages = new VMMessages() { Css = "alert alert-success", Text = "Removido com sucesso!" }; TempData["_mensagem"] = JsonConvert.SerializeObject(mMessages); } else { var mMessages = new VMMessages() { Css = "alert alert-danger", Text = "Um erro insperado ocorreu" }; TempData["_mensagem"] = JsonConvert.SerializeObject(mMessages); } return(RedirectToAction(nameof(Index))); } catch (CustomHttpException ex) { //return StatusCode(ex.StatusCode, ex.ErrorMessage); } catch (Exception ex) { _logger.Log(LogLevel.Error, ex.Message); //return StatusCode(500, new { error = "Internal server error" }); } var _msg = new VMMessages() { Css = "alert alert-danger", Text = "Um erro insperado ocorreu" }; TempData["_mensagem"] = JsonConvert.SerializeObject(_msg); return(RedirectToAction(nameof(Index))); }
public void Remove(Guid id) { instructorService.Remove(id); unitOfWork.Commit(); }