Beispiel #1
0
        public static void Add(DTO.OrderComment model, int productNum)
        {
            var info = model.Map <Himall.Entities.OrderCommentInfo>();

            _tradeCommentService.AddOrderComment(info, productNum);
            model.Id = info.Id;
        }
        public static void Add(DTO.OrderComment model)
        {
            var info = model.Map <Model.OrderCommentInfo>();

            _tradeCommentService.AddOrderComment(info);
            model.Id = info.Id;
        }
        public JsonResult AddOrderEvaluationAndComment(int packMark, int deliveryMark, int serviceMark, long orderId, string productCommentsJSON)
        {
            if (packMark != 0 || deliveryMark != 0 || serviceMark == 0)
            {
                var info = new DTO.OrderComment();
                info.UserId       = CurrentUser.Id;
                info.PackMark     = packMark;
                info.DeliveryMark = deliveryMark;
                info.ServiceMark  = serviceMark;
                info.OrderId      = orderId;
                TradeCommentApplication.Add(info);
            }

            var productComments = JsonConvert.DeserializeObject <List <ProductCommentsModel> >(productCommentsJSON);
            var list            = new List <DTO.ProductComment>();

            foreach (var productComment in productComments)
            {
                var model = new ProductComment();
                model.ReviewDate    = DateTime.Now;
                model.ReviewContent = productComment.content;
                model.UserId        = CurrentUser.Id;
                model.UserName      = CurrentUser.UserName;
                model.Email         = CurrentUser.Email;
                model.SubOrderId    = productComment.subOrderId;
                model.ReviewMark    = productComment.star;
                if (productComment.proimages != null && productComment.proimages.Length > 0)
                {
                    model.Images = new List <ProductCommentImage>();
                    foreach (var img in productComment.proimages)
                    {
                        var p = new ProductCommentImage();
                        p.CommentType  = 0;                       //0代表默认的表示评论的图片
                        p.CommentImage = MoveImages(img, CurrentUser.Id);
                        model.Images.Add(p);
                    }
                }

                list.Add(model);
            }
            var comments = CommentApplication.GetProductEvaluationByOrderIdNew(orderId, CurrentUser.Id);

            foreach (var item in comments)
            {
                var addComment = productComments.FirstOrDefault(e => e.subOrderId == item.Id);
                if (addComment != null)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "您已进行过评价!", status = -1
                    }));
                }
            }
            CommentApplication.Add(list);

            return(Json(new Result()
            {
                success = true, msg = "评价成功"
            }));
        }
 public JsonResult AddOrderEvaluation(DTO.OrderComment model)
 {
     model.UserId = CurrentUser.Id;
     TradeCommentApplication.Add(model);
     return(Json(new Result()
     {
         success = true, msg = "评价成功"
     }));
 }