public async Task <IEnumerable <IFavoriteItem> > GetFavorites() { if (Items == null) { Items = new FavoriteSerializer().Deserialize(await LocalStorageRepository.GetItem(LocalStorageFavoritesName)).ToList(); } return(Items.ToArray()); }
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); }