Ejemplo n.º 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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 5
0
 public void ViewHotelTest()
 {
     using (var db = new BookingService.AppContext())
     {
         Console.WriteLine("All hotel in database:");
         foreach (var hotel in db.Hotel)
         {
             Console.WriteLine(" - {0}", hotel.Id);
             Console.WriteLine(" - {0}", hotel.HotelName);
             Console.WriteLine(" - {0}", hotel.RoomType);
             Console.WriteLine(" - {0}", hotel.GuestNum);
             Console.WriteLine(" - {0}", hotel.Booked);
             Console.WriteLine(" - {0}", hotel.CreatedAt);
         }
     }
 }
Ejemplo n.º 6
0
 public static string ViewHotelList()
 {
     using (var db = new BookingService.AppContext())
     {
         Console.WriteLine("All hotel in database:");
         foreach (var hotel in db.Hotel)
         {
             Console.WriteLine("ID:           {0}", hotel.Id);
             Console.WriteLine("Hotel Name:   {0}", hotel.HotelName);
             Console.WriteLine("Room Type:    {0}", hotel.RoomType);
             Console.WriteLine("Guest number: {0}", hotel.GuestNum);
             Console.WriteLine("Booked?:      {0}", hotel.Booked);
             Console.WriteLine("Created at:   {0}", hotel.CreatedAt);
             Console.WriteLine("---------------------------------------------");
         }
     }
     return("Error occured. No data return");
 }
Ejemplo n.º 7
0
 public static string ViewFlightList()
 {
     using (var db = new BookingService.AppContext())
     {
         Console.WriteLine("All flight in database:");
         foreach (var flight in db.Flight)
         {
             Console.WriteLine("ID:                   {0}", flight.Id);
             Console.WriteLine("Airlines:             {0}", flight.Airlines);
             Console.WriteLine("Class:                {0}", flight.Class);
             Console.WriteLine("Trip(One way/Return): {0}", flight.TripType);
             Console.WriteLine("Guest number:         {0}", flight.GuestNum);
             Console.WriteLine("Booked?:              {0}", flight.Booked);
             Console.WriteLine("Created at:           {0}", flight.CreatedAt);
             Console.WriteLine("---------------------------------------------");
         }
     }
     return("Error occured. No data return");
 }