Beispiel #1
0
        public IActionResult DeleteConfirmed(int id)
        {
            var hotel = _manageHotel.Get(id);

            if (hotel == null)
            {
                return(View());
            }
            bool ok = _manageHotel.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #2
0
        public void Test_Hotel_Put()
        {
            //Arrange
            Hotel       testHotel   = new Hotel(9999, "Test", "Test");
            ManageHotel manageHotel = new ManageHotel();

            manageHotel.Post(testHotel);
            Hotel expectedHotelUpdate = new Hotel(8888, "Test2", "Test2");


            //Act
            bool  ok = manageHotel.Put(9999, expectedHotelUpdate);
            Hotel actualUpdatedHotel = manageHotel.Get(8888);

            //Cleanup
            manageHotel.Delete(8888);
            manageHotel.Delete(9999);

            //Assert
            Assert.AreEqual(true, ok);
            Assert.AreEqual(expectedHotelUpdate, actualUpdatedHotel);
        }
Beispiel #3
0
        public void TestManageHotelPost()
        {
            //Arrange
            ManageHotel manageHotel = new ManageHotel();
            Hotel       newHotel    = new Hotel(602, "TestHotel", "TestAdresse");


            //Act

            bool ok       = manageHotel.Post(newHotel);
            bool okdelete = manageHotel.Delete(602);

            //Assert
            Assert.IsTrue(ok);
        }
Beispiel #4
0
        public void Test_Hotel_GetSpecific()
        {
            //Arrange
            Hotel       testHotel   = new Hotel(9999, "Test", "Test");
            ManageHotel manageHotel = new ManageHotel();

            manageHotel.Post(testHotel);

            //Act
            Hotel actualHotel = manageHotel.Get(9999);

            //Cleanup
            manageHotel.Delete(9999);

            //Assert
            Assert.AreEqual(testHotel, actualHotel);
        }
Beispiel #5
0
        public void TestManageHotelDelete()
        {
            //Arrange
            ManageHotel manageHotel  = new ManageHotel();
            Hotel       aHotel       = new Hotel(603, "Testdelete", "Testdelete");
            bool        ok           = manageHotel.Post(aHotel);
            int         numberBefore = (from h in manageHotel.Get()
                                        select h.Id).Count();

            //Act

            bool okdelete     = manageHotel.Delete(603);
            int  numbersAfter = (from h in manageHotel.Get()
                                 select h.Id).Count();

            //Assert
            Assert.AreEqual(numberBefore - 1, numbersAfter);
        }
Beispiel #6
0
        public void Test_Hotel_Delete()
        {
            //Arrange
            Hotel       testHotel   = new Hotel(9999, "Test", "Test");
            ManageHotel manageHotel = new ManageHotel();

            manageHotel.Post(testHotel);
            int hotelsBefore = (from h in manageHotel.Get() select h.ID).Count();

            //Act
            bool ok          = manageHotel.Delete(9999);
            int  hotelsAfter = (from h in manageHotel.Get() select h.ID).Count();


            //Assert
            Assert.AreEqual(true, ok);
            Assert.AreEqual(hotelsBefore - 1, hotelsAfter);
        }
Beispiel #7
0
        public void TestManageHotelPut()
        {
            //Arrange
            ManageHotel manageHotel = new ManageHotel();
            bool        okbefore    = manageHotel.Post(new Hotel(604, "BeforeHotel", "BeforeHotel"));


            //Act
            Hotel        putHotel    = new Hotel(604, "PutHotel", "PutHotel");
            bool         ok          = manageHotel.Put(604, putHotel);
            List <Hotel> listHotel   = manageHotel.Get().ToList();
            Hotel        hotelInList = manageHotel.Get(604);
            bool         okdelete    = manageHotel.Delete(604);


            //Assert

            Assert.AreEqual(putHotel, hotelInList);
        }
 // DELETE: api/Hotels/5
 public bool Delete(int id)
 {
     return(manager.Delete(id));
 }
Beispiel #9
0
        static void Main(string[] args)
        {
            //Hotel

            ManageHotel hmgr = new ManageHotel();

            Console.WriteLine("Alle hoteller");
            foreach (Hotel h in hmgr.Get())
            {
                Console.WriteLine(h);
            }

            Console.WriteLine("Et hotel no3");
            Console.WriteLine(hmgr.Get(3));

            Console.WriteLine("opret hotel");
            Console.WriteLine(hmgr.Post(new Hotel(100, "peters", "vejen 3")));
            Console.WriteLine(hmgr.Get(100));

            Console.WriteLine("ændre hotel");
            Console.WriteLine(hmgr.Put(100, new Hotel(100, "pouls", "gaden 3")));
            Console.WriteLine(hmgr.Get(100));

            Console.WriteLine("Slet hotel 100");
            Console.WriteLine(hmgr.Delete(100));
            Console.WriteLine(hmgr.Get(100));


            //Guest

            ManageGuest gmgr = new ManageGuest();

            Console.WriteLine("Alle gæster");
            foreach (Guest g in gmgr.Get())
            {
                Console.WriteLine(g);
            }

            Console.WriteLine("En Gæst no4");
            Console.WriteLine(gmgr.Get(4));

            Console.WriteLine("opret gæst");
            Console.WriteLine(gmgr.Post(new Guest(100, "peter", "vejen 3")));
            Console.WriteLine(gmgr.Get(100));

            Console.WriteLine("ændre gæst");
            Console.WriteLine(gmgr.Put(100, new Guest(100, "poul", "gaden 3")));
            Console.WriteLine(gmgr.Get(100));

            Console.WriteLine("Slet gæst 100");
            Console.WriteLine(gmgr.Delete(100));
            Console.WriteLine(gmgr.Get(100));



            //Room

            ManageRoom rmgr = new ManageRoom();

            Console.WriteLine("Alle værelser");
            foreach (Room r in rmgr.Get())
            {
                Console.WriteLine(r);
            }

            Console.WriteLine("En værelse no4");
            Console.WriteLine(rmgr.Get(4, 1));

            Console.WriteLine("opret værelse");
            Console.WriteLine(rmgr.Post(new Room(400, 4, 'S', 234.4)));
            Console.WriteLine(rmgr.Get(4, 400));

            Console.WriteLine("ændre værelse");
            Console.WriteLine(rmgr.Put(100, 4, new Room(400, 4, 'F', 287.5)));
            Console.WriteLine(rmgr.Get(4, 400));

            Console.WriteLine("Slet værelse 100");
            Console.WriteLine(rmgr.Delete(4, 400));
            Console.WriteLine(rmgr.Get(4, 400));


            //Guest

            ManageBooking bmgr = new ManageBooking();

            Console.WriteLine("Alle bookninger");
            foreach (Booking b in bmgr.Get())
            {
                Console.WriteLine(b);
            }

            Console.WriteLine("En bookning no4");
            Console.WriteLine(bmgr.Get(4));

            Console.WriteLine("opret bookning");
            Console.WriteLine(bmgr.Post(new Booking(100, 4, 1, 5, DateTime.Parse("2019-03-07"), DateTime.Parse("2019-03-09"))));

            //Console.Write("Give latest / highest b-no : ");
            //int bno = Int32.Parse(Console.ReadLine());
            //Console.WriteLine(bmgr.Get(bno));

            Console.WriteLine("ændre bookning ");
            Console.WriteLine(bmgr.Put(100, new Booking(100, 5, 2, 2, DateTime.Parse("2019-03-17"), DateTime.Parse("2019-03-19"))));
            Console.WriteLine(bmgr.Get(100));

            Console.WriteLine("Slet bookning ");
            Console.WriteLine(bmgr.Delete(100));
            Console.WriteLine(bmgr.Get(100));

            // Facilities

            ManageFacilities fmgr = new ManageFacilities();

            Console.WriteLine("Alle facilities");
            foreach (Facilities f in fmgr.Get())
            {
                Console.WriteLine(f);
            }

            Console.WriteLine();
            Console.WriteLine("Printer facility nr1:");
            Console.WriteLine(fmgr.Get(1));

            Console.WriteLine("Opretter en faciltiy:");
            Console.WriteLine(fmgr.Post(new Facilities(15, 10, "Golfbane")));

            Console.WriteLine(fmgr.Get(15));

            Console.WriteLine("Opdatere facility:");
            Console.WriteLine(fmgr.Put(15, new Facilities(15, 10, "Golfbane UPDATE")));
            Console.WriteLine(fmgr.Get(15));

            Console.WriteLine("Sletter facility:");
            Console.WriteLine(fmgr.Delete(15));
            Console.WriteLine("Prøver at printe slettet facility: ");
            Console.Write(fmgr.Get(15));


            /*
             * ManageGuest m = new ManageGuest();
             * foreach (var guest in m.Get())
             * {
             *  Console.WriteLine(guest.Name);
             * }
             *
             *
             *
             * ManageBooking b = new ManageBooking();
             *
             * Booking b1 = b.Get(4);
             *
             * Console.WriteLine(b1.ToString());
             *
             * ManageHotel hotel = new ManageHotel();
             *
             * Hotel hotel1 = hotel.Get(2);
             *
             * Console.WriteLine(hotel1.Name);
             *
             */

            Console.ReadLine();
        }