public Models.Booking.Booking GetBookingById(long bookingId)
        {
            using (SqlConnection connection = new SqlConnection(CommonUtility.ConnectionString))
            {
                SqlCommand command = new SqlCommand(StoreProcedure.GETBOOKINGSBYID, connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("@BookingId", bookingId));

                try
                {
                    connection.Open();
                    SqlDataReader          reader  = command.ExecuteReader();
                    Models.Booking.Booking booking = new Models.Booking.Booking();
                    booking = UtilityManager.DataReaderMap <Models.Booking.Booking>(reader);
                    return(booking);
                }
                catch (Exception e)
                {
                    throw new Exception("Exception retrieving reviews. " + e.Message);
                }
                finally
                {
                    connection.Close();
                }
            }
        }
        public bool UpdateBooking(Models.Booking.Booking booking)
        {
            bool isUpdate = true;

            using (SqlConnection connection = new SqlConnection(CommonUtility.ConnectionString))
            {
                SqlCommand command = new SqlCommand(StoreProcedure.UPDATEBOOKINGS, connection);
                command.CommandType = CommandType.StoredProcedure;

                foreach (var bookings in booking.GetType().GetProperties())
                {
                    string name  = bookings.Name;
                    var    value = bookings.GetValue(booking, null);
                    command.Parameters.Add(new SqlParameter("@" + name, value == null ? DBNull.Value : value));
                }

                try
                {
                    connection.Open();
                    command.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    isUpdate = false;
                    throw new Exception("Exception Updating Data." + e.Message);
                }
                finally
                {
                    connection.Close();
                }
            }
            return(isUpdate);
        }
        public long InsertBooking(Models.Booking.Booking booking)
        {
            long id = 0;

            using (SqlConnection connection = new SqlConnection(CommonUtility.ConnectionString))
            {
                SqlCommand command = new SqlCommand(StoreProcedure.INSERTBOOKINGS, connection);
                command.CommandType = CommandType.StoredProcedure;
                SqlParameter returnValue = new SqlParameter("@" + "BookingId", SqlDbType.Int);
                returnValue.Direction = ParameterDirection.Output;
                command.Parameters.Add(returnValue);
                foreach (var bookings in booking.GetType().GetProperties())
                {
                    if (bookings.Name != "BookingId")
                    {
                        string name  = bookings.Name;
                        var    value = bookings.GetValue(booking, null);

                        command.Parameters.Add(new SqlParameter("@" + name, value == null ? DBNull.Value : value));
                    }
                }
                try
                {
                    connection.Open();
                    command.ExecuteNonQuery();
                    id = (int)command.Parameters["@BookingId"].Value;
                }
                catch (Exception ex)
                {
                    throw new Exception("Execption Adding Data. " + ex.Message);
                }
                finally
                {
                    connection.Close();
                }
            }
            return(id);
        }