// 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()); } }
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()); }
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); }