public void CreateNewOverviewTest_CreatesOverViewAndCalculatesRight()
        {
            ReservationManager       rm            = new ReservationManager(new UnitOfWork(new ReservationContextTest()));
            FindReservationViewModel mockViewModel = new FindReservationViewModel(rm);
            Client client = new Client(999, "Alice", "Cards", ClientCategory.Vip, new Address());

            rm.AddClient(client);
            Location     start  = Location.Antwerpen;
            Location     stop   = Location.Brussel;
            List <Price> prices = new List <Price>();

            prices.Add(new Price(Arrangement.Airport, 100m));
            prices.Add(new Price(Arrangement.Business, 100m));
            prices.Add(new Price(Arrangement.NightLife, 900m));
            prices.Add(new Price(Arrangement.Wedding, 800m));
            prices.Add(new Price(Arrangement.Wellness, 750m));
            Car             car     = new Car("RabbitHole", "Delux", "Brown", prices);
            DeliveryAddress address = new DeliveryAddress("Teaparty", "1", "Wonderland");

            rm.AddCar(car);
            DateTime    startTime   = new DateTime(2020, 12, 12, 8, 0, 0);
            Arrangement arrangement = Arrangement.Airport;
            DateTime    endTime     = new DateTime(2020, 12, 12, 12, 0, 0);


            ReservationOverview reservationOverview = rm.CreateOverview(rm.CreateReservation(client, start, stop, car, startTime, arrangement, endTime, address));

            reservationOverview.TotalNormal.ShouldBe(295m);
            reservationOverview.TotalBeforeDiscount.ShouldBe(295m);
            reservationOverview.Tax.ShouldBe(18m);
            reservationOverview.TotalToPay.ShouldBe(313m);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            ReservationManager rm     = new ReservationManager(new UnitOfWork(new ReservationContextTest()));
            Client             client = new Client(999, "Alice", "Cards", ClientCategory.Vip, new Address());

            rm.AddClient(client);
            Location     start  = Location.Antwerpen;
            Location     stop   = Location.Brussel;
            List <Price> prices = new List <Price>();

            prices.Add(new Price(Arrangement.Airport, 100m));
            prices.Add(new Price(Arrangement.Business, 100m));
            prices.Add(new Price(Arrangement.NightLife, 900m));
            prices.Add(new Price(Arrangement.Wedding, 800m));
            prices.Add(new Price(Arrangement.Wellness, 750m));
            Car             car     = new Car("RabbitHole", "Delux", "Brown", prices);
            DeliveryAddress address = new DeliveryAddress("Teaparty", "1", "Wonderland");

            rm.AddCar(car);
            DateTime    startTime   = new DateTime(2020, 12, 12, 13, 0, 0);
            Arrangement arrangement = Arrangement.Wedding;
            DateTime    endTime     = new DateTime(2020, 12, 13, 0, 0, 0);

            ReservationOverview reservationOverview = rm.CreateOverview(rm.CreateReservation(client, start, stop, car, startTime, arrangement, endTime, address));

            // FileReader.AddClients();
            // FileReader.AddCars();
            Console.ReadKey();
        }
Esempio n. 3
0
        public async Task CreateMeetingRoom()
        {
            var created_reservation = await reservationManager.CreateReservation(NewReservation);


            Assert.IsNotNull(created_reservation);

            Assert.IsNotNull(created_reservation.ID);
        }
