private void GetCountriesList(Action <BackendResult <CountriesResponse, ResultCode> > callback) { VKRequestsDispatcher.DispatchRequestToVK <VKList <Country> >("database.getCountries", new Dictionary <string, string>(), (Action <BackendResult <VKList <Country>, ResultCode> >)(res => { if (res.ResultCode == ResultCode.Succeeded) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["need_all"] = "1"; parameters["count"] = "500"; VKRequestsDispatcher.DispatchRequestToVK <VKList <Country> >("database.getCountries", parameters, (Action <BackendResult <VKList <Country>, ResultCode> >)(res1 => { CountriesResponse resultData = null; if (res.ResultCode == ResultCode.Succeeded) { resultData = new CountriesResponse() { countriesNearby = res.ResultData.items, countries = res1.ResultData.items }; this._cachedCountries = resultData; } callback(new BackendResult <CountriesResponse, ResultCode>(res1.ResultCode, resultData)); }), null, false, true, new CancellationToken?(), null); } else { callback(new BackendResult <CountriesResponse, ResultCode>(res.ResultCode, null)); } }), null, false, true, new CancellationToken?(), null); }
private void GetCountriesListWithExecute(Action <BackendResult <CountriesResponse, ResultCode> > callback) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["code"] = "var countriesNearby = API.database.getCountries().items;\r\n var countries = API.database.getCountries({\"need_all\": 1, \"count\": 500}).items;\r\n return {\"countriesNearby\": countriesNearby, \"countries\": countries};"; VKRequestsDispatcher.DispatchRequestToVK <CountriesResponse>("execute", parameters, (Action <BackendResult <CountriesResponse, ResultCode> >)(res => { if (res.ResultCode == ResultCode.Succeeded) { this._cachedCountries = res.ResultData; } callback(res); }), null, false, true, new CancellationToken?(), null); }
public override async Task <CountriesResponse> GetCountryByCode( IAsyncStreamReader <GetCountryByCodeRequest> requestStream, ServerCallContext context) { var countriesResponse = new CountriesResponse(); while (await requestStream.MoveNext()) { var request = requestStream.Current; var response = CompaniesMock().SingleOrDefault(m => m.Code.Equals(request.Code, StringComparison.InvariantCultureIgnoreCase)); if (response != null) { countriesResponse.Countries.Add(response); } } return(countriesResponse); }
public List <Country> GetListOfCountries() { List <Country> result = new List <Country>(); try { CountriesResponse response = JsonConvert.DeserializeObject <CountriesResponse>(Get(Routes.CountriesList().Value).Result); foreach (var item in response.countries) { result.Add(new Country(item)); } } catch (Exception ex) { throw ex; } return(result); }
public async Task <IHttpActionResult> GetAllCountries() { var countries = await _countriesService.GetAllCountries(); var res = new CountriesResponse { Countries = countries.Select(x => new CountryResponse { Name = x, Links = new List <LinkResponse> { new LinkResponse { Rel = "cities", Href = _routeProvider.Route(this, "GetCitiesByCountry", new { country = x }) } } }).ToList() }; return(Ok(res)); }
private void MoveMapToCurrentPosition() { Country = JsonConvert.DeserializeObject <CountriesResponse>(Settings.Country); //await _geolocatorService.GetLocationAsync(); double latitude = Convert.ToDouble(Country.Latlng.First()); double longitude = Convert.ToDouble(Country.Latlng.Last()); if (latitude != 0 && longitude != 0) { var position = new Position( latitude, longitude); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius( position, Distance.FromKilometers(200))); MyMap.Pins.Add(new Pin { Label = Country.Name, Position = new Position(latitude, longitude), Type = PinType.SearchResult }); } }
private void ReceiveCountriesResponse(CountriesResponse response) { PutResult(response); }