Esempio n. 1
0
        public static async Task <City> SetActualCity()
        {
            try
            {
                var position = await GeolocatorHelper.GetCurrentPositionAsync();

                var cityService = new CityRest();
                var cityName    = await cityService.GetCityNameAsync(position.Latitude, position.Longitude);

                cityName = string.IsNullOrWhiteSpace(cityName) ? DefaultSetting.City.Name : cityName;

                var result = await cityService.GetCityAsync(cityName.Trim());

                var city = result.Value ?? DefaultSetting.City;
                ApplicationManager <City> .AddOrUpdate("city", city);

                return(city);
            }
            catch (Exception ex)
            {
                var exception = DependencyService.Get <IExceptionService>();
                exception.TrackError(ex, "SetActualCity");
                return(DefaultSetting.City);
            }
        }
Esempio n. 2
0
        public async Task <City> GetByNameAsync(string search)
        {
            var service = new CityRest();
            var city    = await service.GetCityAsync(search);

            return(city);
        }