/// private static void SelectUsers(bool option) { for (int i = 0; i < AllUsers.Count; i++) { int selectionNum = i + 1; Console.WriteLine(value: selectionNum + ". : " + AllUsers[index: i].FirstName + " " + AllUsers[index: i].LastName); } Console.WriteLine(value: "Select user via number."); try { var userSelection = Convert.ToInt32(value: Console.ReadLine()); while (userSelection < 1 || userSelection > AllUsers.Count) { Console.WriteLine(value: "Input incorrect. Please select a user by number"); userSelection = Convert.ToInt32(value: Console.ReadLine()); } if (option) { AddHours(currentUser: AllUsers[index: userSelection - 1], allUsers: AllUsers[index: userSelection - 1]); decimal totalPay = WorkWeek.CalculatePay(AllUsers[index: userSelection - 1]); Console.WriteLine("Weekly pay is " + totalPay); } else { EditHours(currentUser: AllUsers[index: userSelection - 1]); decimal totalPay = WorkWeek.CalculatePay(AllUsers[index: userSelection - 1]); Console.WriteLine("Weekly pay is " + totalPay); } } catch (FormatException e) { SelectUsers(option); } }
public static void AddHours(Users currentUser, Users allUsers) { Console.WriteLine(value: "Please input hour's worked for Monday"); string mondayHours = Console.ReadLine(); Console.WriteLine(value: "Please input hour's worked for Tuesday"); string tuesdayHours = Console.ReadLine(); Console.WriteLine(value: "Please input hour's worked for Wednesday"); string wednesdayHours = Console.ReadLine(); Console.WriteLine(value: "Please input hour's worked for Thursday"); string thursdayHours = Console.ReadLine(); Console.WriteLine(value: "Please input hour's worked for Friday"); string fridayHours = Console.ReadLine(); Console.WriteLine(value: "Please input hour's worked for Saturday"); string saturdayHours = Console.ReadLine(); Console.WriteLine(value: "Please input hour's worked for Sunday"); string sundayHours = Console.ReadLine(); int rate = allUsers.UserRate; WorkWeek workweek = new WorkWeek(monday: mondayHours, tuesday: tuesdayHours, wednesday: wednesdayHours, thursday: thursdayHours, friday: fridayHours, saturday: saturdayHours, sunday: sundayHours, payrate: rate); WorkList.Add(item: workweek); Console.WriteLine(value: "Hours added."); }