public ActionResult <IEnumerable <StudentDto> > Delete(int id) { try { _delCommandStd.Execute(id); return(NoContent()); //204 } catch (EntityNotFoundException e) { return(NotFound(e.Message)); //404 } catch (Exception) { return(StatusCode(500, "It's not working")); //500 } }
// GET: Students/Delete/5 public ActionResult Delete(int id) { if (!ModelState.IsValid) { return(View(id)); } try { _delCommandStd.Execute(id); return(RedirectToAction(nameof(Index))); } catch (Exception) { TempData["error"] = "error."; } return(View()); }