/// <summary> /// Retrieves all Users present in database /// User object as parameter for handling session timer and ping function /// </summary> /// <param name="admin"></param> public static List <List <object> > ListAllUsers(User admin) { List <List <object> > userListData = new List <List <object> >(); bool isUsersListed = false; do { if (SessionTimer.CheckSessionTimer(admin.SessionTimer) == true || admin.SessionTimer == DateTime.MinValue) { Console.Clear(); GeneralMessage.AdminNotLoggedIn(); break; } Console.Clear(); var api = new API(); var result = api.ListUsers(admin.Id); if (result == null) { ErrorMessage.ErrorNoAbort("retrieving a list of users", "the database is empty/corrupt"); break; } else { userListData = UserConverters.UserConverter(result); UserController.SendPing(admin.Id); isUsersListed = true; } } while (isUsersListed == false); return(UserView.UserListReader(userListData)); }
/// <summary> /// Retrieves all Users matching search term based on User.Name /// User object as parameter for handling session timer and ping function /// </summary> /// <param name="admin"></param> public static List <List <object> > FindUser(User admin) { List <List <object> > userListData = new List <List <object> >(); bool isUsersFound = false; do { if (SessionTimer.CheckSessionTimer(admin.SessionTimer) == true || admin.SessionTimer == DateTime.MinValue) { Console.Clear(); GeneralMessage.AdminNotLoggedIn(); break; } Console.Clear(); var api = new API(); Console.Write("Enter search term: "); var keyword = Console.ReadLine(); var result = api.FindUser(admin.Id, keyword); if (result.Count < 1) { var input = ErrorMessage.ErrorAbort("retrieving users", "the database is corrupt/empty, or your search term gave no matches"); if (input != "") { Console.Clear(); break; } } else { userListData = UserConverters.UserConverter(result); UserController.SendPing(admin.Id); isUsersFound = true; } } while (isUsersFound == false); return(UserView.UserListReader(userListData)); }