예제 #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),
            });
        }
        public ActionResult Request(Reservation reservation)
        {
            if (reservation == null)
            {
                return(RedirectToAction("Request"));
            }

            CheckReservationData(reservation);

            if (!ModelState.IsValid)
            {
                return(View(reservation));
            }
            else
            {
                rep = new RepositoryReservation();

                rep.Open();

                if (rep.Insert(reservation))
                {
                    rep.Close();

                    return(View("Message", new Message("Request", "Ihre Anfrage wurde erfolgreich abgeschickt!")));
                }
                else
                {
                    rep.Close();

                    return(View("Message", new Message("Request", "Ihre Anfrage konnten nicht abgeschickt werden!")));
                }
            }
        }
예제 #3
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);
        }