public async Task LoadSavedArticlesAsync() { if (SavedArticles == null) { SavedArticles = new List <Article>(); } try { var articles = await DatabaseOperations.GetInstance().GetSavedArticlesAsync(); if (articles == null || articles.Count <= 0) { return; } articles = articles.OrderByDescending(o => o.PublishDate).ToList(); foreach (var article in articles.Where(article => SavedArticles.Find(o => o.ArticleId == article.ArticleId) == null)) { SavedArticles.Add(article); } } catch (Exception exception) { if (Debugger.IsAttached) { Debug.WriteLine("DataService:" + exception); } } NotifySavedArticlesChanged(); }
public async Task SaveCurrentArticleAsync(Article article) { try { if (IsArticleAlreadySaved(article)) { return; } CanSaveCurrentArticle = false; article.IsSaved = true; SavedArticles.Add(article); await SaveSavedArticlesAsync(); NotifySavedArticlesChanged(); } catch (Exception exception) { if (Debugger.IsAttached) { Debug.WriteLine("DataService:" + exception); } } }