Beispiel #1
0
        public decimal GetOverrallFeedbackByContext(Enums.ContextType contextType, Guid contextId)
        {
            decimal returnVal;

            List <Comment> comments = CommentDAO.SelectCommentListByContext((int)contextType, contextId);

            comments.RemoveAll(comm => comm.CommentTypeId != (int)Enums.CommentType.Feedback);

            decimal totalFeedbackScore = 0;

            foreach (Comment comment in comments)
            {
                if (comment.RatingValue > 0)
                {
                    totalFeedbackScore += comment.RatingValue;
                }
            }

            if (totalFeedbackScore > 0)
            {
                returnVal = totalFeedbackScore / comments.Count();
            }
            else
            {
                returnVal = 0.1M;
            }

            return(returnVal);
        }