public void DeleteUserNotFound() { UsersFacade usersFacade = new UsersFacade(); DeleteUserResponse deleteResponse = usersFacade.DeleteUser(-1, "Admin"); Assert.AreEqual(HttpStatusCode.NotFound, deleteResponse.Status); }
public void DeleteUser() { UsersFacade usersFacade = new UsersFacade(); AddUserRequest addUserRequest = new AddUserRequest(); addUserRequest.Username = AlphaNumericStringGenerator.GetString(10); addUserRequest.Password = "******"; addUserRequest.PasswordConfirm = "Password1"; AddUserResponse addUserResponse = usersFacade.AddUser(addUserRequest); Assert.AreEqual(HttpStatusCode.OK, addUserResponse.Status); DeleteUserResponse deleteResponse = usersFacade.DeleteUser(addUserResponse.UserId, "Admin"); Assert.AreEqual(HttpStatusCode.OK, deleteResponse.Status); GetUserResponse response = usersFacade.GetUser(addUserResponse.UserId); Assert.AreEqual(HttpStatusCode.NotFound, response.Status); }
public IActionResult DeleteUser([FromRoute] int id) { if (!IsAuthorized()) { return(Unauthorized()); } try { var facade = new UsersFacade(); var response = facade.DeleteUser(id, GetUsername()); switch (response.Status) { case HttpStatusCode.OK: return(Ok(response)); case HttpStatusCode.Forbidden: return(Forbid()); case HttpStatusCode.BadRequest: return(BadRequest(BuildBadRequestMessage(response))); case HttpStatusCode.InternalServerError: return(StatusCode(StatusCodes.Status500InternalServerError)); case HttpStatusCode.NotFound: return(NotFound()); } s_logger.Fatal("This code should be unreachable, unknown result has occured."); } catch (Exception ex) { s_logger.Error(ex, "Unable to delete user."); } return(StatusCode(StatusCodes.Status500InternalServerError)); }