Exemple #1
0
        private async Task AddReservations()
        {
            var car1 = await repCar.GetAsync(1);

            var car2 = await repCar.GetAsync(2);

            var client = await repClient.GetAsync(1);

            repReservation.Insert(new Reservation()
            {
                Car           = car1,
                Client        = client,
                ClientAccount = new ClientAccount()
                {
                    RentalRateFeeValueAtBookingMoment   = car1.Type.RentalRateFee,
                    CancellationFeeValueAtBookingMoment = car1.Type.CancellationRateFee,
                    DepositFeePaid = 10
                },
                PickUpDateTime = DateTime.Now,
                ReturnDateTime = DateTime.Now.AddHours(2),
            });
            repReservation.Insert(new Reservation()
            {
                Car           = car2,
                Client        = client,
                ClientAccount = new ClientAccount()
                {
                    RentalRateFeeValueAtBookingMoment   = car1.Type.RentalRateFee,
                    CancellationFeeValueAtBookingMoment = car1.Type.CancellationRateFee,
                    DepositFeePaid = 20
                },
                PickUpDateTime = DateTime.Now.AddHours(2),
                ReturnDateTime = DateTime.Now.AddHours(12),
            });
        }
Exemple #2
0
        public async Task <Reservation> BookCarReservationAsync(BookCarReservationParameters parameters)
        {
            var clientTask = clientRep.GetAsync(parameters.ClientId);
            var carTask    = carRep.GetAsync(parameters.CarId);
            var client     = await clientTask;
            var car        = await carTask;

            await ValidateAsync(parameters, car, client);

            var reservation = new Reservation()
            {
                Car            = car,
                Client         = client,
                PickUpDateTime = parameters.PickUpDateTime,
                ReturnDateTime = parameters.ReturnDateTime,
                State          = ReservationState.Booked
            };

            reservation.ClientAccount = new ClientAccount()
            {
                CancellationFeeValueAtBookingMoment = car.Type.CancellationRateFee,
                RentalRateFeeValueAtBookingMoment   = car.Type.RentalRateFee,
                DepositFeePaid = CalculateDepositFeeToPay(reservation)
            };

            reservationRep.Insert(reservation);

            await uow.CompleteAsync();

            return(reservation);
        }
Exemple #3
0
 private async Task Validate(long clientID)
 {
     if (await clientRep.GetAsync(clientID) == null)
     {
         throw new CustomException($"Unknown Client - Id {clientID}", ErrorCode.UnknownClient);
     }
 }