示例#1
0
        public RentalReceipt ReturnVehicle(Guid bookingId, DateTime returnDateTime, int dashboardMileage)
        {
            var rentalBooking = _rentalStorage.GetRentalRegistration(bookingId);

            if (rentalBooking == null)
            {
                throw new BookingNotFoundException();
            }

            var numberOfDays = rentalBooking.Booking.GetNumberOfRentedDays(returnDateTime);
            var kilometers   = rentalBooking.Vehicle.GetDrivenKilometers(dashboardMileage);
            var amountToPay  = ((IRentCalculatable)rentalBooking.Vehicle)
                               .Calculate(numberOfDays, kilometers, _applicationSettings.GetBaseDayRentalPrice(), _applicationSettings.GetKilometerPrice());

            return(new RentalReceipt(amountToPay,
                                     new Period(rentalBooking.Booking.StartDate, returnDateTime),
                                     kilometers));
        }