Exemple #1
0
 public static object ListHotelBooking()
 {
     try
     {
         // Fetch all Bookings in the Hotel
         SQLClient sqlClient = new SQLClient();
         string    query     = "select a.ReservationID, b.RoomTypeName, a.CustomerID, b.HourlyRate, a.Status, a.ExpectedCheckIn, a.ExpectedCheckOut from CheckTime as a, RoomTypes as b where a.RoomTypeID = b.RoomTypeID";
         List <HotelBookingObject> hObjects = sqlClient.FetchHotelBooking(query);
         WriteToFile("List of Fetched Bookings: " + JsonConvert.SerializeObject(hObjects));
         return(DeserializeToDictionaryOrList(JsonConvert.SerializeObject(hObjects)));
     }
     catch (Exception ex)
     {
         WriteToFile(string.Format("{0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace));
         return(DeserializeToDictionaryOrList(string.Format(ex.ToString())));
     }
 }
Exemple #2
0
        public static HotelBookingObject ExecuteHotelBookFetch(long ReservationID)
        {
            SQLClient          sqlClient = new SQLClient();
            HotelBookingObject hObject   = new HotelBookingObject();
            string             query     = string.Format("select a.ReservationID, b.RoomTypeName, a.CustomerID, b.HourlyRate, a.Status, a.ExpectedCheckIn, a.ExpectedCheckOut from CheckTime as a, RoomTypes as b where a.RoomTypeID = b.RoomTypeID and a.ReservationID = {0}", ReservationID);

            WriteToFile(string.Format("Booking Fetch Query: {0}", query));
            List <HotelBookingObject> hObjects = sqlClient.FetchHotelBooking(query);

            if (hObjects.Count < 1)
            {
                hObject.Error = "Either Room Type Does Not Exist in this Hotel or ReservationID does not exists. Available Room Types are: deluxe, regular, palatial";
            }
            else
            {
                hObject = hObjects[0];
            }
            return(hObject);
        }