コード例 #1
0
        static void DeleteChore(ChoreRepository choreRepo)
        {
            List <Chore> allChores = choreRepo.GetAll();

            // Select a chore
            Console.Clear();
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("Assign Chores");
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("-------------");
            Console.WriteLine("\nPlease choose a chore to delete:");
            for (int i = 1; i < allChores.Count + 1; i++)
            {
                Console.WriteLine($"{i}) {allChores[i-1].Name}");
            }
            Console.WriteLine();
            string userSelection  = Console.ReadLine();
            bool   validSelection = int.TryParse(userSelection, out int choreNum);

            while (!validSelection || choreNum < 0 || choreNum > allChores.Count)
            {
                Console.WriteLine("Invalid selection");
                userSelection  = Console.ReadLine();
                validSelection = int.TryParse(userSelection, out choreNum);
            }
            Chore deletedChore = allChores[choreNum - 1];

            choreRepo.Delete(deletedChore.Id);

            Console.WriteLine($"{deletedChore.Name} has been removed from the list.");
        }
コード例 #2
0
        static void SearchChore(ChoreRepository choreRepo)
        {
            while (true)
            {
                try
                {
                    Console.Write("Chore Id: ");
                    int   id    = int.Parse(Console.ReadLine());
                    Chore chore = choreRepo.GetChoreById(id);

                    if (chore == null)
                    {
                        throw new Exception();
                    }

                    Console.WriteLine($"{chore.Id} - {chore.Name}");
                    ContinueMenu();
                    break;
                }
                catch
                {
                    continue;
                }
            }
        }
コード例 #3
0
        static void AssignRoommateChore(ChoreRepository choreRepo, RoommateRepository roommateRepo)
        {
            Console.WriteLine("----------------------");
            Console.WriteLine("Chores");
            Console.WriteLine("----------------------");
            List <Chore> chores = choreRepo.GetAll();

            chores.ForEach(c => Console.WriteLine($"{c.Id} - {c.Name}"));
            Console.WriteLine("");
            Console.Write("Enter chore Id: ");
            int choreId = int.Parse(Console.ReadLine());

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

            Console.WriteLine("");
            Console.WriteLine("----------------------");
            Console.WriteLine("Roommates");
            Console.WriteLine("----------------------");
            roommates.ForEach(r => Console.WriteLine($"{r.Id} - {r.Firstname}"));
            Console.WriteLine("");
            Console.Write("Enter roommate Id: ");
            int roommateId = int.Parse(Console.ReadLine());

            Chore    selectedChore    = chores.Find(c => c.Id == choreId);
            Roommate selectedRoommate = roommates.Find(r => r.Id == roommateId);

            choreRepo.AssignChore(roommateId, choreId);
            Console.WriteLine($"{selectedRoommate.Firstname} is assign to {selectedChore.Name}");
            ContinueMenu();
        }
コード例 #4
0
        static void AssignChoreToRoommate(ChoreRepository choreRepo, RoommateRepository roommateRepo)
        {
            List <Chore>    chores    = choreRepo.GetAll();
            List <Roommate> roommates = roommateRepo.GetAll();

            foreach (Chore c in chores)
            {
                Console.WriteLine($"{c.Id} - {c.Name}");
            }
            Console.Write("Select chore: ");
            int choreChoice = int.Parse(Console.ReadLine());

            foreach (Roommate r in roommates)
            {
                Console.WriteLine($"{r.Id} - {r.FirstName}");
            }
            Console.Write("Select roommate: ");
            int roommateChoice = int.Parse(Console.ReadLine());

            choreRepo.AssignChore(choreChoice, roommateChoice);

            Chore    chore    = choreRepo.GetById(choreChoice);
            Roommate roommate = roommateRepo.GetById(roommateChoice);

            Console.WriteLine($"{chore.Name} has been assigned to {roommate.FirstName}");
            Console.Write("Press any key to continue");
            Console.ReadKey();
        }
