Exemple #1
0
 /// <summary>
 /// Loads all available ratings for the current page.
 /// </summary>
 public virtual PageModel WithRatings()
 {
     // Get all ratings
     using (var api = new Api()) {
         Ratings = RatingsModel.GetByModelId(api, Id);
     }
     return(this);
 }
Exemple #2
0
 /// <summary>
 /// Loads all available ratings for the posts in the archive.
 /// </summary>
 public virtual ArchiveModel WithRatings()
 {
     // Get all ratings
     using (var api = new Api()) {
         foreach (var post in Posts)
         {
             post.Ratings = RatingsModel.GetByModelId(api, post.Id);
         }
     }
     return(this);
 }
Exemple #3
0
        /// <summary>
        /// Loads all available comments for the current post.
        /// </summary>
        /// <param name="ratings">If ratings should be included</param>
        public virtual PostModel WithComments(bool ratings = false)
        {
            // Get all comments
            using (var api = new Api()) {
                Comments = Mapper.Map <IEnumerable <Comment>, IEnumerable <CommentModel> >(api.Comments.Get(where : c => c.PostId == Id)).ToList();

                if (ratings)
                {
                    foreach (var comment in Comments)
                    {
                        comment.Ratings = RatingsModel.GetByModelId(api, comment.Id);
                    }
                }
            }
            return(this);
        }