Inheritance: ViewModelBase
Beispiel #1
0
 public static void Merge(this MetaData metaData, MetaData newData)
 {
     if (newData == null)
     {
         return;
     }
     Task.Run(async () =>
     {
         await DispatcherHelper.RunAsync(() =>
         {
             metaData.ApiVersion = newData.ApiVersion;
             metaData.Reference = newData.Reference;
             metaData.ServerVersion = newData.ServerVersion;
         });
     });
     Parallel.ForEach(newData.Cities, async (city) =>
     {
         await DispatcherHelper.RunAsync(() =>
         {
             var existingCity = metaData.Cities.FirstOrDefault(x => x.Id == city.Id);
             if (existingCity == null)
             {
                 var index = newData.Cities.IndexOf(city);
                 metaData.Cities.Insert(index, city);
             }
             else
             {
                 existingCity.Coordinates = city.Coordinates;
                 existingCity.Name = city.Name;
                 existingCity.Source = city.Source;
                 existingCity.Url = city.Url;
             }
         });
     });
     Parallel.ForEach(metaData.Cities.Where(existingCity => newData.Cities.FirstOrDefault(x => x.Id == existingCity.Id) == null).ToList(), async (existingLot) =>
     {
         await DispatcherHelper.RunAsync(() => {
             metaData.Cities.Remove(existingLot);
         });
     });
 }
Beispiel #2
0
 private MetaDataCityRow FindCityById(MetaData metaData, string id)
 {
     return metaData?.Cities?.Get(id);
 }
Beispiel #3
0
 private MetaDataCityRow FindCityByName(MetaData metaData, string name)
 {
     return metaData?.Cities?.FirstOrDefault(x => x.Name.ToLower().Equals(name.ToLower()));
 }