Ejemplo n.º 1
0
 public AwfulBookmarkPage(AwfulControlPanel cp)
     : base(cp, 1, Constants.USERCP_URI)
 {
 }
Ejemplo n.º 2
0
 public void UpdateUserBookmarksAsync(AwfulProfile user, bool refresh, Action<AwfulProfile> result)
 {
     // check database first
     var bookmarks = new List<AwfulThreadBookmark>();
     if (!refresh)
     {
         user = this.GetProfileByUsername(user.Username);
         bookmarks.AddRange(user.ThreadBookmarks);
     }
     if (bookmarks.IsNullOrEmpty())
     {
         // fetch from web
         AwfulForumPage cp = new AwfulControlPanel().GetBookmarks();
         cp.RefreshAsync(cpRefreshed =>
             {
                 using (var dao = new AwfulProfileDAO())
                 {
                     var profile = dao.SaveBookmarksToProfile(user, cpRefreshed.Threads);
                     if (profile == null)
                     {
                         // if we're here, then there's a database issue, but the show must go on
                         using (var dao2 = new AwfulProfileDAO())
                         {
                             user = dao2.GetProfileByUsername(user.Username);
                             user.AddRangeToBookmarks(cpRefreshed.Threads);
                             result(user);
                         }
                     }
                     else { result(profile); }
                 }
             });
     }
     else
     {
         result(user);
     }
 }