public async Task DeleteSavedArticleAsync(Article article) { if (article == null) { return; } try { SavedArticles.Find(o => o.ArticleId == article.ArticleId).IsSaved = false; await SaveSavedArticlesAsync(); SavedArticles.Remove(article); CurrentSavedArticle = SavedArticles.Count > 0 ? SavedArticles[0] : null; UpdateSavedArticleMoveStates(); NotifyCurrentSavedArticleChanged(CurrentSavedArticle); NotifySavedArticlesChanged(); } catch (Exception exception) { if (Debugger.IsAttached) { Debug.WriteLine("DataService:" + exception); } } }
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 Article GetSavedArticlesFromId(string id) { if (SavedArticles != null) { CurrentSavedArticle = SavedArticles.Find(o => o.ArticleId == id); UpdateSavedArticleMoveStates(); return(CurrentSavedArticle); } else { return(null); } }