/// <summary>
        /// Adds a Reservation to the list and repo.
        /// </summary>
        private void AddReservation()
        {
            if (CurrentReservation.Client != null)
            {
                return;                                    // We don't want an empty reservation :)
            }
            if (!Reservations.Contains(CurrentReservation))
            {
                Reservations.Add(CurrentReservation);
            }
            _reservationManager.AddReservation(CurrentReservation);

            CurrentReservation = new Reservation();
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a Reservation to the list and repo.
        /// </summary>
        public void AddReservation()
        {
            if (ReservationInfo == null)
            {
                CreateReservationInfo();
            }

            var reservation = new Reservation(CurrentClient, CurrentCar, ReservationInfo);

            this.CurrentReservation = reservation;
            if (CurrentReservation.Client == null)
            {
                return;                                    // We don't want an empty reservation :)
            }
            if (!Reservations.Contains(CurrentReservation))
            {
                Reservations.Add(CurrentReservation);
            }
            _reservationManager.AddReservation(CurrentReservation);
        }
Esempio n. 3
0
        public override async Task <ReservationDto> InsertReservation(ReservationDto request, ServerCallContext context)
        {
            try {
                var resrvation = request.ConvertToEntity();
                var response   = await reservationenManager.AddReservation(resrvation);

                return(response.ConvertToDto());
            } catch (Exception e)
            {
                if (e is InvalidDateRangeException)
                {
                    throw new RpcException(new Status(StatusCode.OutOfRange, e.Message));
                }

                if (e is AutoUnavailableException)
                {
                    throw new RpcException(new Status(StatusCode.ResourceExhausted, e.Message));
                }
                throw new RpcException(new Status(StatusCode.Internal, e.Message));
            }
        }
Esempio n. 4
0
        public ActionResult Receipt(string[] rooms_list)
        {
            // Je récupère toutes les informations dont j'ai besoin pour créer une réservation
            DateTime dateReservation = DateTime.Today;
            string   clientFirstname = Request["firstname"];
            string   clientLastname  = Request["lastname"];
            DateTime dateStart       = Convert.ToDateTime(Session["dateStart"]);
            DateTime dateEnd         = Convert.ToDateTime(Session["dateEnd"]);
            decimal  totalPrice      = Convert.ToDecimal(Request["totalPrice"]);

            // Je crée la nouvelle réservation en passant les informations ci-dessus en paramètres (et je récupère son identifiant)
            int idReservation = ReservationManager.AddReservation(dateReservation, clientFirstname, clientLastname, dateStart, dateEnd, totalPrice);

            // Pour chaque élément de la liste, je crée une ligne dans ReservationDetails
            foreach (string element in rooms_list)
            {
                Room    room     = RoomManager.GetRoom(Convert.ToInt16(element));
                int     idRoom   = Convert.ToInt16(element);
                decimal price    = room.Price;
                decimal increase = 0;

                if (Session["increase"].ToString() == "true")
                {
                    increase = price * 20 / 100;
                }

                ReservationDetailsManager.AddReservationDetails(idReservation, idRoom, price, increase);
            }

            // Je passe ensuite les informations dans un ViewModel, afin de pouvoir afficher la quittance de réservation à l'utilisateur
            ReservationVM reservation = new ReservationVM
            {
                IdReservation   = idReservation,
                Gender          = Request["gender"],
                ClientFirstname = clientFirstname,
                ClientLastname  = clientLastname
            };

            return(View(reservation));
        }
Esempio n. 5
0
        public ActionResult Create(ReservationVM reservation)
        {
            if (ModelState.IsValid)
            {
                TempData["ReservationId"] = ReservationManager.AddReservation(
                    reservation.Firstname,
                    reservation.Lastname,
                    reservation.Arrival,
                    reservation.Departure,
                    reservation.RoomIds
                    );

                TempData["Firstname"] = reservation.Firstname;
                TempData["Lastname"]  = reservation.Lastname;

                return(RedirectToAction("Index", "Hotel"));
            }

            TempData["ViewData"] = ViewData;

            return(RedirectToAction("Hotel"));
        }
Esempio n. 6
0
 public void insertReservation(ReservationDto reservation)
 {
     WriteActualMethod();
     try
     {
         _reservationManager.AddReservation(reservation.ConvertToEntity());
     }
     catch (AutoUnavailableException)
     {
         AutoUnavailableFault fault = new AutoUnavailableFault()
         {
             Operation = "insert reservation"
         };
         throw new FaultException <AutoUnavailableFault>(fault);
     }
     catch (InvalidDateRangeException)
     {
         InvalidDateRangeFault fault = new InvalidDateRangeFault()
         {
             Operation = "insert reservation"
         };
         throw new FaultException <InvalidDateRangeFault>(fault);
     }
 }
Esempio n. 7
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);
        }