예제 #1
0
        private static void CreateRoom()
        {
            Console.Clear();
            Console.WriteLine("Indlæs hotelnr");
            int hotelNo = Convert.ToInt32(Console.ReadLine());
            var hs      = new HotelServiceAsync();

            var hotel = hs.GetHotelFromIdAsync(hotelNo).Result;

            if (hotel != null)
            {
                Console.WriteLine($"Hotel-Nr: {hotel.HotelNr}, Navn: {hotel.Name}, Adresse: {hotel.Address}");
            }
            else
            {
                Console.WriteLine($"Hotelnummer {hotelNo} findes ikke i databasen.");
                return;
            }

            Console.WriteLine("Indlæs værelsenr");
            int roomNo = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Indlæs værelsetype");
            string roomType = Console.ReadLine();

            Console.WriteLine("Indlæs værelsepris");
            double roomPrice = Convert.ToDouble(Console.ReadLine());
            var    rs        = new RoomServiceAsync();

            Console.WriteLine(rs.CreateRoomAsync(hotelNo, new Room(roomNo, roomType[0], roomPrice)).Result
                ? "Værelset blev oprettet."
                : "Fejl! Værelset blev ikke oprettet.");
        }
예제 #2
0
        private static void ShowHotelFromId()
        {
            Console.Clear();
            Console.WriteLine("Indlæs hotelnr");
            var hotelNo = Convert.ToInt32(Console.ReadLine());
            var hs      = new HotelServiceAsync();
            var hotel   = hs.GetHotelFromIdAsync(hotelNo).Result;

            Console.WriteLine(hotel != null
                ? $"HotelNr {hotel.HotelNr} Name {hotel.Name} Address {hotel.Address}"
                : $"Hotelnummer {hotelNo} findes ikke i databasen.");
        }
예제 #3
0
        private static void ShowAllRoomsFromHotelId()
        {
            Console.Clear();
            Console.WriteLine("Indlæs hotelnr");
            var hotelNo = Convert.ToInt32(Console.ReadLine());
            var rs      = new RoomServiceAsync();
            var hs      = new HotelServiceAsync();
            var rooms   = rs.GetAllRoomsFromHotelIdAsync(hotelNo).Result;
            var hotel   = hs.GetHotelFromIdAsync(hotelNo).Result;

            Console.WriteLine($"Liste over alle værelser på {hotel.Name}:");
            foreach (var room in rooms)
            {
                Console.WriteLine($"Værelse-Nr: {room.RoomNr}, Pris: {room.Price:C}, Type: {room.Types}.");
            }
        }
예제 #4
0
        private static void SearchHotelAsync()
        {
            Console.Clear();
            Console.WriteLine("Indlæs Hotelnr du leder efter");
            int hotelnr              = Convert.ToInt32(Console.ReadLine());
            HotelServiceAsync hs     = new HotelServiceAsync();
            Hotel             search = hs.GetHotelFromIdAsync(hotelnr).Result;

            if (search != null)
            {
                Console.WriteLine($"HotelNr {search.HotelNr} Name {search.Navn} Address {search.Adresse}");
            }
            else
            {
                Console.WriteLine("There was an error in your search");
            }
        }
예제 #5
0
        private static void ShowRoomFromRoomId()
        {
            Console.Clear();
            Console.WriteLine("Indlæs hotelnr:");
            var hotelNo = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Indlæs værelsenr:");
            var roomNo = Convert.ToInt32(Console.ReadLine());

            var rs    = new RoomServiceAsync();
            var hs    = new HotelServiceAsync();
            var hotel = hs.GetHotelFromIdAsync(hotelNo).Result;
            var room  = rs.GetRoomFromRoomIdAsync(roomNo, hotelNo).Result;

            Console.WriteLine($"Hotel-Nr: {hotel.HotelNr}, Navn: {hotel.Name}, Adresse: {hotel.Name}.");
            Console.WriteLine($"Værelse-Nr: {room.RoomNr}, Pris: {room.Price:C}, Type: {room.Types}.");
        }