Пример #1
0
        public static async Task <IList <City> > GetAsync()
        {
            try
            {
                var rest   = new CityRest();
                var result = await rest.GetAsync(string.Empty);

                if (result.IsValid)
                {
                    SetLocalCities(result.Value);
                    return(result.Value);
                }
                else
                {
                    return(GetLocalCities());
                }
            }
            catch (Exception ex)
            {
                var exception = DependencyService.Get <IExceptionService>();
                exception.TrackError(ex, "AccountManager.GetAsync");
                return(new List <City> {
                    DefaultSetting.City
                });
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        public async Task <string> GetCityName(double latitude, double longitude)
        {
            var service  = new CityRest();
            var cityName = await service.GetCityName(latitude, longitude);

            return(cityName);
        }
Пример #4
0
        public async Task <City> GetByNameAsync(string search)
        {
            var service = new CityRest();
            var city    = await service.GetCityAsync(search);

            return(city);
        }
Пример #5
0
        public static async Task <IList <City> > GetHasHistoricalSightAsync()
        {
            var rest   = new CityRest();
            var cities = await rest.GetHasHistoricalSightAsync() ?? GetLocalCities();

            SetLocalCities(cities);
            return(cities);
        }
Пример #6
0
        public static async Task <IList <City> > GetHasCompanyAsync(int subCategoryId)
        {
            var rest   = new CityRest();
            var cities = await rest.GetHasCompanyAsync(subCategoryId) ?? GetLocalCities();

            SetLocalCities(cities);
            return(cities);
        }
Пример #7
0
        public static async Task <IList <City> > GetAsync()
        {
            var rest   = new CityRest();
            var cities = await rest.GetAsync(string.Empty) ?? GetLocalCities();

            SetLocalCities(cities);
            return(cities);
        }
Пример #8
0
        public async Task <IList <City> > GetHasHistoricalSightAsync()
        {
            var service = new CityRest();
            var items   = await service.GetHasHistoricalSightAsync();

            ApplicationManager <string> .AddOrUpdate("cities", items);

            return(items.OrderBy(o => o.Name).ToList());
        }
Пример #9
0
        public async Task <IList <City> > GetHasCompanyAsync(int subCategoryId)
        {
            var service = new CityRest();
            var items   = await service.GetHasCompanyAsync(subCategoryId);

            ApplicationManager <string> .AddOrUpdate("cities", items);

            return(items.OrderBy(o => o.Name).ToList());
        }
Пример #10
0
        public static async Task <IList <City> > GetHasEventAsync()
        {
            var rest   = new CityRest();
            var result = await rest.GetHasEventAsync();

            if (result.IsValid)
            {
                SetLocalCities(result.Value);
                return(result.Value);
            }
            else
            {
                return(GetLocalCities());
            }
        }
Пример #11
0
        public static async Task <IList <City> > GetHasCompanyAsync(int subCategoryId)
        {
            var rest   = new CityRest();
            var result = await rest.GetHasCompanyAsync(subCategoryId);

            if (result.IsValid)
            {
                SetLocalCities(result.Value);
                return(result.Value);
            }
            else
            {
                return(GetLocalCities());
            }
        }