コード例 #1
0
        static void UpdateRoommate()
        {
            // Update Roommate
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("------------------ Roommate List -------------------");
            ListAllRoommates();
            Console.WriteLine("----------- Enter the Id of the Roommate You'd Like to Edit  -------------");
            Roommate roommate   = roommateRepo.GetById(Int32.Parse(Console.ReadLine()));
            string   rmResponse = null;

            Console.WriteLine("Enter a new first name for the roommate or press ENTER");
            rmResponse = Console.ReadLine();
            if (rmResponse != "")
            {
                roommate.FirstName = rmResponse;
            }
            Console.WriteLine("Enter a new last name for the roommate or press ENTER");
            rmResponse = Console.ReadLine();
            if (rmResponse != "")
            {
                roommate.LastName = rmResponse;
            }
            Console.WriteLine("Enter a whole number rent portion for this roommate or press ENTER");
            rmResponse = Console.ReadLine();
            if (rmResponse != "")
            {
                roommate.RentPortion = Int32.Parse(rmResponse);
            }
            Console.WriteLine("Enter a new move in date for the roommate MM-DD-YY or press ENTER: ");
            rmResponse = Console.ReadLine();
            if (rmResponse != "")
            {
                roommate.MoveInDate = DateTime.Parse(rmResponse);
            }
            Console.WriteLine("Enter the Room ID for the roommate or press ENTER: ");
            GetRooms();
            rmResponse = Console.ReadLine();
            if (rmResponse != "")
            {
                roommate.Room = GetRoom(Int32.Parse(rmResponse));
            }
            roommateRepo.Update(roommate);
            roommate = roommateRepo.GetById(roommate.Id);
            Console.WriteLine("Here is the Updated Roommate:");
            Console.WriteLine("First Name \t Last name \t Rent Portion \t Move In Date \t Room Name \t Max Occupancy");
            Console.WriteLine($"{roommate.Id} {roommate.FirstName}\t{roommate.LastName}\t{roommate.RentPortion}\t{roommate.MoveInDate}\t{roommate.Room.Name}\t{ roommate.Room.MaxOccupancy}");
        }
コード例 #2
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();
        }
コード例 #3
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();
        }
コード例 #4
0
        static void SearchRoommate(RoommateRepository roommateRepo)
        {
            while (true)
            {
                try
                {
                    Console.Write("Roommate Id: ");
                    int      id       = int.Parse(Console.ReadLine());
                    Roommate roommate = roommateRepo.GetById(id);

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

                    Console.WriteLine($"{roommate.Firstname}'s rent portion is ${roommate.RentPortion}, occupies {roommate.Room.Name}.");
                    ContinueMenu();
                    break;
                }
                catch
                {
                    continue;
                }
            }
        }
コード例 #5
0
        static void GetSingleRoommate(RoommateRepository roommateRepo)
        {
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 2");

            Roommate singleRoommate = roommateRepo.GetById(2);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.Firstname} {singleRoommate.Lastname} {singleRoommate.RentPortion} {singleRoommate.MovedInDate}");
        }
コード例 #6
0
        static void EditRoommate(RoommateRepository roommateRepo)
        {
            Roommate roommateToEdit = roommateRepo.GetById(3);

            roommateToEdit.RentPortion = 20;

            roommateRepo.Update(roommateToEdit);
            Console.WriteLine($"{roommateToEdit.Firstname} {roommateToEdit.Lastname} has been updated!");
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: TAPinson/Roommates
            static void searchForRoommate(RoommateRepository roommateRepo)
            {
                Console.Write("Roommate Id: ");
                int      roommateId = int.Parse(Console.ReadLine());
                Roommate roommate   = roommateRepo.GetById(roommateId);

                Console.WriteLine($"{roommate.Firstname} - Rent Portion: {roommate.RentPortion}% - {roommate.Room.Name}");
                Console.Write("Press any key to continue");
                Console.ReadKey();
            }
コード例 #8
0
ファイル: Program.cs プロジェクト: terraroush/Roommates
        static void ShowOneRoommate(RoommateRepository roommateRepo)
        {
            Console.Write("Roommate Id: ");
            int id = int.Parse(Console.ReadLine());

            Roommate roommate = roommateRepo.GetById(id);

            Console.WriteLine($"{roommate.Id} - {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate} {roommate.Room.Name}");
            Console.Write("Press any key to continue");
            Console.ReadKey();
        }
コード例 #9
0
        static void SearchForRoommate(RoommateRepository roommateRepo)
        {
            Console.Write("Roommate id: ");
            int id = int.Parse(Console.ReadLine());

            Roommate roommate = roommateRepo.GetById(id);

            Console.WriteLine($"{roommate.Id} - {roommate.FirstName} Rent Portion({roommate.RentPortion}) Room Name({roommate.Room.Name})");
            Console.Write("Press any key to continue");
            Console.ReadKey();
        }
コード例 #10
0
        private static Roommate RoommateValueUpdater(int id, RoommateRepository roommateRepo)
        {
            Roommate singleRoommate = roommateRepo.GetById(id);
            int      choice;

            do
            {
                Console.Clear();
                HouseBot();
                Console.WriteLine("What would you like to change?");
                Console.WriteLine($"1) First Name \t{singleRoommate.Firstname}");
                Console.WriteLine($"2) Last Name \t{singleRoommate.Lastname}");
                Console.WriteLine($"3) Rent% \t{singleRoommate.RentPortion}");
                Console.WriteLine($"4) Move In \t{singleRoommate.MoveInDate}");
                Console.WriteLine($"5) Room Id \t{singleRoommate.RoomId}");
                Console.WriteLine($"6) I'm finished");
                choice = getChoice();
                if (choice == 1)
                {
                    Console.WriteLine("Enter a new first name");
                    singleRoommate.Firstname = Console.ReadLine();
                }
                else if (choice == 2)
                {
                    Console.WriteLine("Enter a new last name");
                    singleRoommate.Lastname = Console.ReadLine();
                }
                else if (choice == 3)
                {
                    Console.WriteLine("Enter the new rent protion");
                    do
                    {
                        singleRoommate.RentPortion = getChoice();
                    } while (singleRoommate.RentPortion < 1 || singleRoommate.RentPortion > 100);
                }
                else if (choice == 4)
                {
                    Console.WriteLine("Enter the correct move in date");


                    singleRoommate.MoveInDate = UpdateDate();
                }
                else if (choice == 5)
                {
                    Console.WriteLine("Enter their new room assignment");
                    singleRoommate.RoomId = getChoice();
                }
            } while (choice != 6);

            return(singleRoommate);
        }
コード例 #11
0
        private static void ViewSingleRoommate(RoomRepository roomRepo, RoommateRepository roommateRepo)
        {
            int choice;

            Console.Clear();
            HouseBot();
            Console.WriteLine("Enter the index of the Roommate you'd like to view");
            List <Roommate> allRoommates = roommateRepo.GetAll();

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname}");
            }

            do
            {
                choice = getChoice();
            } while (!allRoommates.Any(rm => rm.Id == choice));


            Roommate singleRoommate = roommateRepo.GetById(choice);

            Console.WriteLine($"{singleRoommate.Firstname} {singleRoommate.Lastname} {singleRoommate.RentPortion} {singleRoommate.MoveInDate}");

            Console.WriteLine("Would you like to view another?");
            string YesNo = getYesNo();

            if (YesNo == "y")
            {
                Console.Clear();
                ViewSingleRoommate(roomRepo, roommateRepo);
            }
            else
            {
                Console.Clear();
                RoommatePage(roomRepo, roommateRepo);
            }
        }
