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 static void AddClients()
        {
            ReservationManager RM = new ReservationManager(new UnitOfWork(new ReservationContext("Reservation")));

            RM.DeleteAllClients();
            List <Client> clients = ReadClients();

            foreach (Client c in clients)
            {
                RM.AddClient(c);
            }
        }
Esempio n. 4
0
        public void AddReservationTest()
        {
            ReservationManager      rm            = new ReservationManager(new UnitOfWork(new ReservationContextTest()));
            AddReservationViewModel mockViewModel = new AddReservationViewModel(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);

            var reservationInfo = new ReservationInfo(start, stop, startTime, arrangement, endTime, address);

            mockViewModel.CurrentClient   = client;
            mockViewModel.ReservationInfo = reservationInfo;
            mockViewModel.CurrentCar      = car;
            var reservation = new Reservation(client, car, reservationInfo);

            mockViewModel.AddReservationCommand.Execute(null);

            Assert.AreEqual(reservation.Client, mockViewModel.Reservations.Last().Client);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            ClientManager      clientManager;
            HotelManager       hotelManager;
            ReservationManager reservationManager;

            string control = "s";

            while (control != "0")
            {
                Console.WriteLine("Чтобы создать клиента нажмите 1");
                Console.WriteLine("Чтобы удалить клиента нажмите 2");
                Console.WriteLine("Чтобы создать отель нажмите 3");
                Console.WriteLine("Чтобы удалить отель нажмите 4");
                Console.WriteLine("Чтобы создать бронь нажмите 5");
                Console.WriteLine("Чтобы удалить бронь нажмите 6");
                Console.WriteLine("Чтобы выйти нажмите 0");
                Console.Write("Ввод: ");
                control = Console.ReadLine();
                if (control == "1")
                {
                    clientManager = new ClientManager();
                    Console.Write("Введите имя: ");
                    string name = Console.ReadLine();
                    Console.Write("Введите Фамилию: ");
                    string surname = Console.ReadLine();
                    Console.Write("Введите возраст: ");
                    string age = Console.ReadLine();
                    clientManager.AddClient(name, surname, int.Parse(age));
                    clientManager.CreateClientsLog();
                }

                if (control == "2")
                {
                    clientManager = new ClientManager();
                    Thread.Sleep(300);
                    if (clientManager.clients.Count == 0)
                    {
                        Console.WriteLine("Увы сегодня некого удалить!");
                        Console.WriteLine(" ");
                    }
                    else
                    {
                        int numbClient = 0;
                        foreach (Client client in clientManager.clients)
                        {
                            Console.WriteLine($"{numbClient + 1}. {client.Name}");
                        }
                        Console.Write("Выберите номер кого удалить:");
                        string numbClient2 = Console.ReadLine();
                        numbClient = int.Parse(numbClient2);

                        clientManager.RemoveClient(clientManager.clients[numbClient - 1].IdClient);
                        Console.WriteLine("Он больше не забронирует не один отель :) ");
                        Console.WriteLine(" ");
                    }
                }

                if (control == "3")
                {
                    hotelManager = new HotelManager();
                    try
                    {
                        Console.Write("Введите название: ");
                        string name = Console.ReadLine();
                        Console.Write("Введите рейтинг: ");
                        string rating = Console.ReadLine();
                        Console.Write("Введите страну: ");
                        string country = Console.ReadLine();
                        hotelManager.AddHotel(name, Double.Parse(rating), country);
                        hotelManager.CreateHotelsLog();
                    } catch
                    {
                        Console.WriteLine("Некоректные данные. Повторите попытку");
                    }
                }

                if (control == "4")
                {
                    hotelManager = new HotelManager();
                    Thread.Sleep(300);
                    if (hotelManager.hotels.Count == 0)
                    {
                        Console.WriteLine("Ни одного отеля нет для разрушения");
                        Console.WriteLine(" ");
                    }
                    else
                    {
                        int numbHotel = 0;
                        foreach (Hotel hotel in hotelManager.hotels)
                        {
                            Console.WriteLine($"{numbHotel + 1}. {hotel.Name} - {hotel.Country}");
                        }
                        Console.Write("Введите номер отеля для разрушения: ");
                        string numbHotel2 = Console.ReadLine();
                        numbHotel = int.Parse(numbHotel2);
                        hotelManager.RemoveHotel(hotelManager.hotels[numbHotel - 1].IdHotel);
                        Console.WriteLine("Отель разрушен! Постояльцы переселенны , персонал ищет работу в другом месте :)");
                        Console.WriteLine(" ");
                    }
                }

                if (control == "5")
                {
                    reservationManager = new ReservationManager();
                    Thread.Sleep(300);
                    if (reservationManager.clients.Count == 0 || reservationManager.hotels.Count == 0)
                    {
                        Console.WriteLine("В базе нет клиентов или отелей. Добавьте их!");
                        Console.WriteLine(" ");
                        continue;
                    }
                    Console.WriteLine("Выберите для какого клиента: ");
                    int numbClient = 0;
                    foreach (Client client in reservationManager.clients)
                    {
                        Console.WriteLine($"{numbClient + 1}.{client.Name}");
                    }
                    Console.Write("Введите нормер клиента: ");
                    string numbClient2 = Console.ReadLine();
                    numbClient = int.Parse(numbClient2);
                    reservationManager.AddClient(reservationManager.clients[numbClient - 1].IdClient);
                    Console.WriteLine("Выберите отель: ");
                    int numbHotel = 0;
                    foreach (Hotel hotel in reservationManager.hotels)
                    {
                        Console.WriteLine($"{numbHotel + 1}.{hotel.Name} - {hotel.Country}");
                    }
                    Console.Write("Введите нормер отеля: ");
                    string numbHotel2 = Console.ReadLine();
                    numbHotel = int.Parse(numbHotel2);
                    reservationManager.AddHotel(reservationManager.hotels[numbHotel - 1].IdHotel);

                    try
                    {
                        Console.WriteLine("Введите даты бронирования (от и до) : ");
                        Console.Write("Введите год (дата от):");
                        string d1Year = Console.ReadLine();
                        Console.Write("Введите месяц (дата от):");
                        string d1Month = Console.ReadLine();
                        Console.Write("Введите день (дата от):");
                        string d1Day = Console.ReadLine();

                        DateTime dateIn = new DateTime(int.Parse(d1Year), int.Parse(d1Month), int.Parse(d1Day));

                        Console.Write("Введите год (дата до):");
                        string d2Year = Console.ReadLine();
                        Console.Write("Введите месяц (дата до):");
                        string d2Month = Console.ReadLine();
                        Console.Write("Введите день (дата до):");
                        string d2Day = Console.ReadLine();

                        DateTime dateOut = new DateTime(int.Parse(d2Year), int.Parse(d2Month), int.Parse(d2Day));

                        reservationManager.AddDateReserv(dateIn, dateOut);
                        reservationManager.AddReservation();
                    } catch
                    {
                        Console.WriteLine("Дата некоректно введена попробуйте снова");
                        Console.WriteLine(" ");
                    }
                }

                if (control == "6")
                {
                    reservationManager = new ReservationManager();
                    Thread.Sleep(300);
                    if (reservationManager.reservations.Count == 0)
                    {
                        Console.WriteLine("Ни одной брони нет в списке");
                        Console.WriteLine(" ");
                    }
                    else
                    {
                        int numbReserv = 0;
                        foreach (Reservation reserv in reservationManager.reservations)
                        {
                            Console.WriteLine($"{numbReserv + 1}. {reserv.ClientCurrent.Name} {reserv.HotelCurrent.Name} - {reserv.HotelCurrent.Country}");
                            Console.WriteLine($"с {reserv.CheckInDate} по {reserv.CheckOutDate} ");
                        }

                        Console.Write("Введите номер брони:");
                        string numbReserv2 = Console.ReadLine();
                        numbReserv = int.Parse(numbReserv2);
                        reservationManager.RemoveReservation(reservationManager.reservations[numbReserv - 1].IdReservation);
                        Console.WriteLine("Теперь на эту дату отель забронирует кто то другой :)");
                        Console.WriteLine(" ");
                    }
                }
            }
        }
        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);
        }