Exemple #1
0
 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
     }
 }
Exemple #2
0
        // 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());
        }