コード例 #12
0
        static void Main(string[] args)
        {
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            ChoreRepository    choreRepo    = new ChoreRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);
            bool runProgram = true;

            while (runProgram)
            {
                string selection = GetMenuSelection();

                switch (selection)
                {
                case ("Show all rooms"):
                    List <Room> rooms = roomRepo.GetAll();
                    foreach (Room r in rooms)
                    {
                        Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})");
                    }
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Search for room"):
                    Console.Write("Room Id: ");
                    int id = int.Parse(Console.ReadLine());

                    Room room = roomRepo.GetById(id);

                    Console.WriteLine($"{room.Id} - {room.Name} Max Occupancy({room.MaxOccupancy})");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a room"):
                    Console.Write("Room name: ");
                    string name = Console.ReadLine();

                    Console.Write("Max occupancy: ");
                    int max = int.Parse(Console.ReadLine());

                    Room roomToAdd = new Room()
                    {
                        Name         = name,
                        MaxOccupancy = max
                    };

                    roomRepo.Insert(roomToAdd);
                    Console.WriteLine($"{roomToAdd.Name} has been added and assigned an Id of {roomToAdd.Id}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Show all chores"):
                    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();
                    break;

                case ("Search for chore"):
                    Console.WriteLine("Chore Id: ");
                    int   choreId = int.Parse(Console.ReadLine());
                    Chore chore   = choreRepo.GetById(choreId);
                    Console.WriteLine($"{chore.Id} - {chore.Name}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a chore"):
                    Console.WriteLine("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();
                    break;

                case ("Search for roommate"):
                    Console.WriteLine("Roommate Id: ");
                    int      roommateId = int.Parse(Console.ReadLine());
                    Roommate roommate   = roommateRepo.GetById(roommateId);
                    Console.WriteLine($"{roommate.Firstname}:");
                    Console.WriteLine($"    Rent Portion:{roommate.RentPortion}");
                    Console.WriteLine($"    Room: {roommate.Room.Name}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Unassigned chores"):
                    List <Chore> unassignedchores = choreRepo.UnassignedChores();
                    foreach (Chore c in unassignedchores)
                    {
                        Console.WriteLine(c.Name);
                    }
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Assign chore to roommate"):
                    List <Chore>    choreList    = choreRepo.GetAll();
                    List <Roommate> roommateList = roommateRepo.GetAll();
                    foreach (Chore c in choreList)
                    {
                        Console.WriteLine($"{c.Id} - {c.Name}");
                    }
                    Console.WriteLine("Please enter the id of the chore.");
                    int   choreIdToAdd = int.Parse(Console.ReadLine());
                    Chore chore1       = choreRepo.GetById(choreIdToAdd);
                    foreach (Roommate r in roommateList)
                    {
                        Console.WriteLine($"{r.Id} - {r.Firstname} {r.Lastname}");
                    }
                    Console.WriteLine("Please enter the id of the roommate.");
                    int      roommateIdToAdd = int.Parse(Console.ReadLine());
                    Roommate roommate1       = roommateRepo.GetById(roommateIdToAdd);
                    choreRepo.assignChore(roommateIdToAdd, choreIdToAdd);
                    Console.WriteLine($"{roommate1.Firstname} {roommate1.Lastname} has been assigned to {chore1.Name}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Update a room"):
                    List <Room> roomOptions = roomRepo.GetAll();
                    foreach (Room r in roomOptions)
                    {
                        Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})");
                    }

                    Console.Write("Which room would you like to update? ");
                    int  selectedRoomId = int.Parse(Console.ReadLine());
                    Room selectedRoom   = roomOptions.FirstOrDefault(r => r.Id == selectedRoomId);

                    Console.Write("New Name: ");
                    selectedRoom.Name = Console.ReadLine();

                    Console.Write("New Max Occupancy: ");
                    selectedRoom.MaxOccupancy = int.Parse(Console.ReadLine());

                    roomRepo.Update(selectedRoom);

                    Console.WriteLine($"Room has been successfully updated");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Delete room"):
                    List <Room> allRooms = roomRepo.GetAll();
                    foreach (Room r in allRooms)
                    {
                        Console.WriteLine($"{r.Id} - {r.Name}");
                    }
                    Console.WriteLine("Selecet the Id of the room to delete.");
                    int roomToDelete = int.Parse(Console.ReadLine());
                    roomRepo.Delete(roomToDelete);
                    break;

                case ("Update a chore"):
                    List <Chore> choreOptions = choreRepo.GetAll();
                    foreach (Chore c in choreOptions)
                    {
                        Console.WriteLine($"{c.Id} - {c.Name}");
                    }
                    Console.WriteLine("Which chore would you like to update?");
                    int   selectedChoreId = int.Parse(Console.ReadLine());
                    Chore selectedChore   = choreOptions.FirstOrDefault(c => c.Id == selectedChoreId);
                    Console.WriteLine("New Name: ");
                    selectedChore.Name = Console.ReadLine();
                    choreRepo.Update(selectedChore);
                    Console.WriteLine("Chore has been successfully updates.");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Delete chore"):
                    List <Chore> allChore = choreRepo.GetAll();
                    foreach (Chore c in allChore)
                    {
                        Console.WriteLine($"{c.Id} - {c.Name}");
                    }
                    Console.WriteLine("Selecet the Id of the chore to delete.");
                    int choreToDelete = int.Parse(Console.ReadLine());
                    choreRepo.Delete(choreToDelete);
                    break;

                case ("Exit"):
                    runProgram = false;
                    break;
                }
            }
        }
コード例 #13
0
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            /*
             * Console.WriteLine("Getting All Rooms:");
             * Console.WriteLine();
             *
             * List<Room> allRooms = roomRepo.GetAll();
             *
             * foreach (Room room in allRooms)
             * {
             *  Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }
             */
            Console.WriteLine("----------------------------");

            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("getting all the roommates");
            Console.WriteLine();
            List <Roommate> allRoommates = roommateRepo.GetAll();

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate} {roommate.Room}");
            }

            /*
             * Console.WriteLine("----------------------------");
             *
             * Console.WriteLine("Getting Room with Id 1");
             *
             * Room singleRoom = roomRepo.GetById(1);
             *
             * Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");
             */

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 1");

            Roommate roommate1 = roommateRepo.GetById(1);

            Console.WriteLine($"{roommate1.Firstname} {roommate1.Lastname} {roommate1.Room}");
            Console.WriteLine("----------------------------");

            // getting roommates based on roomId

            Console.WriteLine("getting all the roommates and all their room info");
            List <Roommate> allRoommatesWithRoom = roommateRepo.GetRoommatesByRoomId(1);

            foreach (Roommate roommateWithRoom in allRoommatesWithRoom)
            {
                Console.WriteLine($"{roommateWithRoom.Id}: {roommateWithRoom.Firstname} {roommateWithRoom.Lastname} is assigned {roommateWithRoom.Room.Name}; \n pays {roommateWithRoom.RentPortion} move-in-date: {roommateWithRoom.MovedInDate}");
            }
            ;
            Console.WriteLine("----------------------------");

            Roommate newRoommate = new Roommate
            {
                Firstname   = "pablo",
                Lastname    = "nuts",
                MovedInDate = new DateTime(2020, 2, 22),
                RentPortion = 12,
                Room        = roomRepo.GetById(1)
            };

            //roommateRepo.Insert(newRoommate);
            //update
            roommateRepo.Update(newRoommate);
            Console.WriteLine($"updated juan to {newRoommate.Firstname}");
            Console.WriteLine("----------------------------");

            roommateRepo.Delete(2);

            /*
             * Room bathroom = new Room
             * {
             *  Name = "Bathroom",
             *  MaxOccupancy = 1
             * };
             *
             * roomRepo.Insert(bathroom);
             *
             */


            /*
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"Added the new Room with id {bathroom.Id}");
             *
             * bathroom.MaxOccupancy = 3;
             *
             * roomRepo.Update(bathroom);
             *
             *
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"updated the room to have max occupancy of {bathroom.MaxOccupancy}");
             */


            /*
             * foreach (Room room in allRooms)
             * {
             *  Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }
             * Console.WriteLine("-------------------------------");
             *
             * roomRepo.Delete(bathroom.Id);
             */
        }
コード例 #14
0
        static void Main(string[] args)
        {
            // <----- Rooms Test Code ----->

            /*RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);
             *
             * Console.WriteLine("Getting All Rooms:");
             * Console.WriteLine();
             *
             * List<Room> allRooms = roomRepo.GetAll();
             *
             * foreach (Room room in allRooms)
             * {
             *  Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }
             *
             * Console.WriteLine("----------------------------");
             * Console.WriteLine("Getting Room with Id 1");
             *
             * Room singleRoom = roomRepo.GetById(1);
             *
             * Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");
             *
             * Room bathroom = new Room
             * {
             *  Name = "Bathroom",
             *  MaxOccupancy = 1
             * };
             *
             *
             * roomRepo.Insert(bathroom);
             *
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"Added the new Room with id {bathroom.Id}");
             *
             * bathroom.MaxOccupancy = 2;
             *
             * roomRepo.Update(bathroom);
             *
             * Console.WriteLine("-------------------------------");
             *
             * allRooms = roomRepo.GetAll();
             *
             * foreach (Room room in allRooms)
             * {
             *  Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }
             *
             * roomRepo.Delete(8);
             *
             * Console.WriteLine("-------------------------------");
             *
             * allRooms = roomRepo.GetAll();
             *
             * foreach (Room room in allRooms)
             * {
             *  Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }*/

            // <----- Roommates Test Code ----->

            /*RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);
             *
             * Console.WriteLine("Getting All Roommates:");
             * Console.WriteLine();
             *
             * List<Roommate> allRoommates = roommateRepo.GetAll();
             *
             * foreach (Roommate roommate in allRoommates)
             * {
             *  Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate} {roommate.Room}");
             * }
             *
             * Console.WriteLine("----------------------------");
             * Console.WriteLine("Getting Roommate with Id 1");
             *
             * Roommate aRoommate = roommateRepo.GetById(1);
             *
             * Console.WriteLine($"{aRoommate.Id} {aRoommate.Firstname} {aRoommate.Lastname} {aRoommate.RentPortion} {aRoommate.MovedInDate} {aRoommate.Room}");
             *
             * Console.WriteLine("----------------------------");
             * Console.WriteLine("Getting Roommates with roomId 1");
             *
             * List<Roommate> allRoommatesWithRoomId = roommateRepo.GetRoommmatesByRoomId(1);
             *
             * foreach (Roommate roommate in allRoommatesWithRoomId)
             * {
             *  Console.WriteLine($"{roommate.Firstname} {roommate.Lastname} {roommate.Room.Name}");
             * }
             *
             * Roommate newRoommate = new Roommate
             * {
             *  Firstname = "Jimmy",
             *  Lastname = "Rocket",
             *  RentPortion = 2,
             *  MovedInDate = DateTime.Now,
             *  RoomId = 1
             * };
             *
             * roommateRepo.Insert(newRoommate);
             *
             * newRoommate.RentPortion = 10;
             *
             * roommateRepo.Update(newRoommate);
             *
             * roommateRepo.Delete(5);*/

            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("Welcome to Roommates!");
            Console.WriteLine("Please select an option from the menu below:");
            Console.WriteLine("(1) View all roommates (2) View specific roommate by Id (3) Add a new roommate ");

            int userResponse = Int32.Parse(Console.ReadLine());

            switch (userResponse)
            {
            case 1:
                List <Roommate> listOfRoommates = roommateRepo.GetAll();
                foreach (Roommate roommate in listOfRoommates)
                {
                    Console.WriteLine($"Id: {roommate.Id} Name: {roommate.Firstname} {roommate.Lastname}");
                }
                ;
                break;

            case 2:
                Console.Write("Enter a roommate Id: ");
                int      res           = Int32.Parse(Console.ReadLine());
                Roommate foundRoommate = roommateRepo.GetById(res);
                Console.WriteLine($"Name: {foundRoommate.Firstname} {foundRoommate.Lastname} Moved In Date: {foundRoommate.MovedInDate}");
                break;

            case 3:
                Console.Write("Enter first name: ");
                string firstName = Console.ReadLine();
                Console.Write("Enter last name: ");
                string lastName = Console.ReadLine();
                Console.Write("Enter rent portion: ");
                int rentPortion = Int32.Parse(Console.ReadLine());
                Console.Write("Moved in date: ");
                DateTime movedInDate = DateTime.Parse(Console.ReadLine());
                Console.Write("Enter room id: ");
                int      roomId      = Int32.Parse(Console.ReadLine());
                Roommate newRoommate = new Roommate
                {
                    Firstname   = firstName,
                    Lastname    = lastName,
                    RentPortion = rentPortion,
                    MovedInDate = movedInDate,
                    RoomId      = roomId
                };
                roommateRepo.Insert(newRoommate);
                Console.WriteLine($"{firstName} {lastName} was successfully added!");
                break;
            }
        }
