public async Task <Reservation> CreateReservationAsync(ReservationRequest request) { Bike bike = await _storeService.ReserveBikeAsync(request.RequestedBikeId); Customer customer = await _storeService.RegisterCustomerAsync(request.Customer); PricingInfo pricingInfo = await _storeService.CalculatePriceAsync(bike, request.DaysRequested); // Get the reservation object Reservation reservation = request.BuildReservation(pricingInfo); // Post it reservation = await _reservationsRepo .InsertAsync(reservation, BikeRentalRoute.Reservations); // We have to set these properties after posting or there will be key conflicts reservation.Customer = customer; reservation.CustomerId = customer.Id; reservation.Bike = bike; // Update it reservation = await _reservationsRepo .UpdateAsync(reservation, BikeRentalRoute.Reservations); return(reservation); }