public async void LoadHotelsAsync()
        {
            var HotelList = await PersistanceService.LoadHotelsFromJsonAsync();

            foreach (var hotel in HotelList)
            {
                Hotels.Add(hotel);
            }
        }
        private async void LoadHotelsAsync()
        {
            List <Hotel> hotels = await new PersistenceFacade().GetAllAsync();

            foreach (Hotel h in hotels)
            {
                Hotels.Add(h);
            }
            //Hotels = new ObservableCollection<Hotel>(hotels);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Проверка заполнения обязательных полей и добавление локации в базу данных.
        /// </summary>
        /// <returns>True - если все обязательные поля заполнены и локация добавлена в БД. False - если заполнены не все обязательные поля или возникла ошибка при добавлении данных в БД.</returns>
        private bool AddLocation()
        {
            if (LocationNameTextBox.TextLength > 0 && LocationNameTextBox.Text != LocationNameTextBox.Tag.ToString() &&
                RoomCountTextBox.TextLength > 0 && RoomCountTextBox.Text != RoomCountTextBox.Tag.ToString() &&
                BedsCountTextBox.TextLength > 0 && BedsCountTextBox.Text != BedsCountTextBox.Tag.ToString() &&
                CheckRoomsData())    // Если все обязательные поля заполнены.
            {
                long locationId = Locations.Add(LocationNameTextBox.Text.Trim());
                if (locationId >= 0)
                {
                    long hotelId = Hotels.Add(locationId, Customer.Id, Convert.ToInt32(RoomCountTextBox.Text), Convert.ToInt32(BedsCountTextBox.Text), Convert.ToInt32(CardCountTextBox.Text));
                    if (hotelId >= 0)
                    {
                        for (int i = 0; i < RoomsDataGridView.RowCount; i++)
                        {
                            string roomName  = RoomsDataGridView["RoomNumber", i].Value.ToString().Trim();
                            string bedsCount = RoomsDataGridView["BedsCount", i].Value.ToString().Trim();

                            if (Hotels.FindRoom(roomName, hotelId, out long roomId)) // Если в БД есть такие комнаты.
                            {
                                Hotels.EditRoom(roomId, roomName, Convert.ToInt64(bedsCount));
                            }
                            else
                            {
                                Hotels.AddRoom(hotelId, roomName, Convert.ToInt32(bedsCount));
                            }
                        }

                        LocationsDataGridView.DataSource = Hotels.GetAll(Customer.Id);

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        private void InitHotels()
        {
            List <string> existingHotels = new List <string>();
            string        sql            = $"SELECT DISTINCT hotel_code FROM include WHERE pass_number = {StationManager.SelectedPass.PassNumber}";
            MySqlCommand  comand         = new MySqlCommand(sql, ConnectionManager.Connection);

            using (MySqlDataReader reader = comand.ExecuteReader())
            {
                while (reader.Read())
                {
                    existingHotels.Add(reader.GetString(0));
                }
            }
            foreach (Hotel hotel in StationManager.DataStorage.GetHotels())
            {
                if (!existingHotels.Contains(hotel.HotelCode))
                {
                    Hotels.Add(hotel);
                }
            }
        }
Ejemplo n.º 5
0
        public void Handle(HotelCreated e)
        {
            Hotels.Add(new Hotel
            {
                Id           = e.HotelId,
                TournamentId = e.Id,
                Name         = e.Name,
                Website      = e.Website,
                PhoneNumber  = e.PhoneNumber,
                RoomTypes    = e.RoomTypes
            });

            Storage.Create(new TSHotelLogo
            {
                Id       = e.HotelId,
                Contents = e.Logo
            });

            Storage.Create(new TSHotelImage
            {
                Id       = e.HotelId,
                Contents = e.Image
            });
        }
Ejemplo n.º 6
0
 public void addHotel(HotelApplication h)
 {
     Hotels.Add(h);
 }
Ejemplo n.º 7
0
        public async Task Init()
        {
            var countries = await _countryService.Get <List <CountryDTO> >(null);

            foreach (var country in countries)
            {
                Countries.Add(country);
            }


            var hotelData    = (await _hotelService.Get <List <HotelDTO> >(null)).OrderByDescending(_ => _.TotalVisits).Take(5);
            var tCompanyData = (await _tCompanyService.Get <List <TransportCompanyDTO> >(null)).OrderByDescending(_ => _.TotalReservations).Take(5);

            foreach (var hotel in hotelData)
            {
                Hotels.Add(hotel);
            }
            foreach (var tcompany in tCompanyData)
            {
                Transports.Add(tcompany);
            }

            int visits       = 0;
            var reservations = await _reservationService.Get <List <ReservationDTO> >(null);

            foreach (var item in reservations)
            {
                visits += item.NumberOfPersons;
            }
            AllTimeVisits = visits;

            //Dictionary<int, int> topOffers = new Dictionary<int, int>();
            //Dictionary<int, int> bestHotels = new Dictionary<int, int>();
            //Dictionary<int, int> bestTransports = new Dictionary<int, int>();

            //#region hotels
            //foreach (var hOffer in hOffers)
            //{
            //    var reservations = (await _reservationService.Get<List<ReservationDTO>>(new ReservationSearchRequest { HotelOfferId = hOffer.Id})).Count;

            //    if (topOffers.ContainsKey(hOffer.HotelId))
            //    {
            //        topOffers[hOffer.HotelId] += reservations;
            //    }
            //    else
            //    {
            //        topOffers.Add(hOffer.HotelId, reservations);
            //    }
            //}
            //var offers = bestOffer(ref topOffers, bestHotels);

            //foreach (var hotel in offers)
            //{
            //    var bestHotel = await _hotelService.GetById<HotelDTO>(hotel.Key);
            //    Hotels.Add(bestHotel);
            //}
            //#endregion



            //#region transports

            //foreach (var tOffer in tOffers)
            //{
            //    var reservations = (await _reservationService.Get<List<ReservationDTO>>(new ReservationSearchRequest {TransportOfferId = tOffer.Id})).Count;

            //    if (topOffers.ContainsKey(tOffer.TransportCompanyId))
            //    {
            //        topOffers[tOffer.TransportCompanyId] += reservations;
            //    }
            //    else
            //    {
            //        topOffers.Add(tOffer.TransportCompanyId, reservations);
            //    }
            //}


            //offers = bestOffer(ref topOffers, bestTransports);

            //foreach (var transport in offers)
            //{
            //    var bestTransport = await _tCompanyService.GetById<TransportCompanyDTO>(transport.Key);
            //    Transports.Add(bestTransport);
            //}
            //#endregion
        }
Ejemplo n.º 8
0
        public void load()
        {
            Thread.Sleep(3000);

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\170575461.jpg",
                    Name    = "Hotel : Pensione Guerrato",
                    Address = "Address : San Polo 240/A, San Polo, 30125 Venice, Italy",
                    Price   = "190 $"
                });


                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\170575461.jpg",
                    Name    = "Hotel : Pensione Guerrato",
                    Address = "Address : San Polo 240/A, San Polo, 30125 Venice, Italy",
                    Price   = "190 $"
                });

                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\11129086.jpg",
                    Name    = "Hotel : Tivoli",
                    Address = "Address : Crosera San Pantalon-Dorsoduro, 30123 Venice, Italy",
                    Price   = "202 $"
                });

                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\115470246.jpg",
                    Name    = "Hotel : Locanda Silva",
                    Address = "Address : Castello 4423, Castello, 30122 Venice, Italy",
                    Price   = "250 $"
                });


                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\81893385.jpg",
                    Name    = "Hotel : Antico Mercato",
                    Address = "Address : Calle prima de la donzella 290, San Polo",
                    Price   = "290 $"
                });

                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\139875486.jpg",
                    Name    = "Hotel :  Il Moro di Venezia",
                    Address = "Address : Lista di Spagna 152, Cannaregio",
                    Price   = "132 $"
                });

                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\97919768.jpg",
                    Name    = "Hotel : Preference Hualing Tbilisi",
                    Address = "Address : Jozef Pilsudski Avenue, Tbilisi Sea New City, 0152",
                    Price   = "246 $"
                });

                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\11278896.jpg",
                    Name    = "Hotel : Anantara Riverside Bangkok",
                    Address = "Address : 257 Charoennakorn Road, Samrae, Thonburi",
                    Price   = "332 $"
                });

                Hotels.Add(new HotelInfo
                {
                    photo   = @"Images\116338281.jpg",
                    Name    = "Hotel : Riad El Walida",
                    Address = "Address : 12 Touareg Berrima, 40040 Marrakech, Morocco",
                    Price   = "198 $"
                });
            }));
        }