示例#1
0
        public static XDoc AppendRatingXml(XDoc doc, PageBE page, UserBE user)
        {
            bool endDoc = false;

            if (doc == null)
            {
                doc = new XDoc("rating");
            }
            else
            {
                doc.Start("rating");
                endDoc = true;
            }

            RatingComputedBE ratingEffective = DbUtils.CurrentSession.Rating_GetResourceRating(page.ID, RatingBE.Type.PAGE);
            RatingBE         userRating      = null;

            if (ratingEffective != null)
            {
                doc.Attr("score", ratingEffective.Score)
                .Attr("score.trend", ratingEffective.ScoreTrend)
                .Attr("count", ratingEffective.Count)
                .Attr("date", ratingEffective.Timestamp);

                userRating = DbUtils.CurrentSession.Rating_GetUserResourceRating(user.ID, page.ID, RatingBE.Type.PAGE);
                if (userRating != null)
                {
                    doc.Start("user.ratedby")
                    .Attr("id", user.ID)
                    .Attr("score", userRating.Score.ToString())
                    .Attr("date", userRating.Timestamp)
                    .Attr("href", UserBL.GetUri(user))
                    .End();
                }
            }
            else
            {
                // No ratings exist for page: Output placeholder
                doc.Attr("score", string.Empty)
                .Attr("count", 0);
            }

            if (endDoc)
            {
                doc.End(); // rating
            }

            return(doc);
        }
示例#2
0
 public XUri GetUri(UserBE user)
 {
     return(UserBL.GetUri(user));
 }