/// <summary> /// 修改商品评价状态 /// </summary> /// <param name="productComment"> /// 更新对象 /// </param> public void ModifytCommentStatus(Product_Comment productComment) { this.productCommentDA.UpdateCommentStatus(productComment); }
/// <summary> /// 添加评论. /// </summary> /// <param name="productComment"> /// Product_Comment. /// </param> /// <returns> /// 评论的编号. /// </returns> public int Add(Product_Comment productComment) { return this.productCommentDA.Insert(productComment); }
/// <summary> /// 添加评论. /// </summary> /// <param name="productComment"> /// Product_Comment. /// </param> /// <returns> /// 评论的编号. /// </returns> public int Insert(Product_Comment productComment) { if (productComment == null) { throw new ArgumentNullException("productComment"); } var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "ProductID", SqlDbType.Int, productComment.ProductID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "OrderID", SqlDbType.Int, productComment.OrderID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "UserID", SqlDbType.Int, productComment.UserID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Score", SqlDbType.Int, productComment.Score, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Status", SqlDbType.Int, productComment.Status, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Content", SqlDbType.VarChar, productComment.Content, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "ReferenceID", SqlDbType.Int, null, ParameterDirection.Output) }; this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Product_Comment_Insert", parameters, null); return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value; }
public JsonResult AddComment(int score, int productID, string content) { try { var userID = this.GetUserID(); if (userID <= 0) { return this.Json(new AjaxResponse(2, "未登录!")); } // 商品ID、会员ID 查询订单 var orderCount = new OrderProductService().QueryByProductIDAndUserID(productID, userID); if (orderCount <= 0) { return this.Json(new AjaxResponse(3, "未购买过!")); } var commentReply = new Product_Comment { UserID = userID, ProductID = productID, Content = content, Status = 1, Score = score }; commentReply.ID = new ProductCommentService().Add(commentReply); return this.Json(new AjaxResponse(1, "评论成功!")); } catch (Exception exception) { return this.Json(new AjaxResponse(0, "评论失败!:" + exception.Message)); } }
/// <summary> /// 更新商品评价状态 /// </summary> /// <param name="model"> /// 需更新的商品评价对象 /// </param> public void UpdateCommentStatus(Product_Comment model) { var paras = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "ID", SqlDbType.Int, model.ID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Status", SqlDbType.Int, model.Status, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "AuditDescription", SqlDbType.NVarChar, model.AuditDescription, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "EmployeeID", SqlDbType.Int, model.EmployeeID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "AuditTime", SqlDbType.DateTime, DateTime.Now, ParameterDirection.Input) }; try { this.SqlServer.ExecuteNonQuery( CommandType.StoredProcedure, "sp_Product_Comment_UpdateStatus", paras, null); } catch (Exception exception) { throw new Exception("Exception - ProductComment - UpdateCommentStatus", exception); } }