Example #1
0
        public static string bookFlight()
        {
            Console.WriteLine("Please enter the flight id that you want to make booking.");
            string value    = Console.ReadLine();
            int    flightId = Convert.ToInt32(value);

            using (var db = new BookingService.AppContext())
            {
                var flight   = db.Flight.Find(flightId);
                var original = flight.Booked;

                if (flight.Booked == false)
                {
                    Console.WriteLine("---------------------------------------------");
                    Console.WriteLine("Flight {0}", flight.Airlines, "booked successfully");
                }
                else
                {
                    Console.WriteLine("---------------------------------------------");
                    Console.WriteLine("Flight checkout");
                }

                flight.Booked = !flight.Booked;
                db.SaveChanges();
            }
            return("something");
        }
Example #2
0
        public static string bookHotel()
        {
            Console.WriteLine("Please enter the hotel id that you want to make booking/checkout.");
            string value   = Console.ReadLine();
            int    hotelId = Convert.ToInt32(value);

            using (var db = new BookingService.AppContext())
            {
                var hotel    = db.Hotel.Find(hotelId);
                var original = hotel.Booked;

                if (hotel.Booked == false)
                {
                    Console.WriteLine("---------------------------------------------");
                    Console.WriteLine("Room  {0}", hotel.HotelName, " {1} booked successfully");
                }
                else
                {
                    Console.WriteLine("---------------------------------------------");
                    Console.WriteLine("Room {0}", hotel.HotelName, " {1} checkout");
                }

                hotel.Booked = !hotel.Booked;
                db.SaveChanges();
            }
            return("something");
        }
Example #3
0
        public void CreateFlightTest()
        {
            using (var db = new BookingService.AppContext())
            {
                db.Flight.Add(new BookingService.Flight {
                    Airlines = "Malaysia Airlines", Class = "Business Class", TripType = "", Booked = false
                });
                var count = db.SaveChanges();

                Console.WriteLine("Flight inserted is updated in database");
                foreach (var flight in db.Flight)
                {
                    Console.WriteLine(" - {0}", flight.Airlines);
                }
            }
        }
Example #4
0
        public void CreateHotelTest()
        {
            using (var db = new BookingService.AppContext())
            {
                db.Hotel.Add(new BookingService.Hotel {
                    HotelName = "G Hotel Hotel", RoomType = "Family Suite", GuestNum = 4, Booked = false
                });
                var count = db.SaveChanges();

                Console.WriteLine("Hotel inserted is updated in database");
                foreach (var hotel in db.Hotel)
                {
                    Console.WriteLine(" - {0}", hotel.HotelName);
                }
            }
        }