Esempio n. 1
0
        public async Task getSummAsync()
        {
            grouped = new ObservableCollection <GroupedSearchesAndFavorites>();
            var searchesGroup = new GroupedSearchesAndFavorites {
                LongName = "Favorite", ShortName = "F"
            };

            for (int i = 0; i < App.FavoriteDatabase.GetItems().Count; i++)
            {
                if (App.FavoriteDatabase.GetItems()[i].Name != "")
                {
                    var reg = regFromString(App.FavoriteDatabase.GetItems()[i].Region.ToLower());
                    var sum = await api.GetSummonerAsync(reg, App.FavoriteDatabase.GetItems()[i].summonerID);

                    if (sum.Name == App.FavoriteDatabase.GetItems()[i].Name)
                    {
                        searchesGroup.Add(App.FavoriteDatabase.GetItems()[i]);
                    }
                    else
                    {
                        App.FavoriteDatabase.DeleteItem(i + 1);
                        icon = string.Format(icon, sum.Region, sum.Id);
                        var newItem = new SearchesAndFavorites {
                            Name = sum.Name, Region = sum.Region.ToString().ToUpper(), Icon = icon, summonerID = (int)sum.Id
                        };
                        App.FavoriteDatabase.SaveItem(newItem);
                        searchesGroup.Add(newItem);
                        icon = iconReset;
                    }
                }
            }
        }
Esempio n. 2
0
		public int SaveItem(SearchesAndFavorites item)
		{
			lock (locker)
			{
				if (item.ID != 0)
				{
					database.Update(item);
					return item.ID;
				}
				else {
					return database.Insert(item);
				}
			}
		}