/// <summary> /// 评论照片动态 /// </summary> /// <param name="ActivityId"></param> /// <returns></returns> //[DonutOutputCache(CacheProfile = "Frequently")] public ActionResult _CommentPhoto(long ActivityId) { //实例化动态 Activity activity = activityService.Get(ActivityId); if (activity == null) { return(Content(string.Empty)); } ViewData["Activity"] = activity; //实例化评论 PagingDataSet <Comment> commentPaging = commentService.GetRootComments(TenantTypeIds.Instance().Photo(), activity.ReferenceId, 1, SortBy_Comment.DateCreatedDesc); //去掉评论作者相同的评论然后取前3个 IEnumerable <long> commentUserIds = commentPaging.AsEnumerable().Select(n => n.UserId).Distinct().Take(3); List <Comment> commentList = new List <Comment>(); foreach (var commentUserId in commentUserIds) { commentList.Add(commentPaging.First(n => n.UserId == commentUserId)); } IEnumerable <Comment> comments = commentList.AsEnumerable(); if (comments == null) { return(Content(string.Empty)); } ViewData["CommentCount"] = commentPaging.Count(); //实例化照片 Photo photo = photoService.GetPhoto(activity.ReferenceId); if (photo == null) { return(Content(string.Empty)); } ViewData["Photo"] = photo; return(View(comments)); }