예제 #1
0
        private async Task GetAutocomplete()
        {
            try
            {
                if (Filter.Length > 0)
                {
                    var response = await _travelPayoutsApi.GetPlaces(Filter);

                    AirportsAutocomplete = new MvxObservableCollection <AutocompleteIataItem>(response.Select(i => new AutocompleteIataItem(i)));
                }
                else
                {
                    AirportsAutocomplete.Clear();
                }
            }catch
            {
            }
        }
예제 #2
0
        public async Task Search(string code = null)
        {
            AirportsAutocomplete.Clear();
            EmptyVisibility = false;
            Airports.Clear();
            SearchProgressVisibility = true;
            AirportsVisibility       = false;
            try
            {
                SupportedDirectionsResponse response = null;
                if (!string.IsNullOrEmpty(code))
                {
                    response = await _aviasalesApi.GetSupportedDirections(code);
                }
                else if (!string.IsNullOrEmpty(Filter))
                {
                    response = await _aviasalesApi.GetSupportedDirections(Filter);
                }
                Airports = new MvxObservableCollection <IataItem>(response.Directions.Select(d => new IataItem(d)));

                _directions = response.Directions;
                var markers = response.Directions.Where(d => d.Coordinates[0].HasValue && d.Coordinates[1].HasValue).Select(w => new Marker(w.Iata, w.Coordinates));
                _mvxMessenger.Publish(new CreateMarkersMessage(this, markers));
                if (Airports.Count == 0)
                {
                    AirportsVisibility = false;
                    EmptyVisibility    = true;
                }
                else
                {
                    AirportsVisibility = true;
                    EmptyVisibility    = false;
                }
            }
            catch
            {
                EmptyVisibility    = true;
                AirportsVisibility = false;
            }
            SearchProgressVisibility = false;
        }