public bool DeleteUser(string email) { AdminDeleteUserRequest adminDeleteUserRequest = new AdminDeleteUserRequest { Username = email, UserPoolId = _connectionInfo.UserPoolId }; try { var response = _provider.AdminDeleteUserAsync(adminDeleteUserRequest).Result; if (response.HttpStatusCode == HttpStatusCode.OK) { return(true); } else { return(false); } } catch (AggregateException e) { bool response = false; // Let anything we can't handle stop the application. e.Handle((x) => { if (x is NotAuthorizedException) // This we know how to handle. { LoggingHandler.LogError("Authentication Gateway: Invalid credentials provided."); response = false; } if (x is UserNotFoundException) // This we know how to handle. { LoggingHandler.LogWarning("Authentication Gateway: User not found."); response = true; } return(response); }); return(response); } catch (Exception e) { LoggingHandler.LogError(e.Message); LoggingHandler.LogError(e.StackTrace); throw; } }
public void DeleteUserOrganisationLink(int userId) { try { var userOrganisationLink = Context.UserOrganisations .FirstOrDefault(o => o.UserId == userId); if (userOrganisationLink == null) { LoggingHandler.LogWarning("User Organisation Link does not exist"); } else { Context.UserOrganisations.Remove(userOrganisationLink); Context.SaveChanges(); LoggingHandler.LogInfo("User organisation link removed successfully"); } } catch (Exception e) { LoggingHandler.LogError(e.Message); LoggingHandler.LogError(e.StackTrace); throw; } }