コード例 #1
0
        public Room MergeRooms(IEnumerable <Room> roomsToMerge, string newName)
        {
            foreach (Room room in roomsToMerge)
            {
                _roomRepository.Delete(room);
            }

            return(_roomRepository.Create(new Room(newName, false, roomsToMerge.ToList()[0].Floor, roomsToMerge.ToList()[0].RoomType)));
        }
コード例 #2
0
        public void RoomRepository_Delete_ShouldBeOk()
        {
            Room room = ObjectMother.GetRoom();

            room.Id = 2;

            _repository.Delete(room);
            Room deleteObject = _repository.Get(2);

            deleteObject.Should().BeNull();
        }
コード例 #3
0
        static void DeleteRoom(RoomRepository roomRepo)
        {
            roomRepo.Delete(5);

            Console.Clear();
            Console.WriteLine("Room has been deleted.");
        }
コード例 #4
0
        public void DeleteRoom()
        {
            Room toDelete = ctx.RoomSet.FirstOrDefault(x => x.Title == "Melanie");

            repo.Delete(toDelete);
            repo.Save();

            Assert.IsNotNull(ctx.RoomCategorySet.FirstOrDefault(x => x.Title == "Cat1"));
            Assert.IsNotNull(ctx.RoomSet.FirstOrDefault(x => x.Title == "Georges"));

            IQueryable <Bed> beds = ctx.BedSet.Include("Room").Where(x => x.Room.Id == toDelete.Id);

            Assert.AreEqual(beds.Count(), 0);

            IQueryable <PricePerPerson> ppps = ctx.PricePerPersonSet.Include("Room").Where(x => x.Room.Id == toDelete.Id);

            Assert.AreEqual(ppps.Count(), 0);

            IQueryable <PricePerPerson> ppps2 = ctx.PricePerPersonSet.Include("Room").Where(x => x.Room == null);

            Assert.AreEqual(ppps2.Count(), 0);

            IQueryable <RoomBooking> rbooks = ctx.RoomBookingSet.Include("Room").Where(x => x.Room.Id == toDelete.Id);

            Assert.AreEqual(rbooks.Count(), 0);
        }
コード例 #5
0
        public JsonResult Delete(int id)
        {
            var deleteResult = RoomRepository.Delete(id);
            var result       = new PostResult(deleteResult);

            return(Json(result));
        }
コード例 #6
0
        public static void DeleteRoom(int roomID)
        {
            MessageController.DeleteRoomMessages(roomID);

            var roomRep = new RoomRepository();
            roomRep.Delete(roomRep.GetById(roomID));
            roomRep.SaveChanges();
        }
コード例 #7
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}");
            }
            Room bathroom = new Room
            {
                Name         = "Bathroom",
                MaxOccupancy = 1
            };

            roomRepo.Insert(bathroom);

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


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

            Console.WriteLine("Deleting");

            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.Room}");
                Console.WriteLine();
                // Console.WriteLine("Getting Roommate with specific Id");

                // Roommate singleRoommate = roommateRepo.GetById(1);
                //Console.WriteLine($"{singleRoommate.Id} {singleRoommate.Firstname}");
            }
            Roommate Aaron = new Roommate
            {
                Firstname = "Aaron"
            };

            roommateRepo.Insert(Aaron);
            Console.WriteLine($"Added new roommate: {Aaron.Firstname}");
        }
コード例 #8
0
ファイル: RoomManager.cs プロジェクト: sfreeley/roommates
        private void Remove()
        {
            Room roomToDelete = ChooseRoom("Which room would you like to remove?");

            if (roomToDelete != null)
            {
                _roomRepository.Delete(roomToDelete.Id);
            }
        }
コード例 #9
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     if (lstRooms.SelectedIndex > -1 && lstTypes.SelectedIndex > -1)
     {
         roomRepository.Delete(room);
         ClearTextBoxes();
         LoadListBox();
     }
 }
コード例 #10
0
ファイル: RoomService.cs プロジェクト: ProbaFirma10/Proba
        public void Remove(Room room)
        {
            removeRoomFromAllMedicines(room);

            removeRoomFromAllEquipments(room);

            removeRoomFromAllSchedules(room);

            roomRepository.Delete(room.id);
        }
コード例 #11
0
        public void IsDeleteable()
        {
            object id = 6546;//test object to be deleted id
            HttpResponseMessage response = repository.Delete(id);
            string jsonContents          = response.Content.ReadAsStringAsync().Result;
            Room   deletedRoom           = JsonConvert.DeserializeObject <Room>(jsonContents);

            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Created, "Room deletion test has failed.");
            Assert.Equals(deletedRoom.ID, id);
        }
コード例 #12
0
ファイル: RoomService.cs プロジェクト: randy102/cinemo
        public Room Delete(int id)
        {
            var existed = GetDetail(id);

            if (existed.ShowTimes.Any())
            {
                throw new Exception("Can not delete Room that already had Showtimes!");
            }
            return(repository.Delete(id));
        }
コード例 #13
0
        static void DeleteRoom(RoomRepository roomRepo)
        {
            List <Room> roomOptions = roomRepo.GetAll();

            roomOptions.ForEach(r => Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})"));
            Console.Write("Which room would you like to delete? ");
            int selectedRoomId = int.Parse(Console.ReadLine());

            roomRepo.Delete(selectedRoomId);
            ContinueMenu();
        }
