private void LoadLocalData()
        {
            using (var data = new Store.LocalStore())
            {
                try
                {
                    Loading = true;
                    var result = new ObservableCollection <ZipCodeInfo>(data.DataConnection.Table <ZipCodeInfo>().OrderByDescending(x => x.CEP).ToList());
                    Locations = new ObservableCollection <LocationZipCode>();

                    if (result != null)
                    {
                        CenteredReference = new Position(result.FirstOrDefault().Latitude, result.FirstOrDefault().Longitude);
                        foreach (var item in result)
                        {
                            Locations.Add(new LocationZipCode
                            {
                                Position = new Xamarin.Forms.Maps.Position(item.Latitude, item.Longitude),
                                Address  = item.CEP
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
                finally
                {
                    Loading = false;
                }
            }
        }
 public void LoadItemId(string itemId)
 {
     using (var data = new Store.LocalStore())
     {
         try
         {
             Item = data.DataConnection.Table <ZipCodeInfo>().FirstOrDefault(x => x.CEP == itemId);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
         }
     }
 }
Esempio n. 3
0
 private void LoadLocalData()
 {
     using (var data = new Store.LocalStore())
     {
         try
         {
             Loading = true;
             Items   = new ObservableCollection <ZipCodeInfo>(data.DataConnection.Table <ZipCodeInfo>().OrderByDescending(x => x.CEP).ToList());
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
         }
         finally
         {
             Loading = false;
         }
     }
 }