Esempio n. 1
0
        async Task ExecuteLoadCitiesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Cities.Clear();

                var cities = await CitiesService.GetCitiesAsync();

                Parallel.ForEach(cities.Data, city =>
                {
                    Cities.Add(city);
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 2
0
        public void GetCitiesAsyncTest()
        {
            base.ClearAll();

            var mockHttpService = new HttpService();

            Ioc.RegisterSingleton <IHttpService>(mockHttpService);

            var mockJsonConverter = new JsonConverter();

            Ioc.RegisterSingleton <IJsonConverter>(mockJsonConverter);

            var service = new CitiesService(mockHttpService, mockJsonConverter);

            NUnit.Framework.Assert.IsNotNull(service.GetCitiesAsync("Belarus").Result);
        }
Esempio n. 3
0
        private async Task SetCitiesToAsync()
        {
            var citiesService = new CitiesService(_httpService, _jsonConverter);

            _dataOfFlights.CountryTo = SelectedCountryTo;
            var citiesTo = await citiesService.GetCitiesAsync(SelectedCountryTo);

            if (citiesTo != null)
            {
                ItemsCitiesTo.AutoCompleteList.Clear();
                ItemsCitiesTo.AutoCompleteList = citiesTo;
                IsAirportToExist        = true;
                _dataOfFlights.CitiesTo = citiesTo;
                RaisePropertyChanged(() => ItemsCitiesTo);
            }
            else
            {
                IsAirportToExist        = false;
                _dataOfFlights.CitiesTo = null;
            }
        }