コード例 #15
0
        static void Main(string[] args)
        {
            //RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            //Console.WriteLine("Getting All Rooms:");
            //Console.WriteLine();

            //List<Room> allRooms = roomRepo.GetAll();

            //foreach (Room room in allRooms)
            //{
            //    Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            //}

            //Console.WriteLine("----------------------------");
            //Console.WriteLine("Getting Room with Id 1");

            //Room singleRoom = roomRepo.GetById(1);

            //Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            //Room bathroom = new Room
            //{
            //    Name = "Bathroom",
            //    MaxOccupancy = 1
            //};

            //roomRepo.Delete(11);

            //roomRepo.Insert(bathroom);

            //Console.WriteLine("-------------------------------");
            //Console.WriteLine($"Added the new Room with id {bathroom.Id}");

            //Room updatedBathroom = new Room
            //{
            //    Id = 7,
            //    Name = "Bathroom",
            //    MaxOccupancy = 2
            //};

            //roomRepo.Update(updatedBathroom);

            //RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            //Console.WriteLine("Getting all roommates: ");

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

            //foreach(Roommate rm in roommates)
            //{
            //    Console.WriteLine(@$"
            //        Id: {rm.Id}
            //        {rm.Firstname} {rm.Lastname}
            //        Rent Portion: {rm.RentPortion}
            //        Move In Date: {rm.MovedInDate}
            //    ");
            //}

            //Roommate id1 = roommateRepo.GetById(1);

            //Console.WriteLine(@$"
            //        {id1.Firstname} {id1.Lastname}
            //        Rent Portion: {id1.RentPortion}
            //        Move In Date: {id1.MovedInDate}
            //    ");

            //List<Roommate> roommates = roommateRepo.GetAllWithRoom();

            //foreach (Roommate rm in roommates)
            //{
            //    Console.WriteLine(@$"
            //        Id: {rm.Id}
            //        {rm.Firstname} {rm.Lastname}
            //        Rent Portion: {rm.RentPortion}
            //        Move In Date: {rm.MovedInDate}
            //        Room: {rm.Room.Name}
            //    ");
            //}

            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            bool app = true;

            while (app == true)
            {
                int choice = -1;

                List <int> allRoomIds     = roomRepo.GetAllIds();
                List <int> allRoommateIds = roommateRepo.GetAllIds();

                while (true)
                {
                    Console.WriteLine(@"
                Welcome to Chore Manager!
                -------------------------
                Select an option:
                0 List all rooms
                1 List room by Id
                2 Add a room
                3 Delete a room
                4 Edit a room
                5 List all roommates
                6 List roommate by Id
                7 Add a roommate
                8 Edit a roommate
                9 Delete a roommate
                ");

                    string resp = Console.ReadLine();

                    if (resp == "")
                    {
                        app = false;
                        break;
                    }
                    else
                    {
                        bool allowed = int.TryParse(resp, out choice);

                        if (allowed && choice >= 0 && choice < 10)
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Not a valid choice.");
                        }
                    }
                }

                switch (choice)
                {
                case 0:
                    List <Room> allRooms = roomRepo.GetAll();
                    foreach (Room room in allRooms)
                    {
                        Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
                    }
                    break;

                case 1:
                    int roomId = -1;
                    while (true)
                    {
                        Console.WriteLine("Input Room Id: ");
                        bool allowed = int.TryParse(Console.ReadLine(), out roomId);
                        if (allowed && allRoomIds.Contains(roomId))
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Invalid Id. Choice is not an interger or Id does not exist.");
                        }
                    }
                    Console.WriteLine($"Getting Room with Id {roomId}");
                    Room singleRoom = roomRepo.GetById(roomId);
                    Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");
                    break;

                case 2:
                    Console.WriteLine("Room name:");
                    string roomName = Console.ReadLine();
                    int    maxOcc   = -1;
                    while (true)
                    {
                        Console.WriteLine("Maximum occupancy: ");
                        bool allowed = int.TryParse(Console.ReadLine(), out maxOcc);
                        if (allowed && maxOcc > 0)
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Value must be a postive number");
                        }
                    }
                    Room newRoom = new Room
                    {
                        Name         = roomName,
                        MaxOccupancy = maxOcc
                    };
                    roomRepo.Insert(newRoom);
                    Console.WriteLine($"Added {newRoom.Name} with id {newRoom.Id}");
                    break;

                case 3:
                    int roomToDelete = -1;
                    while (true)
                    {
                        Console.WriteLine("Input Id of room to be deleted: ");
                        string response = Console.ReadLine();
                        if (response == "")
                        {
                            break;
                        }
                        else
                        {
                            bool allowed = int.TryParse(response, out roomToDelete);
                            if (allowed && allRoomIds.Contains(roomToDelete))
                            {
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Room does not exist. Please enter a valid room Id.");
                            }
                        }
                    }
                    if (roomToDelete == -1)
                    {
                        break;
                    }
                    else
                    {
                        roomRepo.Delete(roomToDelete);
                        Console.WriteLine($"Deleted room with Id {roomToDelete}");
                        break;
                    }

                case 4:
                    int roomToEditId = -1;
                    while (true)
                    {
                        Console.WriteLine("Enter Id of room to edit");
                        bool allowed = int.TryParse(Console.ReadLine(), out roomToEditId);
                        if (allowed && allRoomIds.Contains(roomToEditId))
                        {
                            Room roomToEdit = roomRepo.GetById(roomToEditId);
                            Console.WriteLine($"{roomToEdit.Id} {roomToEdit.Name} {roomToEdit.MaxOccupancy}");
                            Console.WriteLine("Room name: ");
                            string newName = Console.ReadLine();
                            if (newName == "")
                            {
                                newName = roomToEdit.Name;
                            }
                            int newOcc = -1;
                            while (true)
                            {
                                Console.WriteLine("Max occupancy: ");
                                bool permitted = int.TryParse(Console.ReadLine(), out newOcc);
                                if (permitted && newOcc > 0)
                                {
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Value must be a number > 0.");
                                }
                            }

                            Room editedRoom = new Room {
                            };
                            editedRoom.Id           = roomToEditId;
                            editedRoom.Name         = newName;
                            editedRoom.MaxOccupancy = newOcc;
                            roomRepo.Update(editedRoom);
                            Console.WriteLine($"Edited room: {editedRoom.Id} {editedRoom.Name} {editedRoom.MaxOccupancy}");
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Room Id invalid. Please enter a valid Id.");
                        }
                    }
                    break;

                case 5:
                    List <Roommate> allRoommates = roommateRepo.GetAllWithRoom();
                    foreach (Roommate rm in allRoommates)
                    {
                        Console.WriteLine(@$ "
                                Id: {rm.Id}
                                {rm.Firstname} {rm.Lastname}
                                Rent Portion: {rm.RentPortion}
                                Move In Date: {rm.MovedInDate}
                            ");
                    }
                    break;

                case 6:
                    int roommateId = -1;
                    while (true)
                    {
                        Console.WriteLine("Input Roommate Id: ");
                        bool allowed = int.TryParse(Console.ReadLine(), out roommateId);
                        if (allowed && allRoommateIds.Contains(roommateId))
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Invalid Id. Choice is not an interger or Id does not exist.");
                        }
                    }
                    Console.WriteLine($"Getting Roommate with Id {roommateId}");
                    Roommate singleRoommate = roommateRepo.GetById(roommateId);
                    Console.WriteLine(@$ "
                                {singleRoommate.Firstname} {singleRoommate.Lastname}
                                Rent Portion: {singleRoommate.RentPortion}
                                Move In Date: {singleRoommate.MovedInDate},
                                Room: {singleRoommate.Room.Name}
                            ");
                    break;
コード例 #16
0
ファイル: Program.cs プロジェクト: TKomrij/Roommate
        static void Main(string[] args)
        {
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            ChoreRepository    choreRepo    = new ChoreRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);
            bool runProgram = true;

            while (runProgram)
            {
                string selection = GetMenuSelection();

                switch (selection)
                {
                case ("Show all rooms"):
                    List <Room> rooms = roomRepo.GetAll();
                    foreach (Room r in rooms)
                    {
                        Console.WriteLine($"{r.Name} has an Id of {r.Id} and a max occupancy of {r.MaxOccupancy}");
                    }
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Search for room"):
                    Console.Write("Room Id: ");
                    int id = int.Parse(Console.ReadLine());

                    Room room = roomRepo.GetById(id);

                    Console.WriteLine($"{room.Id} - {room.Name} Max Occupancy({room.MaxOccupancy})");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a room"):
                    Console.Write("Room name: ");
                    string name = Console.ReadLine();

                    Console.Write("Max occupancy: ");
                    int max = int.Parse(Console.ReadLine());

                    Room roomToAdd = new Room()
                    {
                        Name         = name,
                        MaxOccupancy = max
                    };

                    roomRepo.Insert(roomToAdd);

                    Console.WriteLine($"{roomToAdd.Name} has been added and assigned an Id of {roomToAdd.Id}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Show all chores"):
                    List <Chore> chores = choreRepo.GetAll();
                    foreach (Chore c in chores)
                    {
                        Console.WriteLine($"{c.Name} has an Id of {c.Id}");
                    }
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a chore"):
                    Console.Write("Chore name: ");
                    string choreName = Console.ReadLine();

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

                    choreRepo.Insert(choreToAdd);
                    break;

                case ("Search for roommate"):
                    Console.Write("Roommate Id: ");
                    int Roommateid = int.Parse(Console.ReadLine());

                    Roommate roommate = roommateRepo.GetById(Roommateid);

                    Console.WriteLine($"Name: {roommate.FirstName}, Rent Portion: {roommate.RentPortion}%, Room: {roommate.RoomName}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Exit"):
                    runProgram = false;
                    break;
                }
            }
        }
コード例 #17
0
        static void Main(string[] args)
        {
            // ROOM CALLS
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            // GET ALL ROOMS
            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            // GET ROOM BY ID
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");
            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            // CREATE NEW ROOM
            Room bathroom = new Room
            {
                Name         = "Bathroom",
                MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);
            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id}");

            // UPDATE ROOM
            bathroom.MaxOccupancy = 3;
            roomRepo.Update(bathroom);
            Room bathroomFromDb = roomRepo.GetById(bathroom.Id);

            Console.WriteLine($"{bathroomFromDb.Id} {bathroomFromDb.Name} {bathroomFromDb.MaxOccupancy}");

            //DELETE ROOM
            Console.WriteLine("-------------------------------");
            roomRepo.Delete(bathroom.Id);
            allRooms = roomRepo.GetAll();
            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }


            // ROOMMATE CALLS
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            // GET ALL ROOMMATES
            Console.WriteLine("Getting All Roommates:");
            Console.WriteLine();

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

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id}. {roommate.FirstName} {roommate.LastName} moved in on {roommate.MoveInDate} and pays {roommate.RentPortion} per month");
            }

            // GET ROOMMATE BY ID
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 1");
            Roommate singleRoommate = roommateRepo.GetById(1);

            Console.WriteLine($"{singleRoommate.Id}. {singleRoommate.FirstName} {singleRoommate.LastName}");

            // GET ROOMMATE WITH ROOM
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommates with Room");
            List <Roommate> roommatesRooms = roommateRepo.GetAllWithRoom(5);

            foreach (Roommate roommate in roommatesRooms)
            {
                Console.WriteLine($"{roommate.Id}. {roommate.FirstName} {roommate.LastName} lives in room {roommate.Room.Id}");
            }

            // CREATE NEW ROOMMATE
            Roommate rick = new Roommate
            {
                FirstName   = "Big",
                LastName    = "Rick",
                RentPortion = 10,
                MoveInDate  = DateTime.Now,
                Room        = roomRepo.GetById(4)
            };

            roommateRepo.Insert(rick);
            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Roommate with id {rick.Id}");

            // UPDATE ROOMMATE
            rick.LastName = "Ricky";
            roommateRepo.Update(rick);

            Roommate rickFromDb = roommateRepo.GetById(rick.Id);

            Console.WriteLine($"{rickFromDb.Id}. {rickFromDb.FirstName} {rickFromDb.LastName}");

            //DELETE ROOMMATE
            Console.WriteLine("-------------------------------");
            roommateRepo.Delete(4);

            allRoommates = roommateRepo.GetAll();

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id}. {roommate.FirstName} {roommate.LastName}");
            }
        }
