private static Staff Login(List <Staff> availableStaff) { bool loggedIn = false; Staff staffToLogin = null; Console.Clear(); Console.WriteLine("** Login ** "); availableStaff.ForEach(s => Console.WriteLine(StaffHandler.PrintInfo(s))); while (!loggedIn) { try { Console.WriteLine("Select which Id to log in as. Enter 0 to exit"); Console.Write("Id: "); string userInput = Console.ReadLine(); if (userInput == "0") { return(null); } else { int staffId = int.Parse(userInput); staffToLogin = availableStaff.Find(s => s.Id == staffId); if (staffToLogin != null) { loggedIn = true; } else { Console.WriteLine(String.Format("No staff with id {0} was found - try again.", staffId)); } } } catch (FormatException) { Console.WriteLine("Id must be a number. Try again."); } } return(staffToLogin); }
private static void PrintByStaffMember() { using (CashRegistryModel db = new CashRegistryModel()) { List <Staff> staff = db.Staff .Where(s => s.Transaction.Count > 0) // Only get the staff that has any transactions .ToList(); foreach (Staff s in staff) { Console.WriteLine("\n\n" + StaffHandler.PrintInfo(s)); foreach (Transaction t in s.Transaction.OrderByDescending(t => GetTotalSum(t))) // Order by transaction sum { Console.WriteLine(GetShortSummary(t)); } } } }