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!")));
                }
            }
        }
Exemplo n.º 2
0
 public BLReservation(IRepositoryReservation reservationRep, IRepositoryCar carRep, IRepositoryClient clientRep, IUnitOfWork uow)
 {
     this.reservationRep = reservationRep;
     this.carRep         = carRep;
     this.clientRep      = clientRep;
     this.uow            = uow;
 }
Exemplo n.º 3
0
 public Seeder(CarRentalDbContext ctx, IRepositoryClient repClient, IRepositoryCar repCar, IRepositoryReservation repReservation, IUnitOfWork uow)
 {
     this.ctx            = ctx;
     this.repClient      = repClient;
     this.repCar         = repCar;
     this.repReservation = repReservation;
     this.uow            = uow;
 }
Exemplo n.º 4
0
        private void SetupMocks()
        {
            var mockReservationRepository = new Mock <IRepositoryReservation>();

            mockReservationRepository
            .Setup(rep => rep.GetAllByClientAsync(10))
            .ReturnsAsync(
                new List <Reservation>()
            {
                new Reservation()
                {
                    ClientAccount = new ClientAccount()
                    {
                        DepositFeePaid = 100, CancellationFeePaid = 100, RentalFeePaid = 100
                    }
                },
                new Reservation()
                {
                    ClientAccount = new ClientAccount()
                    {
                        DepositFeePaid = 10, CancellationFeePaid = 10, RentalFeePaid = 10
                    }
                }
            }
                );
            mockReservationRepository
            .Setup(rep => rep.GetAllByClientAsync(20))
            .ReturnsAsync(
                new List <Reservation>()
                );

            mockedReservationRepository = mockReservationRepository.Object;

            var mockClientRepository = new Mock <IRepositoryClient>();

            mockClientRepository
            .Setup(rep => rep.GetAsync(10))
            .ReturnsAsync(new Client()
            {
                Id = 10
            });
            mockClientRepository
            .Setup(rep => rep.GetAsync(20))
            .ReturnsAsync(new Client()
            {
                Id = 20
            });
            mockedClientRepository = mockClientRepository.Object;
        }
Exemplo n.º 5
0
        public ActionResult SubmitReservationRequest(int idReservation)
        {
            if (Session["loggedInUser"] == null)
            {
                return(RedirectToAction("login", "admin"));
            }

            if (!Convert.ToBoolean(Session["isAdmin"]))
            {
                return(RedirectToAction("index", "home"));
            }

            rep2 = new RepositoryReservation();

            rep2.Open();
            rep2.UpdateReservationStatus(idReservation, true);
            rep2.Close();
            return(View());
        }
Exemplo n.º 6
0
        public ActionResult DeleteReservationRequests(int idReservation)
        {
            if (Session["loggedInUser"] == null)
            {
                return(RedirectToAction("login", "admin"));
            }

            if (!Convert.ToBoolean(Session["isAdmin"]))
            {
                return(RedirectToAction("index", "home"));
            }

            rep2 = new RepositoryReservation();

            rep2.Open();
            rep2.DeleteReservation(idReservation);

            rep2.Close();
            return(RedirectToAction("ReservationRequests", "admin"));
        }
Exemplo n.º 7
0
        public ActionResult ReservationRequests()
        {
            List <Reservation> reservations;

            rep2 = new RepositoryReservation();

            rep2.Open();
            reservations = rep2.getAllReservations();
            rep2.Close();

            List <Reservation> newReservations = new List <Reservation>();

            foreach (var r in reservations)
            {
                if (!r.Status)
                {
                    newReservations.Add(r);
                }
            }

            return(View(newReservations));
        }
Exemplo n.º 8
0
 public BLClient(IRepositoryReservation reservationRep, IRepositoryClient clientRep)
 {
     this.reservationRep = reservationRep;
     this.clientRep      = clientRep;
 }