コード例 #5
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();
        }
コード例 #6
0
        static void EditChore(ChoreRepository choreRepo)
        {
            List <Chore> allChores = choreRepo.GetAll();

            // Select a chore
            Console.Clear();
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("Assign Chores");
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("-------------");
            Console.WriteLine("\nPlease choose a chore to edit:");
            for (int i = 1; i < allChores.Count + 1; i++)
            {
                Console.WriteLine($"{i}) {allChores[i-1].Name}");
            }
            Console.WriteLine();
            string userSelection  = Console.ReadLine();
            bool   validSelection = int.TryParse(userSelection, out int choreNum);

            while (!validSelection || choreNum < 0 || choreNum > allChores.Count)
            {
                Console.WriteLine("Invalid selection");
                userSelection  = Console.ReadLine();
                validSelection = int.TryParse(userSelection, out choreNum);
            }
            Chore editedChore = allChores[choreNum - 1];

            Console.WriteLine("Please enter a new name for this chore:");
            editedChore.Name = Console.ReadLine();

            choreRepo.Update(editedChore);

            Console.WriteLine($"{editedChore.Name} has been updated.");
        }
コード例 #7
0
        static void ShowChoreCount(ChoreRepository choreRepo)
        {
            List <RoommateChoreCount> roommateChoreCounts = choreRepo.ChoreCount();

            roommateChoreCounts.ForEach(r => Console.WriteLine($"{r.FirstName}: {r.NumOfChores}"));

            ContinueMenu();
        }
コード例 #8
0
        static void PrintUnassignedChores(ChoreRepository choreRepo)
        {
            List <Chore> unassedChores = choreRepo.GetUnassignedChores();

            foreach (Chore c in unassedChores)
            {
                Console.WriteLine($"{c.Id} - {c.Name}");
            }
        }
コード例 #9
0
        static void ShowUnassignedChores(ChoreRepository choreRepo)
        {
            List <Chore> chores = choreRepo.GetUnassignedChores();

            foreach (Chore c in chores)
            {
                Console.WriteLine($"{c.Name}");
            }
            ContinueMenu();
        }
コード例 #10
0
        static void ShowAllChores(ChoreRepository choreRepo)
        {
            List <Chore> chores = choreRepo.GetAll();

            foreach (Chore c in chores)
            {
                Console.WriteLine($"{c.Id} - {c.Name}");
            }
            ContinueMenu();
        }
コード例 #11
0
        static void ListAllChores()
        {
            ChoreRepository choreRepo = new ChoreRepository(CONNECTION_STRING);
            List <Chore>    chores    = choreRepo.GetAll();

            foreach (Chore c in chores)
            {
                Console.WriteLine($"{c.Id} - {c.Name}");
            }
        }
