コード例 #1
0
        private static void ReassignChore(ChoreRepository choreRepo, RoommateRepository roommateRepo)
        {
            List <Chore> assignedChores = choreRepo.GetAssignedChores();

            foreach (Chore chore in assignedChores)
            {
                Console.WriteLine($"{chore.Id} - {chore.Name}");
            }
            Console.Write("Chore to reassign: ");
            int choreSelection = int.Parse(Console.ReadLine());

            Roommate roommateChore = roommateRepo.GetRoommateChoreById(choreSelection);

            Console.WriteLine($"This chore is currently assigned to {roommateChore.FirstName}. Who would you like to assign it to?");

            List <Roommate> roommates = roommateRepo.GetAll();

            foreach (Roommate roommate in roommates)
            {
                Console.WriteLine($"{roommate.Id} - {roommate.FirstName}");
            }
            Console.Write("Roommate to be assigned chore: ");
            int roommateSelection = int.Parse(Console.ReadLine());

            choreRepo.ReassignChore(choreSelection, roommateSelection, roommateChore.Id);

            Roommate roommateAssigned = roommateRepo.GetById(roommateSelection);

            Console.WriteLine($"Chore successfully reassigned to {roommateAssigned.FirstName}");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }