private RatingComputedBE Rating_PopulateRatingComputed(IDataReader dr) { RatingComputedBE rc = new RatingComputedBE { Id = dr.Read <uint>("ratingscomputed_id"), ResourceId = dr.Read <uint>("ratingscomputed_resource_id"), ResourceType = (RatingBE.Type)dr.Read <byte>("ratingscomputed_resource_type"), Score = dr.Read <float>("ratingscomputed_score"), ScoreTrend = dr.Read <float>("ratingscomputed_score_trend"), Count = dr.Read <uint>("ratingscomputed_count"), Timestamp = dr.Read <DateTime>("ratingscomputed_timestamp") }; return(rc); }
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); }
public RatingComputedBE Rating_GetResourceRating(ulong resourceId, RatingBE.Type resourceType) { RatingComputedBE rc = null; string query = @" /* RatingDA::Rating_GetResourceRating */ SELECT * FROM ratingscomputed WHERE ratingscomputed_resource_id = ?RATINGSCOMPUTED_RESOURCE_ID AND ratingscomputed_resource_type = ?RATINGSCOMPUTED_RESOURCE_TYPE; "; Catalog.NewQuery(query) .With("RATINGSCOMPUTED_RESOURCE_ID", resourceId) .With("RATINGSCOMPUTED_RESOURCE_TYPE", (byte)resourceType) .Execute(delegate(IDataReader dr) { if (dr.Read()) { rc = Rating_PopulateRatingComputed(dr); } }); return(rc); }
private RatingComputedBE Rating_PopulateRatingComputed(IDataReader dr) { RatingComputedBE rc = new RatingComputedBE { Id = dr.Read<uint>("ratingscomputed_id"), ResourceId = dr.Read<uint>("ratingscomputed_resource_id"), ResourceType = (RatingBE.Type)dr.Read<byte>("ratingscomputed_resource_type"), Score = dr.Read<float>("ratingscomputed_score"), ScoreTrend = dr.Read<float>("ratingscomputed_score_trend"), Count = dr.Read<uint>("ratingscomputed_count"), Timestamp = dr.Read<DateTime>("ratingscomputed_timestamp") }; return rc; }