Пример #1
0
 public IActionResult Delete(int id)
 {
     try
     {
         deleteRole.Execute(id);
         return(StatusCode(204));
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(new
         {
             Errors = new List <string> {
                 e.Message
             }
         }));
     }
     catch (Exception e)
     {
         return(StatusCode(500, new
         {
             Errors = new List <string> {
                 e.Message
             }
         }));
     }
 }
Пример #2
0
 public IActionResult Delete(int id)
 {
     try
     {
         _deleteRole.Execute(id);
         return(StatusCode(204));
     }
     catch (NotFoundException)
     {
         return(NotFound());
     }
 }
Пример #3
0
 public IActionResult Delete(int id)
 {
     try
     {
         _deleteRoleCommand.Execute(id);
         return(StatusCode(204, "Successfully deleted role."));
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
 }
Пример #4
0
 // GET: Roles/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         // TODO: Add delete logic here
         _deleteRole.Execute(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured. Please try again.";
         return(RedirectToAction(nameof(Index)));
     }
 }
Пример #5
0
 public ActionResult Delete(int id)
 {
     try
     {
         deleteRoleCommand.Execute(id);
         return(NoContent());
     }
     catch (DataNotFoundException)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500, "Server is busy at the moment, please try later"));
     }
 }
        public ActionResult Delete(int id)
        {
            try
            {
                _deleteRole.Execute(id);
                return(StatusCode(200));
            }

            catch (EntityNotFoundException e)
            {
                return(NotFound(e.Message));
            }
            catch (Exception e) {
                return(StatusCode(500, e.Message));
            }
        }
Пример #7
0
 public IActionResult Delete(int id)
 {
     try
     {
         _deleteRoleCommand.Execute(id);
         return(NoContent());
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (Exception)
     {
         return(StatusCode(500, "Server error"));
     }
 }
Пример #8
0
 public ActionResult DeleteRole(int id)
 {
     try
     {
         _deleteRoleCommand.Execute(id);
         return(NoContent());
     }catch (NotFoundException)
     {
         return(NotFound());
     }catch (AlredyExistException)
     {
         return(StatusCode(422, "Role is alredy deleted"));
     }catch (Exception)
     {
         return(StatusCode(500, "Server error, try later"));
     }
 }
Пример #9
0
 public ActionResult Delete(int id)
 {
     try
     {
         _deleteRoleCommand.Execute(id);
         return(NoContent());
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (EntityDeleteForbiddenException e)
     {
         return(StatusCode(StatusCodes.Status403Forbidden, e.Message));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
Пример #10
0
        public ActionResult Delete(int id)
        {
            try
            {
                _deleteRoleCommand.Execute(id);
                TempData["success"] = "Role deleted.";
            }
            catch (EntityNotFoundException e)
            {
                TempData["error"] = e.Message;
            }
            catch (EntityDeleteForbiddenException e)
            {
                TempData["error"] = e.Message;
            }
            catch (Exception e)
            {
                TempData["error"] = e.Message;
            }

            return(RedirectToAction(nameof(Index)));
        }