예제 #1
0
    private void FillGridComment()
    {
        Product_Comment      ac2 = new Product_Comment();
        Product_CommentDatum dm2 = new Product_CommentDatum();

        dm2.Id_Product = decimal.Parse(Request.QueryString["ID_Product"].ToString());

        GridView2.DataSource = ac2.select_product_comment_show_true(dm2);
        GridView2.DataBind();
    }
예제 #2
0
    protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
    {
        PublicClass          p   = new PublicClass();
        Product_Comment      ac2 = new Product_Comment();
        Product_CommentDatum dm2 = new Product_CommentDatum();

        dm2.Title        = TextBox4.Text;
        dm2.Email        = TextBox3.Text;
        dm2.NameUser     = TextBox2.Text;
        dm2.Text         = TextBox1.Text;
        dm2.Date_Send    = p.GetDate();
        dm2.Show_Comment = "false";
        dm2.Id_Product   = decimal.Parse(Request.QueryString["ID_Product"].ToString());
        ac2.Insert(dm2);
        Label11.Visible = true;
        TextBox4.Text   = "";
        TextBox3.Text   = "";
        TextBox2.Text   = "";
        TextBox1.Text   = "";
    }
예제 #3
0
 public IHttpActionResult SaveProductComment([FromBody] dynamic Json)
 {
     if (Json == null)
     {
         return(Ok(new { success = false, message = "评价信息不存在!" }));
     }
     try
     {
         if (string.IsNullOrWhiteSpace(Convert.ToString(Json.CommentContent)))
         {
             return(Ok(new { success = false, message = "评价内容不能为空!" }));
         }
         if (string.IsNullOrWhiteSpace(Convert.ToString(Json.CommentLevel)))
         {
             return(Ok(new { success = false, message = "评价等级不能为空!" }));
         }
         if (string.IsNullOrEmpty(Convert.ToString(Json.OrderID)))
         {
             return(Ok(new { success = false, message = "传入订单ID为空!" }));
         }
         if (string.IsNullOrEmpty(Convert.ToString(Json.ProductId)))
         {
             return(Ok(new { success = false, message = "传入商品ID为空!" }));
         }
         Guid order_id   = Guid.Parse(Convert.ToString(Json.OrderID));
         Guid product_id = Guid.Parse(Convert.ToString(Json.ProductId));
         var  lst        = db.Product_Comments.Where(p => p.OrderID == order_id && p.ProductId == product_id).ToList();
         if (lst != null && lst.Count > 0)
         {
             return(BadRequest("提示,您已经填写了本次订单商品的评论!"));
         }
         Guid            NewId   = Guid.NewGuid();
         Product_Comment comment = new Product_Comment();
         comment.Id             = NewId;
         comment.CommentContent = Convert.ToString(Json.CommentContent);
         comment.CommentLevel   = (CommentLevels)Convert.ToInt32(Json.CommentLevel);
         comment.CreateTime     = DateTime.Now;
         comment.IsAnonymous    = Convert.ToBoolean(Json.IsAnonymous);
         comment.OpenId         = WeiChatApplicationContext.Current.WeiChatUser.OpenId;
         comment.OrderID        = order_id;
         comment.ProductId      = product_id;
         comment.TenantId       = WeiChatApplicationContext.Current.WeiChatUser.TenantId;
         db.Product_Comments.Add(comment);
         Order_Detail detail = db.Order_Details.FirstOrDefault(p => p.OrderID == order_id && p.ProductID == product_id);
         log.Log(LoggerLevels.Debug, NewId.ToString());
         detail.CommentId = NewId;
         //需要更新商品的评价数
         Product_Info product = db.Product_Infos.FirstOrDefault(p => p.Id == product_id);
         if (product == null)
         {
             return(BadRequest("提示,商品信息已删除,无法评论!"));
         }
         product.CommentCount = product.CommentCount + 1;
         db.SaveChanges();
         return(Ok(comment));
     }
     catch (Exception ea)
     {
         log.Log(LoggerLevels.Error, "api/Product/SaveProductComment:" + ea.Message);
         return(BadRequest("系统异常,请联系管理员!"));
     }
 }