コード例 #18
0
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            //Create
            //Room bathroom = new Room
            //{
            //    Name = "Bathroom",
            //    MaxOccupancy = 1
            //};

            //roomRepo.Insert(bathroom);

            //Console.WriteLine("-------------------------------");
            //Console.WriteLine($"Added the new Room with id {bathroom.Id}");

            //Update
            //Room bathroomUpdate = roomRepo.GetById(7);
            //bathroomUpdate.MaxOccupancy = 2;

            //roomRepo.Update(bathroomUpdate);

            //Delete
            //roomRepo.Delete(8);

            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");

            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");


            //ROOMMATE


            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            //Roommate test = new Roommate()
            //{
            //    FirstName = "Chris",
            //    LastName = "Test",
            //    RentPortion = 100,
            //    MoveInDate = DateTime.Now,
            //    Room = singleRoom
            //};

            //roommateRepo.Insert(test);


            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 1");

            Roommate singleRoommate = roommateRepo.GetById(1);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.FirstName} {singleRoommate.LastName} {singleRoommate.RentPortion} {singleRoommate.MoveInDate}");

            singleRoommate.LastName = "Test3";
            Console.WriteLine($"{singleRoommate.LastName} {singleRoommate.Room.Id}");
            //roommateRepo.Update(singleRoommate);

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting All Roommates:");
            Console.WriteLine();

            List <Roommate> allRoommates = roommateRepo.GetAllWithRoom();

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.FirstName} {roommate.LastName} {roommate.RentPortion} {roommate.MoveInDate} {roommate.Room.Id} {roommate.Room.Name}");
            }

            //roommateRepo.Delete(4);
        }
コード例 #19
0
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            //GET ALL ROOMS
            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            //GET SINGLE ROOM ENTRY
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");
            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");



            //ADD ROOM ENTRY
            Room bathroom = new Room
            {
                Name         = "Bathroom",
                MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id} named {bathroom.Name} that holds {bathroom.MaxOccupancy} people");


            //UPDATE object above"bathroom" on the property "maxoccupancy" and set it equal to "3"...
            bathroom.MaxOccupancy = 3;
            roomRepo.Update(bathroom);
            //get it from database
            Room bathroomFromDB = roomRepo.GetById(bathroom.Id);

            //..then see it on the console
            Console.WriteLine($"{bathroomFromDB.Id} {bathroomFromDB.Name} {bathroomFromDB.MaxOccupancy}");


            //DELETE ROOM ENTRY BY ID
            roomRepo.Delete(bathroom.Id);
            //get all rooms and loop through them to show its deleted by delting the SQL assigned id of the entry
            allRooms = roomRepo.GetAll();
            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }



            /*ROOMMATE TABLE QUERIES
             *************************************************************************************************8
             * ROOMMATE TABLE QUERIES */

            //creates new connection to roommate Repo
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            // GET ALL ROOMMATES
            Console.WriteLine("Getting All Roommates:");
            Console.WriteLine();

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

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Lastname}, {roommate.Firstname}");
            }


            //GET SINGLE Roommate ENTRY
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 1");
            Roommate singleRoommate = roommateRepo.GetById(1);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.Firstname}, {singleRoommate.Lastname} paid {singleRoommate.RentPortion} in the {singleRoommate.Room.Name}");


            // GET ROOMmates BY roomId
            Console.WriteLine("Getting All Roommates");
            Console.WriteLine();

            List <Roommate> roommatesByRoomId = roommateRepo.GetRoommatesByRoomId(1);

            foreach (Roommate roommate in roommatesByRoomId)
            {
                Console.WriteLine($"omgz, {roommate.Id} {roommate.Lastname}, {roommate.Firstname}");
            }


            //ADD ENTRY
            //Created a new room to palce the new roommate,
            // OPTION 2: could fetch a room by using a .GetById method
            //Room singleRoom = roomRepo.GetById(1);
            //USED singleRoom that was declared above to be my object represntation that is passed through as an argument to my roommate as the room property
            Room myRoom = new Room
            {
                Name         = "YourRoom",
                MaxOccupancy = 2,
            };

            roomRepo.Insert(myRoom);
            Console.WriteLine($"Look {myRoom.Name} exists as a room");
            Roommate bestest = new Roommate
            {
                Firstname   = "Wife",
                Lastname    = "#1",
                RentPortion = 50,
                MoveInDate  = new DateTime(2011, 11, 11),
                //DateTime.Now.AddDays(-1);
                Room = singleRoom,
            };


            roommateRepo.Insert(bestest);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Roommate id number {bestest.Id} / name: {bestest.Firstname} {bestest.Lastname} / MoveIn: {bestest.MoveInDate} {bestest.Room.Name}");



            //UPDATE object above "bestest roommate" on the property "last name" and set it equal to "#2"...

            bestest.Lastname = "#2";
            roommateRepo.Update(bestest);
            //get it from database
            Roommate bestestFromDB = roommateRepo.GetById(bestest.Id);

            //..then see it on the console
            Console.WriteLine($"{bestestFromDB.Id} {bestestFromDB.Firstname} {bestestFromDB.Lastname}");


            // DELETE ROOMMATE ENTRY BY ID
            roommateRepo.Delete(bestest.Id);
            //get all roommatess and loop through them to show its deleted by delting the SQL assigned id of the entry
            allRoommates = roommateRepo.GetAll();
            foreach (Roommate roommates in allRoommates)
            {
                Console.WriteLine($"{roommates.Id} {roommates.Lastname} {roommates.Firstname}");
            }
        }
