public int AddBooking(Booking booking)
        {
            IRideService rideService = new RideService(configuration);
            Ride         ride        = rideService.GetRideById(booking.Ride.Id);

            ride.Id = booking.Ride.Id;
            int availableSeats = AvailableSeats(ride, booking.PickUp, booking.Drop);

            if (availableSeats >= booking.NumberOfSeatsBooked)
            {
                string query = "insert into Booking(Id,RideId,PickUp,[Drop],BookedBy,Price,StatusId,BookingTime,NumberOfSeatsBooked)" +
                               " values(@Id,@RideId,@PickUp,@Drop,@BookedBy,@Price,@StatusId,@BookingTime,@NumberOfSeatsBooked)";
                booking.Id = Guid.NewGuid().ToString();
                string          statusQuery           = "select * from Status where Type='Booking' and Value='Pending'";
                ExtensionObject statusExtensionObject = new ExtensionObject()
                {
                    Query            = statusQuery,
                    ConnectionString = connectionString
                };

                string            statusId   = statusExtensionObject.GetItem <Status>().Id;
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("Id", booking.Id);
                parameters.Add("RideId", booking.Ride.Id);
                parameters.Add("PickUp", booking.PickUp);
                parameters.Add("Drop", booking.Drop);
                parameters.Add("BookedBy", booking.BookedBy.Id);
                parameters.Add("Price", booking.Price);
                parameters.Add("StatusId", statusId);
                parameters.Add("BookingTime", booking.BookingTime);
                parameters.Add("NumberOfSeatsBooked", booking.NumberOfSeatsBooked);
                ExtensionObject extensionObject = new ExtensionObject()
                {
                    Query            = query,
                    ConnectionString = connectionString
                };
                if (extensionObject.AddOrUpdateItem <Booking>(parameters))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(-1);
            }
        }
        public int UpdateBooking(Booking booking)
        {
            IRideService rideService = new RideService(configuration);
            Ride         ride        = rideService.GetRideById(booking.Ride.Id);

            ride.Id = booking.Ride.Id;
            int availableSeats = AvailableSeats(ride, booking.PickUp, booking.Drop);

            if (booking.Status.Value == "Rejected")
            {
                string query = "update Booking set PickUp=@PickUp,[Drop]=@Drop" +
                               ",StatusId=@Status,NumberOfSeatsBooked=@NumberOfSeatsBooked where Id=@Id";
                DynamicParameters parameters            = new DynamicParameters();
                string            statusQuery           = "select * from Status where Type='Booking' and Value='" + booking.Status.Value + "'";
                ExtensionObject   statusExtensionObject = new ExtensionObject()
                {
                    Query            = statusQuery,
                    ConnectionString = connectionString
                };
                string statusId = statusExtensionObject.GetItem <Status>().Id;

                parameters.Add("Id", booking.Id);
                parameters.Add("PickUp", booking.PickUp);
                parameters.Add("Drop", booking.Drop);
                parameters.Add("Status", statusId);
                parameters.Add("NumberOfSeatsBooked", booking.NumberOfSeatsBooked);
                ExtensionObject extensionObject = new ExtensionObject()
                {
                    Query            = query,
                    ConnectionString = connectionString
                };
                //new { booking.Id, booking.PickUp, booking.Drop, booking.Status, booking.NumberOfSeatsBooked });
                if (extensionObject.AddOrUpdateItem <Booking>(parameters))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            else if (booking.Status.Value == "Approved" && availableSeats >= booking.NumberOfSeatsBooked)
            {
                string query = "update Booking set PickUp=@PickUp,[Drop]=@Drop" +
                               ",StatusId=@Status,NumberOfSeatsBooked=@NumberOfSeatsBooked where Id=@Id";
                DynamicParameters parameters            = new DynamicParameters();
                string            statusQuery           = "select * from Status where Type='Booking' and Value='" + booking.Status.Value + "'";
                ExtensionObject   statusExtensionObject = new ExtensionObject()
                {
                    Query            = statusQuery,
                    ConnectionString = connectionString
                };
                string statusId = statusExtensionObject.GetItem <Status>().Id;

                parameters.Add("Id", booking.Id);
                parameters.Add("PickUp", booking.PickUp);
                parameters.Add("Drop", booking.Drop);
                parameters.Add("Status", statusId);
                parameters.Add("NumberOfSeatsBooked", booking.NumberOfSeatsBooked);
                ExtensionObject extensionObject = new ExtensionObject()
                {
                    Query            = query,
                    ConnectionString = connectionString
                };
                //new { booking.Id, booking.PickUp, booking.Drop, booking.Status, booking.NumberOfSeatsBooked });
                if (extensionObject.AddOrUpdateItem <Booking>(parameters))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            return(-1);
        }