예제 #1
0
 // GET: Users/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         deleteCommand.Execute(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityNotFoundException e)
     {
         TempData["error"] = e.Message;
         return(View());
     }
 }
예제 #2
0
    public ActionResult Delete(string username)
    {
        var existingUser = _getUser.Execute(username);

        if (existingUser == null)
        {
            return(NotFound());
        }

        using (var scope = new TransactionScope())
        {
            _deleteUser.Execute(username);
            scope.Complete();
        }

        return(Ok());
    }
예제 #3
0
 public IActionResult Delete(int id)
 {
     try
     {
         var userFromTokenId = loginService.PossibleUser().Id;
         if (userFromTokenId == id)
         {
             return(BadRequest(new ErrorMessage {
                 Message = "You cannot delete your own account!"
             }));
         }
         deleteCommand.Execute(id);
         return(NoContent());
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(new ErrorMessage {
             Message = e.Message
         }));
     }
 }
 public async Task Delete(Guid id)
 {
     await _deleteUser.Execute(id);
 }