コード例 #14
0
        public async Task <ActionResult <Room> > DeleteRoom(int id)
        {
            var result = await _roomRepository.Delete(id);

            if (result != null)
            {
                return(result);
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #15
0
        static void DeleteRoom()
        {
            RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING);

            GetRooms();
            Console.WriteLine("Enter the numeral of the room you'd like to delete:");
            string roomIdStr = Console.ReadLine();
            int    roomId    = Int32.Parse(roomIdStr);

            roomRepo.Delete(roomId);
            Console.WriteLine("Deleted the room. Here's the updated list:");
            GetRooms();
        }
コード例 #16
0
 public ActionResult Delete(Room room)
 {
     try
     {
         // TODO: Add delete logic here
         _roomRepository.Delete(room);
         return(RedirectToAction(nameof(Details), "Building", new { Id = room.BuildingNumber }));
     }
     catch
     {
         return(View());
     }
 }
コード例 #17
0
        //public void DeleteRoom(int roomId)
        //{
        //    _slotRepo.DeleteSlotsRoomRelated(roomId);
        //    _roomRepo.Delete(roomId);
        //}

        public void DeleteRoom(int roomId)
        {
            var deletedRoom = (from r in _roomRepo.GetById(roomId)
                               select r).FirstOrDefault();

            var relatedSlots = (from s in _slotRepo.List(deletedRoom.ConferenceId)
                                where s.RoomId == deletedRoom.Id
                                select s).ToList();

            _slotRepo.DeleteRelatedSlots(relatedSlots);
            _roomRepo.Delete(deletedRoom);
            _roomRepo.SaveChanges();
        }
コード例 #18
0
        static void DeleteRoom(RoomRepository roomRepo)
        {
            roomRepo.GetAll().ForEach(r => Console.WriteLine($"[{r.Id}] {r.Name}"));

            Console.WriteLine();
            Console.Write("What is the ID of the room you want to delete? ");

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

            roomRepo.Delete(roomId);

            Console.Write("Room has been successfully removed. Press any key to continue...");
            Console.ReadKey();
        }
コード例 #19
0
 public void DeleteRoom(int RoomID)
 {
     try
     {
         RoomRepository roomRepo = new RoomRepository();
         var            r        = roomRepo.Get(RoomID);
         roomRepo.Delete(r);
         GlobalUnitOfWork.Commit();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #20
0
ファイル: RoomController.cs プロジェクト: diablo1998/DKAC
        public ActionResult Delete(int id)
        {
            Employee em  = (Employee)Session[CommonConstants.USER_SESSION];
            var      emp = _roomRepo.GetById(id);

            emp.ModifyBy = em.id;
            var result = _roomRepo.Delete(id);

            if (result == 1)
            {
                return(Json(new { status = 1, message = "Xóa thành công" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { status = 1, message = "Xóa thất bại" }, JsonRequestBehavior.AllowGet));
        }
コード例 #21
0
ファイル: HomeController.cs プロジェクト: Gurdain/HRS
        public ActionResult Room_Delete(Room room)
        {
            bool          success = roomrepo.Delete(room.RoomId);
            RoomViewModel data    = new RoomViewModel();

            data.hotels = hotelsrepo.Read();
            data.rooms  = roomrepo.Read();
            if (success)
            {
                ViewBag.Message = "Successfully Deleted";
                return(View("Room_Read", data));
            }
            ViewBag.Message = "Encountered an Error while deleting";
            return(View("Room_Read", data));
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: TAPinson/Roommates
            static void deleteRoom(RoomRepository roomRepo)
            {
                List <Room> roomsAtRisk = roomRepo.GetAll();

                foreach (Room r in roomsAtRisk)
                {
                    Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})");
                }
                Console.Write("Select a room to delete: ");
                int roomToDelete = int.Parse(Console.ReadLine());

                roomRepo.Delete(roomToDelete);
                Console.Write("Press any key to continue");
                Console.ReadKey();
            }
コード例 #23
0
        public void TestDelete()
        {
            using (var repo = new RoomRepository(new GamesBackendContext(_options)))
            {
                var pen = new Room()
                {
                    Name = "Name"
                };
                repo.Insert(pen);
                repo.Delete(1);
            }

            using (var repo = new RoomRepository(new GamesBackendContext(_options)))
            {
                Assert.AreEqual(0, repo.Count());
            }
        }
コード例 #24
0
        private static void DeleteRoom(RoomRepository roomRepo)
        {
            List <Room> rooms = roomRepo.GetAll();

            foreach (Room r in rooms)
            {
                Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})");
            }

            Console.Write("Which room would you lke to delete? ");
            int id = int.Parse(Console.ReadLine());

            roomRepo.Delete(id);

            Console.WriteLine($"Room with id {id} has been deleted");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
コード例 #25
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}");
            }

            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 = 4;
            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}");
            }
        }
コード例 #26
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}");
            }
        }
コード例 #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
 public void Delete(Room room) => _repository.Delete(room);
コード例 #29
0
 public ActionResult Delete(int id)
 {
     repo.Delete(id);
     return(RedirectToAction("Index"));
 }
コード例 #30
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;
                }
            }
        }
コード例 #31
0
 public void DeleteRoom()
 {
     _repoRoom.Delete(_room1);
     _roomList = _repoRoom.Get();
     Assert.IsFalse(_roomList.Contains(_room1));
 }