Esempio n. 4
0
        public ActionResult Create(CreateReservationsVM vm)
        {
            Table         table    = tableDb.GetTable((int)TempData["TableId"]);
            PiniTCustomer customer = custDb.GetCustomer(User.Identity.GetUserId());
            var           manager  = manDb.GetManager(table.RestaurantId);
            var           hub      = GlobalHost.ConnectionManager.GetHubContext <PiniTHub>();

            if (!ModelState.IsValid || !vm.HasAcceptedTerms)
            {
                TempData["TableId"] = table.TableId;
                vm.Table            = table;
                vm.Restaurant       = restDb.GetRestaurant(table.RestaurantId);
                return(View(vm));
            }

            if (customer.AccountWallet.Credits < vm.Reservation.BookingFee)
            {
                TempData["Message"] = "Not enough Credits. Reservation Cancelled";
                return(RedirectToAction("CustomerIndex", "Tables", new { id = table.RestaurantId }));
            }

            if (table.IsBooked)
            {
                TempData["Message"] = "Sorry! Someone else Booked that Table! You can Book another one :)";
                return(RedirectToAction("CustomerIndex", "Tables", new { id = table.RestaurantId }));
            }

            vm.Reservation.TableId = table.TableId;
            tableDb.ToggleIsBooked(vm.Reservation.TableId);
            vm.Reservation.CustomerId = User.Identity.GetUserId();
            if (vm.Reservation.Comment == null || vm.Reservation.Comment == "")
            {
                vm.Reservation.Comment = "No Comment";
            }
            db.CreateReservation(vm.Reservation);
            hub.Clients.User(manager.UserName).getReservation(new
            {
                Customer      = User.Identity.Name,
                Comment       = vm.Reservation.Comment,
                Date          = vm.Reservation.BookDate.ToString("dd/MM/yyyy HH:mm"),
                Table         = table.Name,
                EstimatedTime = vm.Reservation.BookDate.AddMinutes(vm.EstimatedTime).ToString("HH:mm")
            });
            bool result = walletDb.PayFee(vm.Reservation.BookingFee, vm.Reservation.CustomerId, table.RestaurantId);

            if (result)
            {
                TempData["Message"] = "Reservation Accepted! :)";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TempData["Message"] = "Sorry Something went Wrong ! :'(";
                return(RedirectToAction("CustomerIndex", "Tables", new { id = table.RestaurantId }));
            }
        }
 public async Task <ActionResult> Post([FromBody] Reservation reservation)
 {
     if (ModelState.IsValid)
     {
         try
         {
             return(Json(await reservationManager.CreateReservation(reservation)));
         }
         catch (Exception e)
         {
             return(BadRequest(e.Message));
         }
     }
     return(BadRequest(ModelState));
 }
        public void ShowReservationsCommand_NothingSelected()
        {
            ReservationManager       rm            = new ReservationManager(new UnitOfWork(new ReservationContextTest()));
            FindReservationViewModel mockViewModel = new FindReservationViewModel(rm);

            Client client = new Client(999, "Alice", "Cards", ClientCategory.Vip, new Address());

            rm.AddClient(client);
            Location     start  = Location.Antwerpen;
            Location     stop   = Location.Brussel;
            List <Price> prices = new List <Price>();

            prices.Add(new Price(Arrangement.Airport, 100m));
            prices.Add(new Price(Arrangement.Business, 100m));
            prices.Add(new Price(Arrangement.NightLife, 900m));
            prices.Add(new Price(Arrangement.Wedding, 800m));
            prices.Add(new Price(Arrangement.Wellness, 750m));
            Car             car     = new Car("RabbitHole", "Delux", "Brown", prices);
            DeliveryAddress address = new DeliveryAddress("Teaparty", "1", "Wonderland");

            rm.AddCar(car);
            DateTime    startTime   = new DateTime(2020, 12, 12, 8, 0, 0);
            Arrangement arrangement = Arrangement.Airport;
            DateTime    endTime     = new DateTime(2020, 12, 12, 12, 0, 0);

            rm.AddReservation(rm.CreateReservation(client, start, stop, car, startTime, arrangement, endTime, address));

            Client client2 = new Client(777, "MaddHatter", "Tea", ClientCategory.Vip, new Address());

            rm.AddClient(client2);
            Location     start2  = Location.Antwerpen;
            Location     stop2   = Location.Brussel;
            List <Price> prices2 = new List <Price>();

            prices2.Add(new Price(Arrangement.Airport, 150m));
            prices2.Add(new Price(Arrangement.Business, 110m));
            prices2.Add(new Price(Arrangement.NightLife, 400m));
            prices2.Add(new Price(Arrangement.Wedding, 500m));
            prices2.Add(new Price(Arrangement.Wellness, 650m));
            Car             car2     = new Car("Teacup", "Extra Fragile", "White", prices2);
            DeliveryAddress address2 = new DeliveryAddress("RabbitHole", "3", "Wonderland");

            rm.AddCar(car2);
            DateTime    startTime2   = new DateTime(2020, 12, 13, 21, 0, 0);
            Arrangement arrangement2 = Arrangement.Airport;
            DateTime    endTime2     = new DateTime(2020, 12, 14, 1, 0, 0);

            rm.AddReservation(rm.CreateReservation(client2, start2, stop2, car2, startTime2, arrangement2, endTime2, address2));

            Location     start3  = Location.Antwerpen;
            Location     stop3   = Location.Brussel;
            List <Price> prices3 = new List <Price>();

            prices3.Add(new Price(Arrangement.Airport, 150m));
            prices3.Add(new Price(Arrangement.Business, 110m));
            prices3.Add(new Price(Arrangement.NightLife, 400m));
            prices3.Add(new Price(Arrangement.Wedding, 500m));
            prices3.Add(new Price(Arrangement.Wellness, 650m));

            DeliveryAddress address3 = new DeliveryAddress("RedQueensCastle", "3", "Wonderland");

            DateTime    startTime3   = new DateTime(2020, 12, 12, 21, 0, 0);
            Arrangement arrangement3 = Arrangement.Airport;
            DateTime    endTime3     = new DateTime(2020, 12, 13, 1, 0, 0);

            rm.AddReservation(rm.CreateReservation(client2, start3, stop3, car2, startTime3, arrangement3, endTime3, address3));

            mockViewModel.DateIsChecked   = false;
            mockViewModel.ClientIsChecked = false;
            mockViewModel.ShowReservationCommand.Execute(null);

            mockViewModel.Reservations.Count.ShouldBe(3);
        }