コード例 #20
0
        static void Main(string[] args)
        {
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            ChoreRepository    choreRepo    = new ChoreRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            bool runProgram = true;

            while (runProgram)
            {
                string selection = GetMenuSelection();

                switch (selection)
                {
                //room case commands
                case ("Show all rooms"):
                    List <Room> rooms = roomRepo.GetAll();
                    foreach (Room r in rooms)
                    {
                        Console.WriteLine($"{r.Name} has an Id of {r.Id} and a max occupancy of {r.MaxOccupancy}");
                    }
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Search for room"):
                    Console.Write("Room Id: ");
                    int id = int.Parse(Console.ReadLine());

                    Room room = roomRepo.GetById(id);

                    Console.WriteLine($"{room.Id} - {room.Name} Max Occupancy({room.MaxOccupancy})");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a room"):
                    Console.Write("Room name: ");
                    string name = Console.ReadLine();

                    Console.Write("Max occupancy: ");
                    int max = int.Parse(Console.ReadLine());

                    Room roomToAdd = new Room()
                    {
                        Name         = name,
                        MaxOccupancy = max
                    };

                    roomRepo.Insert(roomToAdd);

                    Console.WriteLine($"{roomToAdd.Name} has been added and assigned an Id of {roomToAdd.Id}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Update a room"):
                    List <Room> roomOptions = roomRepo.GetAll();
                    foreach (Room r in roomOptions)
                    {
                        Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})");
                    }

                    Console.Write("Which room would you like to update? ");
                    int  selectedRoomId = int.Parse(Console.ReadLine());
                    Room selectedRoom   = roomOptions.FirstOrDefault(r => r.Id == selectedRoomId);

                    Console.Write("New Name: ");
                    selectedRoom.Name = Console.ReadLine();

                    Console.Write("New Max Occupancy: ");
                    selectedRoom.MaxOccupancy = int.Parse(Console.ReadLine());

                    roomRepo.Update(selectedRoom);

                    Console.WriteLine($"Room has been successfully updated");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Delete a room"):
                    List <Room> deleteOptions = roomRepo.GetAll();
                    foreach (Room d in deleteOptions)
                    {
                        Console.WriteLine($"{d.Id} - {d.Name} Max Occupancy({d.MaxOccupancy})");
                    }
                    Console.WriteLine("Please note you may not delete a room if people are living in it");
                    Console.Write("Which empty room would you like to delete?");
                    int  deletedRoomId = int.Parse(Console.ReadLine());
                    Room deletedRoom   = deleteOptions.FirstOrDefault(d => d.Id == deletedRoomId);

                    roomRepo.Delete(deletedRoomId);

                    Console.WriteLine($"Room has been successful deleted");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;


                //chore case commands
                case ("Show all chores"):
                    List <Chore> chores = choreRepo.GetAll();
                    foreach (Chore c in chores)
                    {
                        Console.WriteLine($"{c.Name} has an Id of {c.Id}");
                    }
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Search for chore"):
                    Console.Write("Chore Id: ");
                    int choreId = int.Parse(Console.ReadLine());

                    Chore chore = choreRepo.GetById(choreId);

                    Console.WriteLine($"{chore.Id} - {chore.Name}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a chore"):
                    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();
                    break;

                case ("Update a chore"):
                    List <Chore> choreOptions = choreRepo.GetAll();
                    foreach (Chore c in choreOptions)
                    {
                        Console.WriteLine($"{c.Id} - {c.Name}");
                    }

                    Console.Write("Which chore would you like to update? ");
                    int   selectedChoreId = int.Parse(Console.ReadLine());
                    Chore selectedChore   = choreOptions.FirstOrDefault(c => c.Id == selectedChoreId);

                    Console.Write("New Name: ");
                    selectedChore.Name = Console.ReadLine();

                    choreRepo.Update(selectedChore);

                    Console.WriteLine("Chore has been successfully updated");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Delete a chore"):
                    List <Chore> deleteChores = choreRepo.GetAll();
                    foreach (Chore d in deleteChores)
                    {
                        Console.WriteLine($"{d.Id} - {d.Name}");
                    }
                    Console.Write("Which chore would you like to delete?");
                    int   deletedChoreId = int.Parse(Console.ReadLine());
                    Chore deletedChore   = deleteChores.FirstOrDefault(d => d.Id == deletedChoreId);

                    choreRepo.Delete(deletedChoreId);

                    Console.WriteLine("Chore has been successful deleted");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                //select a roommate by id

                case ("Search for roommate"):
                    Console.Write("Roommate Id: ");
                    int roommateId = int.Parse(Console.ReadLine());

                    Roommate roommate = roommateRepo.GetById(roommateId);

                    Console.WriteLine($"{roommate.Id} - {roommate.FirstName} {roommate.LastName} pays {roommate.RentPortion}% of the rent. They live in {roommate.Room.Name}.");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;



                case ("Exit"):
                    runProgram = false;
                    break;
                }
            }
        }
コード例 #21
0
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            //returning list of rooms
            List <Room> allRooms = roomRepo.GetAll();

            //looping over room list and printing them all out
            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }


            //calling getbyID method to print out the results
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");

            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            Room bathroom = new Room
            {
                Name         = "Bathroom",
                MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id}");

            bathroom.MaxOccupancy = 3;
            roomRepo.Update(bathroom);

            Room bathroomFromDb = roomRepo.GetById(bathroom.Id);

            Console.WriteLine($"{bathroomFromDb.Id} {bathroomFromDb.Name} {bathroomFromDb.MaxOccupancy}");
            Console.WriteLine("-------------------------------");

            roomRepo.Delete(bathroom.Id);

            allRooms = roomRepo.GetAll();
            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }
            ////////////////Roommate///////////////////////

            ///////////Getting All Roommates w/o Room//////
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Roommates:");
            Console.WriteLine();

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

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.FirstName} {roommate.LastName} {roommate.RentPortion} {roommate.MoveInDate}");
            }
            ///////////Getting One Single Roommate by Id //////

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roomate with Id 1");

            Roommate singleRoommate = roommateRepo.GetById(1);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.FirstName} {singleRoommate.LastName} {singleRoommate.RentPortion} {singleRoommate.MoveInDate}");

            ///////////Getting All Rooms with Room Object Attatched //////
            RoommateRepository roommateRoomRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Roommates with Room:");
            Console.WriteLine();

            List <Roommate> allRoommateswithRoom = roommateRoomRepo.GetAllWithRoom(2);

            foreach (Roommate roommateWithRoom in allRoommateswithRoom)
            {
                Console.WriteLine($"{roommateWithRoom.Id} {roommateWithRoom.FirstName} {roommateWithRoom.LastName} {roommateWithRoom.RentPortion} {roommateWithRoom.MoveInDate} {roommateWithRoom.Room.Name} {roommateWithRoom.Room.MaxOccupancy}");
            }


            ///////////Adding in New Roommate //////
            Roommate newRoommate = new Roommate
            {
                FirstName   = "Wendy",
                LastName    = "Jones",
                MoveInDate  = DateTime.Now.AddDays(-1),
                RoomId      = 1,
                RentPortion = 10
            };

            roommateRepo.Insert(newRoommate);


            ///////////Updating Roommate //////
            newRoommate.LastName = "Smith";

            roommateRepo.Update(newRoommate);

            allRoommates = roommateRepo.GetAll();
            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} First Name : {roommate.FirstName} Last Name: {roommate.LastName} Rent Portion: {roommate.RentPortion} Date Moved In : {roommate.MoveInDate}");
            }
            Console.WriteLine("-----------------------------------------");

            ///////////Deleting Roommate ///////////
            roommateRepo.Delete(newRoommate.Id);

            allRoommates = roommateRepo.GetAll();
            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} First Name : {roommate.FirstName} Last Name: {roommate.LastName} Rent Portion: {roommate.RentPortion} Date Moved In : {roommate.MoveInDate}");
            }
        }
