/// <summary>
        /// Adds a new booking record to storage.
        /// </summary>
        /// <param name="newBooking">The Save_Bookings object to be added</param>
        /// <returns>The newly added custom event</returns>
        public Save_Bookings AddBooking(Save_Bookings newBooking)
        {
            var ride        = _unitOfWork.RideRepository.FirstOrDefault(x => x.rideID == newBooking.rideID);
            var bookings    = _unitOfWork.BookingRepository.GetAll(x => x.rideID == newBooking.rideID);
            int bookedCount = 0;

            foreach (var booking in bookings)
            {
                bookedCount += 1;
            }

            if (ride.capacity < bookedCount)
            {
                throw new ResourceCreationException()
                      {
                          ExceptionMessage = "Ride is full!"
                      };
            }

            var idParam       = new SqlParameter("@ID", newBooking.ID);
            var rideIdParam   = new SqlParameter("@RIDEID", newBooking.rideID);
            var isDriverParam = new SqlParameter("@ISDRIVER", newBooking.isDriver);
            var context       = new CCTEntities1();

            context.Database.ExecuteSqlCommand("CREATE_BOOKING @ID, @RIDEID, @ISDRIVER", idParam, rideIdParam, isDriverParam);

            _unitOfWork.Save();

            return(newBooking);
        }
        public IHttpActionResult PostBooking([FromBody] Save_Bookings newBooking)
        {
            var authenticatedUser = this.ActionContext.RequestContext.Principal as ClaimsPrincipal;
            var username          = authenticatedUser.Claims.FirstOrDefault(x => x.Type == "user_name").Value;
            var id = _accountService.GetAccountByUsername(username).GordonID;

            newBooking.ID = id;

            var result = _saveService.AddBooking(newBooking);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }