public ActionResult QueryByProductCommentID([DataSourceRequest] DataSourceRequest request, int pcId)
        {
            var service = new ProductCommentReplyService();
            var list = service.QueryByCommentID(pcId);

            if (list != null)
            {
                var modelList = new List<ProductCommentReplyModel>();

                foreach (var comment in list)
                {
                    var cmt = DataTransfer.Transfer<ProductCommentReplyModel>(comment, typeof(Product_Comment_Reply));
                    modelList.Add(cmt);
                }

                var dataSource = new DataSource() { Data = modelList };

                return Json(dataSource, JsonRequestBehavior.AllowGet);
            }

            return Json(null);
        }
Пример #2
0
        public JsonResult GetProductComment(int productID, int pageIndex, int pageSize)
        {
            try
            {
                var paging = new Paging(
                    "[view_product_Comment]",
                    null,
                    null,
                    "ProductID = " + productID,
                    pageIndex,
                    pageSize,
                    "[CreateTime]",
                    1);
                int pageCount, totalCount;
                var comment = new ProductCommentService().QueryWithPaging(
                    paging,
                    out pageCount,
                    out totalCount);
                if (comment == null)
                {
                    return this.Json(null);
                }

                var commentList = new List<ProductCommentModel>();
                foreach (var productComment in comment)
                {
                    commentList.Add(DataTransfer.Transfer<ProductCommentModel>(productComment, typeof(Product_Comment)));
                }

                foreach (var commentReplt in commentList)
                {
                    var commentReplyList = new ProductCommentReplyService().QueryByCommentID(commentReplt.ID);
                    var replys = new List<ProductCommentReplyModel>();
                    foreach (var commentReply in commentReplyList)
                    {
                        replys.Add(
                             DataTransfer.Transfer<ProductCommentReplyModel>(
                                 commentReply,
                                 typeof(Product_Comment_Reply)));
                    }

                    commentReplt.CommentReplys = replys;
                }

                return this.Json(new { data = commentList, rowsCount = totalCount });
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
        public ActionResult RemoveProductCommentReply([DataSourceRequest] DataSourceRequest request, int id)
        {
            var service = new ProductCommentReplyService();
            service.Remove(id);

            return Json(null);
        }