コード例 #22
0
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            Console.WriteLine("----------------------------");
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Roommatess:");
            Console.WriteLine();

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

            foreach (Roommate roommate in allRoommatess)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} lives in {roommate.Room.Name}");
            }

            Console.WriteLine("----------------------------");
            Console.WriteLine("roomate with id of 1");

            Roommate singleRoommate = roommateRepo.GetById(1);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.Firstname} {singleRoommate.Lastname} lives in {singleRoommate.Room.Name}");



            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");

            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            Room bathroom = new Room
            {
                Name         = "Bathroom",
                MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id}");


            Room UpdatedRoom = new Room
            {
                Name         = "Attic",
                MaxOccupancy = 1,
                Id           = 5
            };

            roomRepo.Update(UpdatedRoom);

            roomRepo.Delete(9);
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: midlantica/Zoom-mates
        static void Main(string[] args)
        {
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();
            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            // >> Roommates
            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();
            List <Roommate> allRoommates = roommateRepo.GetAll();

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.FirstName} {roommate.LastName} {roommate.RentPortion}");
            }

            // Getting Room with Id 1
            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");
            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");


            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 1");
            Roommate singleRoommate = roommateRepo.GetById(1);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.FirstName} {singleRoommate.LastName} {singleRoommate.RentPortion}");


            // INSERT ROOM
            Room bathroom = new Room {
                Name = "Bathroom", MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);
            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id}");

            // INSERT ROOMATE
            // INSERT ROOMATE
            // INSERT ROOMATE
            string userTypedFirstName   = Console.ReadLine();
            string userTypedLastName    = Console.ReadLine();
            int    userTypedRentPortion = Int32.Parse(Console.ReadLine());

            // Roomsssssss...
            List <Room> someRooms = roomRepo.GetAll();
            Room        aRoom     = someRooms.First()
                                    // int userTypedRoomId = Int32.Parse(Console.ReadLine());
            ;
            Roommate newRoommate = new Roommate
            {
                FirstName   = userTypedFirstName,
                LastName    = userTypedLastName,
                RentPortion = userTypedRentPortion,
                MoveInDate  = DateTime.Now.AddDays(-1),
                Room        = aRoom
            };

            RoommateRepository.Insert(newRoommate);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {newRoommate.Id}");
            //Console.ReadLine($"First name: {userTypedFirstName}");

            // UPDATE
            new Room
            {
                Name         = "Bathroom2",
                MaxOccupancy = 2
            };
            roomRepo.Update(bathroom);
            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id} 2");


            // DELETE
            roomRepo.Delete(10);
            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Deleted Room with id {bathroom.Id} 3");
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: alexcurnow/Roommates
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            /*Console.WriteLine("----------------------------");
             * Console.WriteLine("Getting Room with Id 1");
             *
             * Room singleRoom = roomRepo.GetById(1);
             *
             * Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");
             *
             * Room bathroom = new Room
             * {
             *  Name = "Bathroom",
             *  MaxOccupancy = 1
             * };
             *
             * roomRepo.Insert(bathroom);
             *
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"Added the new Room with id {bathroom.Id}");
             *
             * bathroom.MaxOccupancy = 3;
             * roomRepo.Update(bathroom);
             *
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"Updated room to have a new occupancy of {bathroom.MaxOccupancy}");
             *
             * roomRepo.Delete(9);
             * roomRepo.Delete(8);
             *
             * allRooms = roomRepo.GetAll();
             *
             * foreach (Room room in allRooms)
             * {
             *  Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }*/

            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine();
            Console.WriteLine("-------------------------------");
            Console.WriteLine("Getting All Roommates:");
            Console.WriteLine();

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

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate}");
            }

            Roommate roommateById = roommateRepo.GetById(1);

            Console.WriteLine();
            Console.WriteLine("Getting a roommate by Id");
            Console.WriteLine($"{roommateById.Id} {roommateById.Firstname} {roommateById.Lastname} {roommateById.RentPortion} {roommateById.MovedInDate}");

            List <Roommate> allRoommatesWithRooms = roommateRepo.GetAllWithRoom();

            Console.WriteLine();
            Console.WriteLine("Getting all roommates with rooms");

            foreach (Roommate roommateWithRoom in allRoommatesWithRooms)
            {
                Console.WriteLine($@"{roommateWithRoom.Id} {roommateWithRoom.Firstname} {roommateWithRoom.Lastname}
                                    {roommateWithRoom.RentPortion} {roommateWithRoom.MovedInDate} // 
                                    {roommateWithRoom.Room.Id} {roommateWithRoom.Room.Name} {roommateWithRoom.Room.MaxOccupancy}");
            }
        }
