Example #1
0
        /// <summary>
        /// 为商品添加评论信息
        /// </summary>
        /// <param name="CommentShop">商品评论实体</param>
        /// <returns></returns>
        public async Task <IActionResult> AddComment(CommentShop CommentShop)
        {
            CommentShop.user_id = return_front_userid();
            var data = await commentService.AddComment(CommentShop);

            return(Json(data));
        }
        public IActionResult AnswerComment(CommentClient cc)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }


            CommentShop.Create(cc.ID_comment_client, cc.CommentShop.Comment_shop);

            return(Redirect("Comment"));
        }
        //[Authorize]
        public IActionResult DeleteAnswerComment(string ID_comment_shop, string ID_comment_client)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }



            CommentShop.Delete(ID_comment_shop, ID_comment_client);

            var referrer = Request.Headers["Referer"];

            return(Redirect(referrer));
        }
Example #4
0
        public async Task <BaseResult <bool> > AddComment(CommentShop CommentShop)
        {
            //首先修改订单子表中的评论状态为已评论,添加评论表并且添加图片表信息
            var isOrderDetail = await orderDetailRepository.UpdateAsync(new OrderDetailEntity()
            {
                orderdetail_id = CommentShop.orderdetail_id, orderdetail_evaluate = 2
            }, false, true, c => c.orderdetail_evaluate);

            CommentEntity commentEntity = new CommentEntity()
            {
                user_id      = CommentShop.user_id,
                shop_id      = CommentShop.shop_id,
                shopsku_id   = CommentShop.shopsku_id,
                comment_star = CommentShop.comment_star,
                comment_desc = CommentShop.comment_desc,
                createtime   = DateTime.Now,
                disable      = (int)DisableStatus.disable_false
            };
            var isComment = await commentRepository.AddAsync(commentEntity, false);

            if (CommentShop.image_url != null && CommentShop.image_url.Count > 0)
            {
                List <CommentImageEntity> commentImages      = new List <CommentImageEntity>();
                CommentImageEntity        commentImageEntity = null;
                foreach (var image_url in CommentShop.image_url)
                {
                    commentImageEntity                 = new CommentImageEntity();
                    commentImageEntity.comment_id      = commentEntity.comment_id;
                    commentImageEntity.comment_address = image_url;
                    commentImages.Add(commentImageEntity);
                }
                var isCommentImage = await commentImageRepository.AddListAsync(commentImages, false);
            }

            if (unitOfWork.SaveCommit())
            {
                return(new BaseResult <bool>(200, true));
            }
            return(new BaseResult <bool>(201, false));
        }
        public void GetCommentShop(string connectionString, string id_shop)
        {
            Comments = new List <CommentClient>();
            SqlConnection connection = new SqlConnection(connectionString);


            string sqlExpression = @"SELECT 
                    COMCL.ID_comment_client,
                    COMCL.ID_shop,
                    COMCL.Email,
                    COMCL.Name,
                    COMCL.Comment,
                    COMCL.Count_star,
                    COMCL.Date_add,
                    CS.ID_comment_shop,
                    CS.Comment AS comment_shop,
                    CS.Date_add AS Date_add_shop

                        FROM SPAVREMONT.Comment_Client COMCL
                    LEFT JOIN SPAVREMONT.Comment_shop CS ON CS.id_comment_shop=COMCL.id_comment_shop
                    WHERE COMCL.id_shop='" + id_shop + @"'
                        AND COMCL.DELETED=0
                        AND COMCL.VISIBLE=1
                    ORDER BY COMCL.Date_add DESC
                    ";

            connection.Open();
            SqlCommand command = new SqlCommand();

            command.CommandText = sqlExpression;
            command.Connection  = connection;
            SqlDataReader reader = command.ExecuteReader();

            if (reader.HasRows) // если есть данные
            {
                //int genreIDIndex = reader.GetOrdinal("GenreID");
                //...
                //while...
                //GenreID = reader.IsDBNull(genreIDIndex) ? null : reader.GetInt32(genreIDIndex)

                int ccID_comment_clientIndex = reader.GetOrdinal("ID_comment_client");
                int ccID_shopIndex           = reader.GetOrdinal("ID_shop");
                int ccEmailIndex             = reader.GetOrdinal("Email");
                int ccNameIndex            = reader.GetOrdinal("Name");
                int ccCommentIndex         = reader.GetOrdinal("Comment");
                int ccCount_starIndex      = reader.GetOrdinal("Count_star");
                int ccDate_addIndex        = reader.GetOrdinal("Date_add");
                int csID_comment_shopIndex = reader.GetOrdinal("ID_comment_shop");
                int csCommentShopIndex     = reader.GetOrdinal("comment_shop");
                int csDate_add_shopIndex   = reader.GetOrdinal("Date_add_shop");



                while (reader.Read()) // построчно считываем данные
                {
                    CommentShop comment_shop = new CommentShop
                    {
                        ID_comment_shop = reader.IsDBNull(csID_comment_shopIndex) ? null : reader.GetString(csID_comment_shopIndex),
                        Comment         = reader.IsDBNull(csCommentShopIndex) ? null : reader.GetString(csCommentShopIndex)
                    };

                    if (!reader.IsDBNull(csDate_add_shopIndex))// если дата существует в запросе
                    {
                        comment_shop.Date_add = reader.GetDateTime(csDate_add_shopIndex);
                    }

                    CommentClient itemCommentClient = new CommentClient
                    {
                        Comment      = reader.IsDBNull(ccCommentIndex) ? null : reader.GetString(ccCommentIndex),
                        Comment_shop = comment_shop,
                        Count_star   = reader.IsDBNull(ccCount_starIndex) ? 0 : reader.GetByte(ccCount_starIndex),
                        Date_add     = reader.GetDateTime(ccDate_addIndex),
                        //Email= reader.IsDBNull(ccCommentIndex) ? null : reader.GetString(ccCommentIndex),// аноним для всех, виден только для магазина
                        ID_comment_client = reader.IsDBNull(ccID_comment_clientIndex) ? null : reader.GetString(ccID_comment_clientIndex),
                        ID_shop           = reader.IsDBNull(ccID_shopIndex) ? null : reader.GetString(ccID_shopIndex),
                        Name = reader.IsDBNull(ccNameIndex) ? null : reader.GetString(ccNameIndex)
                    };

                    Comments.Add(itemCommentClient);
                }



                //return shops;
            }
        }