コード例 #1
0
        /// <summary>
        /// 根据用户ID获取最佳评论/回答
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="priseEnumType"></param>
        /// <param name="bestornice">1最佳解答 2最优解答</param>
        /// <param name="paging"></param>
        /// <returns></returns>
        public MyCommentsViewModel GetBestAnswersByUserID(long userID, PriseEnumType priseEnumType, int bestornice, Paging paging)
        {
            MyCommentsViewModel model = new MyCommentsViewModel();
            DataSet             ds    = dal.GetBestAnswersByUserID(userID, priseEnumType.GetHashCode(), bestornice, paging.StartIndex, paging.EndIndex);
            int recordCount           = Convert.ToInt32(ds.Tables[0].Rows[0][0]);

            if (recordCount > 0)
            {
                paging.RecordCount = recordCount;
                model.CommentPage  = paging;
                model.CommentList  = ModelConvertHelper <_MyComments> .ConvertToList(ds.Tables[1]);

                model.CommentHeadUrl = ds.Tables[2].Rows[0][0].ToString();
            }
            return(model);
        }
コード例 #2
0
        /// <summary>
        /// 根据用户ID获取评论/回答
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="answerPage"></param>
        /// <returns></returns>
        public MyCommentsViewModel GetCommentListByUserid(long userID, CommentEnumType commentEnumType, Paging answerPage, long currentLoginUserID)
        {
            MyCommentsViewModel amodel   = new MyCommentsViewModel();
            DataSet             ds       = dal.GetCommentListByUserid(userID, commentEnumType.GetHashCode(), answerPage.StartIndex, answerPage.EndIndex, currentLoginUserID, UserBaseBLL.Instance.IsMaster);
            DataTable           answerdt = ds.Tables[1];

            if (answerdt.IsNotNullAndRowCount())
            {
                answerPage.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                amodel.CommentPage     = answerPage;
                amodel.CommentList     = ModelConvertHelper <_MyComments> .ConvertToList(answerdt);

                amodel.CommentHeadUrl = ds.Tables[2].Rows[0][0].ToString();
            }
            return(amodel);
        }
コード例 #3
0
 public IActionResult MyComments(MyCommentsViewModel vm)
 {
     if (ModelState.IsValid)
     {
         var userId = _userManager.GetUserId(User);
         vm.Comments = _commentService.GetByUserId(userId);
         ICollection <Product> products = new List <Product>();
         foreach (var comment in vm.Comments)
         {
             var product = _productService.GetById(comment.productId);
             if (!(products.Contains(product)))
             {
                 products.Add(product);
             }
         }
         vm.Products = products;
     }
     return(View(vm));
 }