コード例 #25
0
        static void Main(string[] args)
        {
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            /*
             * Room bathroom = new Room
             * {
             * Name = "Bathroom",
             * MaxOccupancy = 1
             * };
             *
             * roomRepo.Insert(bathroom);
             *
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"Added the new Room with id {bathroom.Id}");
             *
             * singleRoom.MaxOccupancy = 21;
             * roomRepo.Update(singleRoom);
             *
             * Console.WriteLine("----------------------------");
             * Console.WriteLine($"{singleRoom.Name}'s occupancy has been changed to 21.");
             *
             * Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");
             *
             * Roommate roommate1 = new Roommate
             * {
             *  Firstname = "Michael",
             *  Lastname = "Carroll",
             *  RentPortion = 100,
             *  MovedInDate = DateTime.Now,
             *  Room = singleRoom
             * };
             *
             * roommateRepo.Insert(roommate1);
             *
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"Added the new roommate {roommate1.Firstname} {roommate1.Lastname} with id {roommate1.Id} in the {roommate1.Room.Name} for {roommate1.RentPortion} to move in on {roommate1.MovedInDate}.");
             *
             * roomRepo.Delete(8);
             *
             * roommateRepo.Delete(5);
             *
             * singleRoommate.RentPortion = 75;
             * roommateRepo.Update(singleRoommate);
             *
             * Console.WriteLine("----------------------------");
             * Console.WriteLine($"{singleRoommate.Firstname}'s rent portion has been changed to {singleRoommate.RentPortion}.");
             */

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 5");

            Room singleRoom = roomRepo.GetById(5);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 4");

            Roommate singleRoommate = roommateRepo.GetById(4);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.Firstname} {singleRoommate.Lastname} {singleRoommate.RentPortion} {singleRoommate.MovedInDate} {singleRoommate.Room.Name}");

            Console.WriteLine("----------------------------");
            Console.WriteLine($"Getting all roommates in the room.");
            Console.WriteLine();

            List <Roommate> allRoommatesWithRoom = roommateRepo.GetAllWithRoom(5);

            foreach (Roommate roommate in allRoommatesWithRoom)
            {
                Console.WriteLine(@$ "
                Name: {roommate.Firstname} {roommate.Lastname}, 
コード例 #26
0
ファイル: Program.cs プロジェクト: laceywalkerr/ControlFlow
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");

            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            Room bathroom = new Room
            {
                Name         = "Bathroom",
                MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id}");
            Console.WriteLine("-------------------------------");

            bathroom.MaxOccupancy = 3;
            roomRepo.Update(bathroom);
            Room bathroomFromDb = roomRepo.GetById(bathroom.Id);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            Console.WriteLine("-------------------------------");
            roomRepo.Delete(bathroom.Id);

            allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            RoommateRepository roommateRepository = new RoommateRepository(CONNECTION_STRING);

            Roommate aRoommate = roommateRepository.GetById(2);

            Console.WriteLine($"{aRoommate.Firstname} {aRoommate.Lastname}");

            /*Roommate another = roommateRepository.GetById(999);
             * Console.WriteLine($"{another.Firstname} {another.Lastname}");*/

            Roommate newRoommate = new Roommate()
            {
                Firstname   = "Sadie",
                Lastname    = "Bean",
                MovedInDate = DateTime.Now.AddDays(-1),
                RoomId      = 1,
                RentPortion = 10
            };

            roommateRepository.Insert(newRoommate);
        }
コード例 #27
0
        static void Main(string[] args)
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Rooms:");
            Console.WriteLine();

            List <Room> allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Room with Id 1");

            Room singleRoom = roomRepo.GetById(1);

            Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            Room bathroom = new Room
            {
                Name         = "Bathroom",
                MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Room with id {bathroom.Id}");

            bathroom.MaxOccupancy = 3;
            roomRepo.Update(bathroom);

            Room bathroomFromDb = roomRepo.GetById(bathroom.Id);

            Console.WriteLine($"{bathroomFromDb.Id} {bathroomFromDb.Name} {bathroomFromDb.MaxOccupancy}");
            Console.WriteLine("-------------------------------");
            roomRepo.Delete(bathroom.Id);

            allRooms = roomRepo.GetAll();

            foreach (Room room in allRooms)
            {
                Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            }
            Console.WriteLine("-------------------------------");

            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.WriteLine("Getting All Roommates:");
            Console.WriteLine();

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

            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} rent: {roommate.RentPortion}%, date moved in: {roommate.MovedInDate}");
            }
            ;

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting Roommate with Id 1");

            Roommate singleRoommate = roommateRepo.GetById(1);

            Console.WriteLine($"{singleRoommate.Id} {singleRoommate.Firstname} {singleRoommate.Lastname} rent: {singleRoommate.RentPortion}%, date moved in: {singleRoommate.MovedInDate}");

            Console.WriteLine("----------------------------");
            Console.WriteLine("Getting All Roommates with Room:");
            Console.WriteLine();

            List <Roommate> allRoommatesWithRoom = roommateRepo.GetAllWithRoom(1);

            foreach (Roommate roommate in allRoommatesWithRoom)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} rent: {roommate.RentPortion}%, date moved in: {roommate.MovedInDate}");
            }
            ;

            Roommate newRoomate = new Roommate
            {
                Firstname   = "Lacey",
                Lastname    = "Walker",
                RentPortion = 15,
                MovedInDate = new DateTime(2020, 12, 07),
                Room        = allRooms[2]
            };

            roommateRepo.Insert(newRoomate);

            Console.WriteLine("-------------------------------");
            Console.WriteLine($"Added the new Roommate with id {newRoomate.Id}");


            newRoomate.RentPortion = 20;
            roommateRepo.Update(newRoomate);
            allRoommates = roommateRepo.GetAll();
            Console.WriteLine("-----------------------------------------");
            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} rent: {roommate.RentPortion}%, date moved in: {roommate.MovedInDate}");
            }

            roommateRepo.Delete(newRoomate.Id);
            allRoommates = roommateRepo.GetAll();
            Console.WriteLine("-----------------------------------------");
            foreach (Roommate roommate in allRoommates)
            {
                Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} rent: {roommate.RentPortion}%, date moved in: {roommate.MovedInDate}");
            }
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: durrjp/RoommatesExercise
        static void Main(string[] args)
        {
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);
            ChoreRepository    choreRepo    = new ChoreRepository(CONNECTION_STRING);
            RoommateChoreRepo  rcRepo       = new RoommateChoreRepo(CONNECTION_STRING);

            //Console.WriteLine("Getting All Rooms:");
            //Console.WriteLine();

            //List<Room> allRooms = roomRepo.GetAll();

            //foreach (Room room in allRooms)
            //{
            //    Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
            //}

            //Console.WriteLine("----------------------------");
            //Console.WriteLine("Getting Room with Id 1");

            //Room singleRoom = roomRepo.GetById(1);

            //Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");

            //Room bathroom = new Room
            //{
            //    Name = "Bathroom",
            //    MaxOccupancy = 1
            //};

            //roomRepo.Insert(bathroom);

            //Console.WriteLine("-------------------------------");
            //Console.WriteLine($"Added the new Room with id {bathroom.Id}");

            //Room washroom = new Room
            //{
            //    Id = 7,
            //    Name = "Washroom",
            //    MaxOccupancy = 2
            //};

            //roomRepo.Update(washroom);

            while (true)
            {
                Console.WriteLine();
                int selection = Menu();
                switch (selection)
                {
                case 1:
                    List <Roommate> allRoommates = roommateRepo.GetAll();

                    foreach (Roommate roommate in allRoommates)
                    {
                        Console.WriteLine(@$ "{roommate.Firstname} {roommate.Lastname} {roommate.RentPortion}
Living in the {roommate.Room.Name}");
                    }
                    break;

                case 2:
                    Console.WriteLine("Enter room id to return who lives in that room");
                    string          roomyRoomString = Console.ReadLine();
                    int             roomyRoomId     = int.Parse(roomyRoomString);
                    List <Roommate> roomies         = roommateRepo.GetAllWithRoom(roomyRoomId);
                    foreach (Roommate roommate in roomies)
                    {
                        Console.WriteLine($"{roommate.Firstname} {roommate.Lastname}");
                    }
                    break;

                case 3:
                    Console.WriteLine("Roommate First Name:");
                    string FirstName = Console.ReadLine();
                    Console.WriteLine("Roommate Last Name:");
                    string LastName = Console.ReadLine();
                    Console.WriteLine("Rent Portion:");
                    string   RentString = Console.ReadLine();
                    int      RentInt    = Int32.Parse(RentString);
                    DateTime todaysDate = DateTime.Now;
                    Console.WriteLine("Room Id:");
                    string   RoomIdString = Console.ReadLine();
                    int      RoomIdInt    = Int32.Parse(RoomIdString);
                    Room     singleRoom   = roomRepo.GetById(RoomIdInt);
                    Roommate newRoomy     = new Roommate()
                    {
                        Firstname   = FirstName,
                        Lastname    = LastName,
                        RentPortion = RentInt,
                        MovedInDate = todaysDate,
                        Room        = singleRoom
                    };
                    roommateRepo.Insert(newRoomy);
                    break;

                case 4:
                    Console.WriteLine("Enter Roommate Id to Update:");
                    string   roomyString   = Console.ReadLine();
                    int      roomyInt      = Int32.Parse(roomyString);
                    Roommate roomyToUpdate = roommateRepo.GetById(roomyInt);

                    Console.WriteLine($"Enter updated roomy First Name from {roomyToUpdate.Firstname}:");
                    string firstName = Console.ReadLine();

                    Console.WriteLine($"Enter updated roomy Last Name from {roomyToUpdate.Lastname}");
                    string lastName = Console.ReadLine();

                    Console.WriteLine($"Update Rent Portion from {roomyToUpdate.RentPortion}");
                    string RentStringed = Console.ReadLine();
                    int    RentInted    = Int32.Parse(RentStringed);

                    Console.WriteLine($"Enter updated room Id from {roomyToUpdate.Room.Id}");
                    string   RoomyIdString    = Console.ReadLine();
                    int      RoomyIdInt       = Int32.Parse(RoomyIdString);
                    Room     updateSingleRoom = roomRepo.GetById(RoomyIdInt);
                    Roommate updatedRoomy     = new Roommate
                    {
                        Firstname   = firstName,
                        Lastname    = lastName,
                        RentPortion = RentInted,
                        MovedInDate = roomyToUpdate.MovedInDate,
                        Room        = updateSingleRoom,
                        Id          = roomyToUpdate.Id
                    };
                    roommateRepo.Update(updatedRoomy);

                    break;

                case 5:
                    Console.WriteLine("Enter Roommate id to kick from the house:");
                    string stringOfRoomyKick = Console.ReadLine();
                    int    intOfRoomyKick    = Int32.Parse(stringOfRoomyKick);
                    roommateRepo.Delete(intOfRoomyKick);
                    break;

                case 6:
                    Console.WriteLine("Enter roommate Id of roomy who needs some chores:");
                    string   rmString  = Console.ReadLine();
                    int      rmInt     = int.Parse(rmString);
                    Roommate lazyRoomy = roommateRepo.GetById(rmInt);

                    Console.WriteLine("Enter the name of the chore to complete");
                    string choreName = Console.ReadLine();
                    Chore  newChore  = new Chore()
                    {
                        Name = choreName
                    };
                    choreRepo.Insert(newChore);
                    Chore choreSelected = choreRepo.GetWithChoreName(newChore.Name);
                    rcRepo.InsertRC(lazyRoomy, choreSelected);
                    break;

                case 0:
                    Console.WriteLine("Goodbye");
                    return;

                default:
                    throw new Exception("Something went wrong...invalid selection");
                }
            }
コード例 #29
0
ファイル: Program.cs プロジェクト: rryb77/Roommates
        static void Main(string[] args)
        {
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            ChoreRepository    choreRepo    = new ChoreRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            bool runProgram = true;

            while (runProgram)
            {
                string selection = GetMenuSelection();

                switch (selection)
                {
                case ("Show all rooms"):
                    List <Room> rooms = roomRepo.GetAll();
                    foreach (Room r in rooms)
                    {
                        Console.WriteLine($"{r.Name} has an Id of {r.Id} and a max occupancy of {r.MaxOccupancy}");
                    }
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Search for room"):
                    Console.Write("Room Id: ");
                    int id = int.Parse(Console.ReadLine());

                    Room room = roomRepo.GetById(id);

                    Console.WriteLine($"{room.Id} - {room.Name} Max Occupancy({room.MaxOccupancy})");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a room"):
                    Console.Write("Room name: ");
                    string name = Console.ReadLine();

                    Console.Write("Max occupancy: ");
                    int max = int.Parse(Console.ReadLine());

                    Room roomToAdd = new Room()
                    {
                        Name         = name,
                        MaxOccupancy = max
                    };

                    roomRepo.Insert(roomToAdd);

                    Console.WriteLine($"{roomToAdd.Name} has been added and assigned an Id of {roomToAdd.Id}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Update a room"):
                    List <Room> roomOptions = roomRepo.GetAll();
                    foreach (Room r in roomOptions)
                    {
                        Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})");
                    }

                    Console.Write("Which room would you like to update? ");
                    int  selectedRoomId = int.Parse(Console.ReadLine());
                    Room selectedRoom   = roomOptions.FirstOrDefault(r => r.Id == selectedRoomId);

                    Console.Write("New Name: ");
                    selectedRoom.Name = Console.ReadLine();

                    Console.Write("New Max Occupancy: ");
                    selectedRoom.MaxOccupancy = int.Parse(Console.ReadLine());

                    roomRepo.Update(selectedRoom);

                    Console.WriteLine($"Room has been successfully updated");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Show all chores"):
                    List <Chore> chores = choreRepo.GetAll();
                    foreach (Chore c in chores)
                    {
                        Console.WriteLine($"{c.Name} has an Id of {c.Id}");
                    }
                    ;
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Search for a chore"):
                    Console.Write("Chore Id: ");
                    int choreId = int.Parse(Console.ReadLine());

                    Chore chore = choreRepo.GetById(choreId);

                    Console.WriteLine($"{chore.Id} - {chore.Name}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Add a chore"):
                    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();
                    break;

                case ("Search for roommate"):
                    Console.Write("Roommate Id: ");
                    int roommateId = int.Parse(Console.ReadLine());

                    Roommate roommate = roommateRepo.GetById(roommateId);

                    Console.WriteLine($"{roommate.FirstName} pays {roommate.RentPortion}% of rent to occupy the {roommate.Room.Name}");
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Show all unassigned chores"):
                    List <Chore> unassignedChores = choreRepo.UnassignedChores();
                    foreach (Chore c in unassignedChores)
                    {
                        Console.WriteLine($"ID: {c.Id} - Chore: {c.Name}");
                    }
                    ;
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Assign chore to roommate"):
                    List <Chore>    choresToAssign   = choreRepo.GetAll();
                    List <Roommate> roomatesToAssign = roommateRepo.GetAll();
                    Console.WriteLine("Chore List:");
                    Console.WriteLine("---------------------");
                    foreach (Chore c in choresToAssign)
                    {
                        Console.WriteLine($"{c.Id} - {c.Name}");
                    }
                    Console.WriteLine("");
                    Console.Write("Which chore would you like to assign: ");
                    int choreChoice = int.Parse(Console.ReadLine());

                    Console.WriteLine("Roommate List:");
                    Console.WriteLine("---------------------");
                    foreach (Roommate r in roomatesToAssign)
                    {
                        Console.WriteLine($"{r.Id} - {r.FirstName} {r.LastName}");
                    }
                    Console.WriteLine("");
                    Console.Write($"Which roommate would you like to assign to chore #{choreChoice}? ");
                    int roommateChoice = int.Parse(Console.ReadLine());

                    choreRepo.AssignChore(roommateChoice, choreChoice);

                    Roommate roomie = roommateRepo.GetById(roommateChoice);
                    Chore    chorie = choreRepo.GetById(choreChoice);

                    Console.WriteLine($"The '{chorie.Name}' chore was assigned to {roomie.FirstName} {roomie.LastName}!");

                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Get Chore Count"):
                    List <ChoreCount> choreCount = choreRepo.GetChoreCounts();
                    foreach (ChoreCount c in choreCount)
                    {
                        Console.WriteLine($"{c.Name}: {c.NumberOfChores}");
                    }
                    ;
                    Console.Write("Press any key to continue");
                    Console.ReadKey();
                    break;

                case ("Exit"):
                    runProgram = false;
                    break;
                }
            }
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: tylerghilliard94/Roommates
        static void Main(string[] args)
        {
            /* RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);
             *
             * Console.WriteLine("Getting All Rooms:");
             * Console.WriteLine();
             *
             * List<Room> allRooms = roomRepo.GetAll();
             *
             * foreach (Room room in allRooms)
             * {
             *   Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }
             *
             * Console.WriteLine("----------------------------");
             * Console.WriteLine("Getting Room with Id 1");
             *
             * Room singleRoom = roomRepo.GetById(1);
             *
             * Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}");
             *
             * Room bathroom = new Room
             * {
             *   Name = "Bathroom",
             *   MaxOccupancy = 1
             * };
             *
             * roomRepo.Insert(bathroom);
             *
             * Console.WriteLine("-------------------------------");
             * Console.WriteLine($"Added the new Room with id {bathroom.Id}");
             * Console.WriteLine("-------------------------------");
             * bathroom.Name = "Outhouse";
             * bathroom.MaxOccupancy = 1;
             *
             * roomRepo.Update(bathroom);
             * Room UpdateTest = roomRepo.GetById(bathroom.Id);
             * Console.WriteLine($"Updated: {UpdateTest.Id} {UpdateTest.Name} {UpdateTest.MaxOccupancy}");
             * Console.WriteLine("-------------------------------");
             * roomRepo.Delete(bathroom.Id);
             *
             * List<Room> allRooms2 = roomRepo.GetAll();
             *
             * foreach (Room room in allRooms2)
             * {
             *   Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}");
             * }*/



            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            int  userEntry      = 1;
            bool mainWhileCheck = true;

            while (mainWhileCheck != false)
            {
                Console.WriteLine("Welcome to Roommate Manager!");
                Console.WriteLine("Choose an option below:");
                Console.WriteLine("");
                Console.WriteLine("1) Get all Roommates");
                Console.WriteLine("2) Get Roommate by Id/Edit");
                Console.WriteLine("3) Get First Roommate by Room");
                Console.WriteLine("4) Get Roommates by Room");
                Console.WriteLine("5) Add new Rommmate");

                Console.WriteLine("6) Delete a Roommate");
                Console.WriteLine("0) Exit");
                Console.WriteLine("");
                userEntry = int.Parse(Console.ReadLine());
                Console.WriteLine("");
                if (userEntry == 0)
                {
                    mainWhileCheck = false;
                    break;
                }
                else if (userEntry == 1)
                {
                    Console.WriteLine("Getting All Roommates:");
                    Console.WriteLine();

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

                    foreach (Roommate roommate in allRoommates)
                    {
                        Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate} {roommate.Room}");
                    }
                    Console.WriteLine("----------------------------");
                }
                else if (userEntry == 2)
                {
                    int byIdEntry = 1;
                    Console.Write("Type in the id of the roommate you want to find:");
                    byIdEntry = int.Parse(Console.ReadLine());

                    Console.WriteLine($"Getting Roommate with Id {byIdEntry}");

                    Roommate singleRoommate = roommateRepo.GetById(byIdEntry);

                    Console.WriteLine($"{singleRoommate.Id} {singleRoommate.Firstname} {singleRoommate.Lastname} {singleRoommate.RentPortion} {singleRoommate.MovedInDate} {singleRoommate.Room}");
                    Console.WriteLine("----------------------------");

                    string editCheck = "a";
                    bool   editWhile = true;
                    Console.WriteLine("");
                    Console.Write("Do you want to Edit this Entry Y/N:");
                    editCheck = Console.ReadLine();
                    Console.WriteLine("");
                    if (editCheck == "y" || editCheck == "Y")
                    {
                        int editSelect = 1;
                        while (editWhile == true)
                        {
                            Console.WriteLine("What do you want to edit:");
                            Console.WriteLine("");
                            Console.WriteLine("1) First Name");
                            Console.WriteLine("2) Last Name");
                            Console.WriteLine("3) Rent Portion");
                            Console.WriteLine("4) Move in Date");
                            Console.WriteLine("5) Assigned Room Id");
                            Console.WriteLine("0) Edit Complete");

                            editSelect = int.Parse(Console.ReadLine());

                            if (editSelect == 0)
                            {
                                editWhile = false;
                            }
                            else if (editSelect == 1)
                            {
                                Console.WriteLine($"The entry's First Name is {singleRoommate.Firstname}. What would you like to change it to?");
                                singleRoommate.Firstname = Console.ReadLine();
                                Console.WriteLine("");
                            }
                            else if (editSelect == 2)
                            {
                                Console.WriteLine($"The entry's Last Name is {singleRoommate.Lastname}. What would you like to change it to?");
                                singleRoommate.Lastname = Console.ReadLine();
                            }
                            else if (editSelect == 3)
                            {
                                Console.WriteLine($"The entry's Rent Portion is {singleRoommate.RentPortion}. What would you like to change it to?");
                                singleRoommate.RentPortion = int.Parse(Console.ReadLine());
                            }
                            else if (editSelect == 4)
                            {
                                Console.WriteLine($"The entry's Move in Day is {singleRoommate.MovedInDate}. What would you like to change it to? (Year, Month, Day)");
                                singleRoommate.MovedInDate = DateTime.Parse(Console.ReadLine());
                            }
                            else if (editSelect == 5)
                            {
                                Console.WriteLine($"The entry's Assigned Room Id is {singleRoommate.RoomId}. What would you like to change it to?");
                                singleRoommate.RoomId = int.Parse(Console.ReadLine());
                            }
                        }
                        roommateRepo.Update(singleRoommate);
                        Roommate UpdatedTest = roommateRepo.GetById(singleRoommate.Id);
                        Console.WriteLine($"Updated: {UpdatedTest.Id} {UpdatedTest.Firstname} {UpdatedTest.Lastname} {UpdatedTest.RentPortion} {UpdatedTest.MovedInDate}");
                        Console.WriteLine("-------------------------------");
                        Console.WriteLine("");
                    }
                    else
                    {
                        Console.WriteLine("");
                    }
                }
                else if (userEntry == 3)
                {
                    int byIdEntry = 1;
                    Console.Write("Type in the Roomid of the roommate you want to find:");
                    byIdEntry = int.Parse(Console.ReadLine());
                    Console.WriteLine($"Getting Latest Roommate with RoomId {byIdEntry}");
                    Roommate singleRoommate2 = roommateRepo.GetByRoom(byIdEntry);

                    Console.WriteLine($"{singleRoommate2.Id} {singleRoommate2.Firstname} {singleRoommate2.Lastname} {singleRoommate2.RentPortion} {singleRoommate2.MovedInDate} {singleRoommate2.Room.Name} {singleRoommate2.Room.MaxOccupancy} {singleRoommate2.Room.MaxOccupancy}");
                    Console.WriteLine("----------------------------");
                    Console.WriteLine("");
                }
                else if (userEntry == 4)
                {
                    int byIdEntry = 1;
                    Console.Write("Type in the Roomid of the roommates you want to find:");
                    byIdEntry = int.Parse(Console.ReadLine());
                    Console.WriteLine($"Getting Roommates with RoomId {byIdEntry}");
                    List <Roommate> allRoommatesByRoom = roommateRepo.GetAllWithRoom(byIdEntry);

                    foreach (Roommate roommate in allRoommatesByRoom)
                    {
                        Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate} {roommate.Room.Name}");
                    }
                    Console.WriteLine("");
                }
                else if (userEntry == 5)
                {
                    Roommate roomy1 = new Roommate
                    {
                        Firstname   = "Matt",
                        Lastname    = "Patt",
                        RentPortion = 40,
                        MovedInDate = new DateTime(2020, 09, 15),
                        Room        = null,
                        RoomId      = 3
                    };
                    Console.WriteLine("");
                    Console.WriteLine("Input information for a new Roommate:");
                    Console.Write("First Name:");
                    roomy1.Firstname = Console.ReadLine();
                    Console.Write("Last Name:");
                    roomy1.Lastname = Console.ReadLine();
                    Console.Write("Rent Portion:");
                    roomy1.RentPortion = int.Parse(Console.ReadLine());
                    Console.Write("Move In Date (Year, Month, Day):");
                    roomy1.MovedInDate = DateTime.Parse(Console.ReadLine());
                    Console.Write("Assigned Room Id:");
                    roomy1.RoomId = int.Parse(Console.ReadLine());

                    Console.Write("Press any key to submit the Roommate:");
                    Console.ReadLine();
                    roommateRepo.Insert(roomy1);
                    Console.WriteLine("-------------------------------");
                    Console.WriteLine($"Added the new Roommate with id {roomy1.Id}");
                    Console.WriteLine("-------------------------------");
                    Console.WriteLine("");
                }
                else if (userEntry == 6)
                {
                    Console.WriteLine("");
                    Console.WriteLine("Which Roommate would you like to Delete?");
                    List <Roommate> allRoommates = roommateRepo.GetAll();

                    foreach (Roommate roommate in allRoommates)
                    {
                        Console.WriteLine($"{roommate.Id}) {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate}");
                    }
                    roommateRepo.Delete(int.Parse(Console.ReadLine()));

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

                    foreach (Roommate roommate in allRoommates2)
                    {
                        Console.WriteLine($"{roommate.Id} {roommate.Firstname} {roommate.Lastname} {roommate.RentPortion} {roommate.MovedInDate} {roommate.RoomId}");
                    }
                    Console.WriteLine("");
                }
            }
        }