Beispiel #1
0
        public async Task <IEnumerable <IFavoriteItem> > GetFavorites()
        {
            if (Items == null)
            {
                Items = new FavoriteSerializer().Deserialize(await LocalStorageRepository.GetItem(LocalStorageFavoritesName)).ToList();
            }

            return(Items.ToArray());
        }
Beispiel #2
0
        private async Task <FavoriteItem> ProcessChanges(FavoriteItem item, Func <FavoriteItem, List <FavoriteItem>, IEnumerable <FavoriteItem> > action)
        {
            await GetFavorites();

            Items = action(item, Items).ToList();

            var serializedFavorites = new FavoriteSerializer().Serialize(Items);
            await LocalStorageRepository.SetItem(LocalStorageFavoritesName, serializedFavorites);

            FavoritesChanged?.Invoke(this, EventArgs.Empty);
            return(item);
        }