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; }
public SupportedDirectionsViewModel(SupportedDirectionsResponse supportedDirectionsResponse) { _supportedDirectionsResponse = supportedDirectionsResponse != null ? supportedDirectionsResponse : new SupportedDirectionsResponse(); }
public SupportedDirectionsViewModel() { _supportedDirectionsResponse = new SupportedDirectionsResponse(); }