コード例 #12
0
        static void AddOneChore(ChoreRepository choreRepo)
        {
            Console.Write("Chore name: ");
            string name = Console.ReadLine();

            Chore choreToAdd = new Chore()
            {
                Name = name,
            };
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: TAPinson/Roommates
            static void searchForChore(ChoreRepository choreRepo)
            {
                Console.Write("Chore Id: ");
                int   choreId = int.Parse(Console.ReadLine());
                Chore chore   = choreRepo.GetById(choreId);

                Console.WriteLine($"{chore.Name} - {chore.Id}");
                Console.Write("Press any key to continue");
                Console.ReadKey();
            }
コード例 #14
0
ファイル: ChoreController.cs プロジェクト: anthonied/Taskify
        public JsonResult Create(ChoreModel model)
        {
            var repo = new ChoreRepository();

            repo.Create(model.ToDomain());
            return(new JsonResult
            {
                Data = new { IsOk = true }
            });
        }
コード例 #15
0
        static void ShowUnassignedChores(ChoreRepository choreRepo)
        {
            List <Chore> unassignedChores = choreRepo.GetUnassignedChores();

            foreach (Chore chore in unassignedChores)
            {
                Console.WriteLine($"{chore.Id} - {chore.Name}");
            }
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
コード例 #16
0
        private static void ListChoreCounts(ChoreRepository choreRepo)
        {
            List <ChoreCount> choreCounts = choreRepo.GetChoreCounts();

            foreach (ChoreCount choreCount in choreCounts)
            {
                Console.WriteLine($"{choreCount.RoommateName}: {choreCount.Count}");
            }
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
コード例 #17
0
        static void UnassignChore(ChoreRepository choreRepo)
        {
            Console.Clear();
            Console.WriteLine("This function coming soon...");
            //dictionary<chore, roommate> allassignments = chorerepo.getallassignments();

            //for (int i = 1; i < allassignments.count + 1; i++)
            //{
            //    console.writeline("")
            //}
        }
コード例 #18
0
        static void AssignChore(ChoreRepository choreRepo, RoommateRepository roommateRepo)
        {
            List <Chore>    allChores    = choreRepo.GetAll();
            List <Roommate> allRoommates = roommateRepo.GetAll();

            // Select a chore
            Console.Clear();
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("Assign Chores");
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("-------------");
            Console.WriteLine("\nPlease choose a chore to assign:");
            for (int i = 1; i < allChores.Count + 1; i++)
            {
                Console.WriteLine($"{i}) {allChores[i-1].Name}");
            }
            Console.WriteLine();
            string userSelection  = Console.ReadLine();
            bool   validSelection = int.TryParse(userSelection, out int choreNum);

            while (!validSelection || choreNum < 0 || choreNum > allChores.Count)
            {
                Console.WriteLine("Invalid selection");
                userSelection  = Console.ReadLine();
                validSelection = int.TryParse(userSelection, out choreNum);
            }
            Chore assignedChore = allChores[choreNum - 1];

            // Select a roommate
            Console.Clear();
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("Assign Chores");
            Console.SetCursorPosition((Console.WindowWidth - 13) / 2, Console.CursorTop);
            Console.WriteLine("-------------");
            Console.WriteLine($"\nAssign {assignedChore.Name} to a roommate:");
            for (int i = 1; i < allRoommates.Count + 1; i++)
            {
                Console.WriteLine($"{i}) {allRoommates[i-1].Firstname} {allRoommates[i-1].Lastname}");
            }
            Console.WriteLine();
            userSelection  = Console.ReadLine();
            validSelection = int.TryParse(userSelection, out int roommateNum);
            while (!validSelection || roommateNum < 0 || roommateNum > allRoommates.Count)
            {
                Console.WriteLine("Invalid selection");
                userSelection  = Console.ReadLine();
                validSelection = int.TryParse(userSelection, out roommateNum);
            }
            Roommate assignedRoommate = allRoommates[roommateNum - 1];

            choreRepo.Assign(assignedChore, assignedRoommate);

            Console.WriteLine($"{assignedChore.Name} has been assigned to {assignedRoommate.Firstname}");
        }
コード例 #19
0
        static void ShowAllChores(ChoreRepository choreRepo)
        {
            List <Chore> chores = choreRepo.GetAll();

            foreach (Chore c in chores)
            {
                Console.WriteLine($"[{c.Id}] {c.Name}");
            }
            Console.Write("Press any key to continue");
            Console.ReadKey();
        }
コード例 #20
0
        static List <Chore> ListAllChores(string name)
        {
            ChoreRepository choreRepo = new ChoreRepository(CONNECTION_STRING);
            List <Chore>    chores    = choreRepo.GetAll();

            foreach (Chore c in chores)
            {
                Console.WriteLine($"{c.Id} - {c.Name}");
            }
            return(chores);
        }
コード例 #21
0
        static void DeleteChore(ChoreRepository choreRepo)
        {
            List <Chore> chores = choreRepo.GetAll();

            chores.ForEach(c => Console.WriteLine($"{c.Id} - {c.Name}"));
            Console.Write("Which chore would you like to delete? ");
            int selectedChoreId = int.Parse(Console.ReadLine());

            choreRepo.Delete(selectedChoreId);
            ContinueMenu();
        }
コード例 #22
0
 public APIController()
 {
     try
     {
         this.UserRepository  = new UserRepository();
         this.ChoreRepository = new ChoreRepository();
     }
     catch (Exception ex)
     {
         throw Utility.ThrowException(ex);
     }
 }
コード例 #23
0
        static void ListChores()
        {
            ChoreRepository choreRepo = new ChoreRepository(CONNECTION_STRING);
            List <Chore>    AllChores = choreRepo.GetAll();

            Console.WriteLine("------------------ Chore List -------------------");
            Console.WriteLine($"ID\tName");
            foreach (Chore aChor in AllChores)
            {
                Console.WriteLine($"{aChor.Id}\t{aChor.Name}");
            }
        }
コード例 #24
0
 public APIController(UserRepository _UserRepository, ChoreRepository _ChoreRepository)
 {
     try
     {
         this.UserRepository  = _UserRepository;
         this.ChoreRepository = _ChoreRepository;
     }
     catch (Exception ex)
     {
         throw Utility.ThrowException(ex);
     }
 }
コード例 #25
0
ファイル: LoginController.cs プロジェクト: rcaigoy/ChoreMan
 public LoginController()
 {
     try
     {
         UserRepository  = new UserRepository();
         ChoreRepository = new ChoreRepository();
     }
     catch (Exception ex)
     {
         throw Utility.ThrowException(ex);
     }
 }
コード例 #26
0
        static void ListAssignedChores()
        {
            ChoreRepository choreRepo = new ChoreRepository(CONNECTION_STRING);

            Console.WriteLine("-------------- Assigned Chores to Roommates -----------------------");
            List <string> assignedChores = choreRepo.ListAssigned();

            Console.WriteLine("RoommateID\tFirst\tLast\tChore");
            foreach (string line in assignedChores)
            {
                Console.WriteLine(line);
            }
        }
コード例 #27
0
 public UsersAPIController()
 {
     try
     {
         this.UserRepository            = new UserRepository();
         this.ChoreRepository           = new ChoreRepository();
         this.AccountPaymentsRepository = new AccountPaymentsRepository();
     }
     catch (Exception ex)
     {
         throw Utility.ThrowException(ex);
     }
 }
コード例 #28
0
ファイル: Program.cs プロジェクト: anthonied/Taskify
        static void Main(string[] args)
        {
            var chore = new Chore
            {
                Name        = "Write a program",
                Requirement = "Do a vertical of adding a chore",
                Deadline    = DateTime.Now,
                Status      = ChoreStatus.Inprogress
            };

            var repo = new ChoreRepository();

            repo.Create(chore);
        }
コード例 #29
0
ファイル: Program.cs プロジェクト: TAPinson/Roommates
            static void addAChore(ChoreRepository choreRepo)
            {
                Console.Write("Chore name: ");
                string choreName  = Console.ReadLine();
                Chore  choreToAdd = new Chore()
                {
                    Name = choreName
                };

                choreRepo.Insert(choreToAdd);
                Console.WriteLine($"{choreToAdd.Name} has been added and assigned an Id of {choreToAdd.Id}");
                Console.Write("Press any key to continue");
                Console.ReadKey();
            }
コード例 #30
0
        static void AddChore(ChoreRepository choreRepo)
        {
            Console.Write("Chore name: ");
            string name = Console.ReadLine();

            Chore choreToAdd = new Chore()
            {
                Name = name
            };

            choreRepo.Insert(choreToAdd);
            Console.WriteLine($"{choreToAdd.Name} has been added and assigned an Id of {choreToAdd.Id}");
            ContinueMenu();
        }