public ActionResult AddComment(long orderId, List <OrderDetailEntity> list)
        {
            bool flag = false;
            var  user = this.LoginUser;

            if (user == null)
            {
                return(JsonCResult(flag));
            }
            OrderService service = new OrderService();
            var          model   = service.GetModel(orderId);

            if (model == null)
            {
                return(JsonCResult(flag));
            }
            List <ProductComment> cList = new List <ProductComment>();

            foreach (var item in list)
            {
                if (string.IsNullOrWhiteSpace(item.CommentContent))
                {
                    item.CommentContent = "该用户很懒,没有留下任何内容。";
                }
                cList.Add(new ProductComment {
                    StateFlag = 1, Contents = item.CommentContent, CreateTime = DateTime.Now, OrderNum = model.OrderNo, ProductId = item.ProductId, UserId = user.UserId
                });
            }
            if (cList.Count > 0)
            {
                flag = new ProductCommentService().Add(cList);
            }
            return(JsonCResult(flag));
        }
Esempio n. 2
0
        public ActionResult GetCommentList(CommentRequest page)
        {
            int recordCount = 0;
            var list        = new ProductCommentService().GetCommentList(page.ProductId, page.PageIndex, page.PageSize, out recordCount);
            int count       = SysHelper.GetPageCount(recordCount, page.PageSize);
            var data        = new PageReturnEntity <List <CommentInfoEntity> > {
                PageCount = count, Data = list
            };

            return(JsonCResult(data));
        }
        public ProductInfo(Frame frame, product selectedProduct)
        {
            InitializeComponent();

            Rating = 50;

            MainFrame       = frame;
            Service         = new ProductCommentService();
            productComments = Service.SelectProductComments(selectedProduct).Select(p => new CommentsView()
            {
                Text   = p.text,
                MarkId = p.comment_mark
            })
                              .ToList();

            BitmapImage negativeImg = new BitmapImage(new Uri("C:\\neg.png"));
            BitmapImage positiveImg = new BitmapImage(new Uri("C:\\p.png"));
            BitmapImage neutralImg  = new BitmapImage(new Uri("C:\\n.png"));



            foreach (var comment in productComments)
            {
                if (comment.MarkId == 1)
                {
                    Rating           += 0.25;
                    comment.ImageMark = positiveImg;
                }
                else if (comment.MarkId == 2)
                {
                    Rating           -= 0.35;
                    comment.ImageMark = negativeImg;
                }
                else
                {
                    comment.ImageMark = neutralImg;
                }
            }
            commentsGrid.ItemsSource = productComments;
            TitleDisplay.Text        = selectedProduct.name;
            DescriptionDisplay.Text  = selectedProduct.description;
            DeveloperDisplay.Text    = selectedProduct.developer.name;
            PriceDisplay.Text        = "$" + selectedProduct.price.ToString();
            RatignDisplay.Text       = "Rating: " + Rating;
        }