Beispiel #1
0
        public Mutation(HotelRepository hotelRepository)
        {
            Field <HotelType>("createHotel",
                              arguments: new QueryArguments(new QueryArgument <NonNullGraphType <CreateHotelCommandType> >
            {
                Name = "command"
            }),
                              resolve: context =>
            {
                var command = context.GetArgument <CreateHotelCommand>("command");
                return(hotelRepository.AddHotel(command));
            });

            Field <HotelType>("addRoom",
                              arguments: new QueryArguments(
                                  new QueryArgument <NonNullGraphType <AddRoomCommandType> > {
                Name = "command"
            }),
                              resolve: context =>
            {
                var command = context.GetArgument <AddRoomCommand>("command");

                var hotel    = hotelRepository.GetById(command.HotelId);
                var newHotel = new Hotel(hotel.Id, hotel.Name, new List <Room>(hotel.Rooms)
                {
                    command.Room
                });
                return(hotelRepository.UpdateHotel(newHotel));
            });
        }
        public async Task AddHotel(Hotel newHotel, string travelIdentity)
        {
            var hotel        = HotelConverter.ToDbHotel(newHotel);
            var hotelDetails = await HotelsApiClient.GetHotelDetails(hotel.DestinationId);

            await HotelRepository.AddHotel(hotel, travelIdentity);

            foreach (var location in hotelDetails.Transportation.TransportLocations)
            {
                var transports        = location.Locations.Select(l => HotelConverter.ToDbTransportLocation(l));
                var transportCategory = new DbHotelTransport {
                    Category = location.Category
                };
                await HotelRepository.AddHotelTransport(hotel.HotelId, transportCategory, transports);
            }
        }
Beispiel #3
0
 public bool AddHotel(string name, double rat, string country)
 {
     if (!String.IsNullOrWhiteSpace(name) || !String.IsNullOrWhiteSpace(country) || rat != 0)
     {
         Hotel newHotel = new Hotel(name, rat, country);
         repo.AddHotel(newHotel);
         Thread newFlow = new Thread(GetHotels);
         newFlow.Start();
         return(true);
     }
     else
     {
         Console.WriteLine("Не все данные отеля указаны!");
         return(false);
     }
 }
Beispiel #4
0
 public void AddHotel(Guid hotelId, string name)
 {
     hotelRepository.AddHotel(hotelId, name);
 }
        private void ApplicationControl()
        {
            HotelRepository hotelRepository = new HotelRepository();

            ConsoleView.DisplayWelcomeScreen();

            using (hotelRepository)
            {
                List <Hotel> hotels = hotelRepository.GetAllHotels();

                int    hotelID;
                Hotel  hotel;
                string message;

                while (active)
                {
                    AppEnum.ManagerAction userActionChoice;


                    userActionChoice = ConsoleView.GetUserActionChoice();

                    switch (userActionChoice)
                    {
                    case AppEnum.ManagerAction.None:
                        break;

                    case AppEnum.ManagerAction.ListAllHotels:
                        ConsoleView.DisplayAllHotels(hotels);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.DisplayHotelDetail:
                        hotelID = ConsoleView.GetHotelID(hotels);

                        ConsoleView.DisplayHotelDetail(hotelRepository.GetHotelByID(hotelID));
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.DeleteHotel:
                        hotelID = ConsoleView.GetHotelID(hotels);

                        hotelRepository.DeleteHotel(hotelID);
                        ConsoleView.DisplayReset();
                        message = String.Format("Hotel ID: {0} has been deleted from the list.", hotelID);
                        ConsoleView.DisplayMessage(message);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.AddHotel:
                        hotel = ConsoleView.AddHotel();
                        hotelRepository.AddHotel(hotel);

                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.UpdateHotel:
                        hotelID = ConsoleView.GetHotelID(hotels);
                        hotel   = hotelRepository.GetHotelByID(hotelID);

                        hotel = ConsoleView.UpdateHotels(hotel);

                        hotelRepository.UpdateHotel(hotel);
                        break;

                    case AppEnum.ManagerAction.QueryHotelsByRoomsAvilable:
                        List <Hotel> matchinghotels = new List <Hotel>();

                        int minimumRoomsAvailable;
                        int maximumRoomsAvailable;
                        ConsoleView.GetRoomsAvailableQueryMinMaxValues(out minimumRoomsAvailable, out maximumRoomsAvailable);

                        matchinghotels = hotelRepository.QueryByRoomsAvailable(minimumRoomsAvailable, maximumRoomsAvailable);
                        ConsoleView.DisplayQueryResults(matchinghotels);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.Quit:
                        active = false;
                        break;

                    default:
                        break;
                    }
                }
            }

            ConsoleView.DisplayExitPrompt();
        }
Beispiel #6
0
 public void AddHotel(HotelDetailsViewModel hotelDetailsViewModel)
 {
     _hotelRepository.AddHotel(hotelDetailsViewModel);
 }