コード例 #1
0
        public List <HotelBookingObject> UpdateHotelBooking(string query, HotelBookingUpdate msg)
        {
            using (SqlConnection sqlCon = new SqlConnection(_connString))
            {
                using (var command = new SqlCommand(query, sqlCon))
                {
                    command.Parameters.AddWithValue("Status", msg.Patch.Status);
                    command.Parameters.AddWithValue("ExpectedCheckIn", msg.Patch.ExpectedCheckInTime);
                    command.Parameters.AddWithValue("ExpectedCheckOut", msg.Patch.ExpectedCheckOutTime);
                    if (sqlCon.State == ConnectionState.Closed)
                    {
                        sqlCon.Open();
                    }
                    command.ExecuteNonQuery();
                }
            }
            string lastQuery = 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}", msg.Patch.ReservationId);
            List <HotelBookingObject> hObjects = FetchHotelBooking(lastQuery);

            return(hObjects);
        }
コード例 #2
0
        public static Dictionary <string, object> UpdateHotelBooking(long ReservationID, HotelBookingUpdate msg)
        {
            try
            {
                // Fetch Details of the Booking to update by ReservationID
                HotelBookingObject hObject = ExecuteHotelBookFetch(ReservationID);
                if (string.IsNullOrEmpty(hObject.Error))
                {
                    HotelBookingUpdate updateMsg = new HotelBookingUpdate();
                    updateMsg.Patch = msg.Patch;
                    WriteToFile(string.Format("Update Msg Details: {0}", JsonConvert.SerializeObject(updateMsg)));

                    // Assign update msg with field values from the API Call if they exist
                    updateMsg.Patch.ReservationId        = hObject.ReservationId;
                    updateMsg.Patch.Status               = string.IsNullOrEmpty(msg.Patch.Status) ? hObject.Status : msg.Patch.Status;
                    updateMsg.Patch.ExpectedCheckInTime  = string.IsNullOrEmpty(msg.Patch.ExpectedCheckInTime) ? hObject.ExpectedCheckInTime : msg.Patch.ExpectedCheckInTime;
                    updateMsg.Patch.ExpectedCheckOutTime = string.IsNullOrEmpty(msg.Patch.ExpectedCheckOutTime) ? hObject.ExpectedCheckOutTime : msg.Patch.ExpectedCheckOutTime;
                    SQLClient sqlClient = new SQLClient();
                    string    query     = string.Format("update CheckTime set [Status] = @Status, [ExpectedCheckIn] = @ExpectedCheckIn, [ExpectedCheckOut] = @ExpectedCheckOut where ReservationID = {0}", hObject.ReservationId);

                    // Update Hotel Booking by the ReservationID
                    List <HotelBookingObject> hObjects = sqlClient.UpdateHotelBooking(query, updateMsg);
                    hObject = hObjects[0];
                    return(DeserializeToDictionary(JsonConvert.SerializeObject(hObject)));
                }
                else
                {
                    Error err = new Error();
                    err.ErrorMessage = hObject.Error;
                    return(DeserializeToDictionary(JsonConvert.SerializeObject(err)));
                }
            }
            catch (Exception ex)
            {
                WriteToFile(string.Format("{0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace));
                return(DeserializeToDictionary(string.Format(ex.ToString())));
            }
        }
コード例 #3
0
        public Dictionary <string, object> Update(long reservationId, [FromBody] HotelBookingUpdate msg)
        {
            Dictionary <string, object> bookingList = Utility.UpdateHotelBooking(reservationId, msg);

            return(bookingList);
        }