Exemple #1
0
        /// <summary>
        /// Gets all the comments for the specified Content.
        /// </summary>
        /// <param name="filter">Filter which comments to be fetched</param>
        /// <param name="pageDetails">Details about the pagination</param>
        /// <returns>List of all comments of the Content</returns>
        public async Task<IEnumerable<CommentDetails>> GetContentComments(CommentFilter filter, PageDetails pageDetails)
        {
            this.CheckNotNull(() => new { filter, pageDetails });

            Func<ContentComments, object> orderBy = (contentComments) => contentComments.CommentDatetime;
            Expression<Func<ContentComments, bool>> condition = (contentComments) => contentComments.ContentID == filter.EntityId && contentComments.IsDeleted == false;

            IEnumerable<ContentComments> comments =  _contentCommentsRepository
                .GetItems(condition, orderBy, filter.OrderType == OrderType.NewestFirst, (pageDetails.CurrentPage - 1) * pageDetails.ItemsPerPage, pageDetails.ItemsPerPage);

            var commentDetails = new List<CommentDetails>();
            if (comments != null)
            {
                foreach (var item in comments)
                {
                    var comment = new CommentDetails();
                    Mapper.Map(item, comment);
                    commentDetails.Add(comment);
                }
            }

            return commentDetails;
        }
Exemple #2
0
        /// <summary>
        /// Gets all the comments for the specified Community.
        /// </summary>
        /// <param name="filter">Filter which comments to be fetched</param>
        /// <param name="pageDetails">Details about the pagination</param>
        /// <returns>List of all comments of the Community</returns>
        public async Task<IEnumerable<CommentDetails>> GetCommunityComments(CommentFilter filter, PageDetails pageDetails)
        {
            this.CheckNotNull(() => new { filter, pageDetails });

            Func<CommunityComments, object> orderBy = (communityComments) => communityComments.CommentedDatetime;
            Expression<Func<CommunityComments, bool>> condition = (communityComments) => communityComments.CommunityID == filter.EntityId && communityComments.IsDeleted == false;

            // Gets the total items satisfying the
            var totalItemsForCondition = _communityCommentRepository.GetItemsCount(condition);
            pageDetails.TotalPages = (totalItemsForCondition / pageDetails.ItemsPerPage) + ((totalItemsForCondition % pageDetails.ItemsPerPage == 0) ? 0 : 1);

            IEnumerable<CommunityComments> comments =  _communityCommentRepository
                .GetItems(condition, orderBy, filter.OrderType == OrderType.NewestFirst, (pageDetails.CurrentPage - 1) * pageDetails.ItemsPerPage, pageDetails.ItemsPerPage);

            var commentDetails = new List<CommentDetails>();
            if (comments != null)
            {
                foreach (var item in comments)
                {
                    var comment = new CommentDetails();
                    Mapper.Map(item, comment);
                    commentDetails.Add(comment);
                }
            }

            return commentDetails;
        }
Exemple #3
0
        /// <summary>
        /// Gets the total number of content comments for the given filter.
        /// </summary>
        /// <param name="filter">Filter which comments to be fetched</param>
        /// <returns>total number of content comments.</returns>
        public int GetTotalContentComments(CommentFilter filter)
        {
            this.CheckNotNull(() => new { filter });

            Expression<Func<ContentComments, bool>> condition = (contentComments) => contentComments.ContentID == filter.EntityId && contentComments.IsDeleted == false;
            return _contentCommentsRepository.GetItemsCount(condition);
        }