예제 #1
0
        public void UpdateCheckout(CheckoutDto checkoutDto)
        {
            var checkout = _checkoutRepository.Get(checkoutDto.Id);

            checkout.ReservationId          = checkoutDto.ReservationId;
            checkout.BikeCheckoutId         = checkoutDto.BikeCheckoutId;
            checkout.ReservedDateTime       = checkoutDto.ReservedDateTime;
            checkout.CheckoutDateTime       = checkoutDto.CheckoutDateTime;
            checkout.ExpectedReturnDateTime = checkoutDto.ExpectedReturnDateTime;

            _checkoutRepository.Update(checkout);
        }
        public async Task <CheckoutResponse> UpdateAsync(int id, Checkout checkout)
        {
            var existingCheckout = await _checkoutRepository.FindByIdAsync(id);

            if (existingCheckout == null)
            {
                return(new CheckoutResponse("Checkout Not Found"));
            }

            try
            {
                _checkoutRepository.Update(existingCheckout);
                await _unitOfWork.CompleteAsync();

                return(new CheckoutResponse(existingCheckout));
            }
            catch (Exception ex)
            {
                return(new CheckoutResponse($"An error occurred when updating the checkout:{ex.Message}"));
            }
        }