public static bool AddUser(string userName) { if (waitList.Any(p => userName == p.UserName)) { return(false); // User is already in waiting list. Could be an error from elsewhere. } WaitingRecord wr = new WaitingRecord { UserName = userName, DateTimeLastActive = DateTime.Now }; waitList.Add(wr); return(true); // User is properly added last in the list. }
public static bool Touch(string userName) { //Todo: Check for errors... const int notFoundInList = -1; int positionInList = FindUserInList(userName); if (positionInList == notFoundInList) { return(false); } WaitingRecord wr = new WaitingRecord { UserName = userName, DateTimeLastActive = DateTime.Now }; waitList.RemoveAt(positionInList); waitList.Insert(positionInList, wr); return(true); }