Exemplo n.º 1
0
        /// <summary>
        ///  添加回复
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public OperationResult <AddReplyCommonEntity> ArticleReply_Insert(EventItemReplyEntity entity)
        {
            try
            {
                AddReplyCommonEntity acEntity = new AddReplyCommonEntity();
                ReplyCommonEntity    rcEntity = new ReplyCommonEntity();
                using (SqlConnection con = new SqlConnection(SQlHelper.MyConnectStr))
                {
                    SqlTransaction trans = null;
                    con.Open();
                    trans = con.BeginTransaction();
                    DateTime?      nowDate = entity.ReplyTime == null ? DateTime.Now : entity.ReplyTime;
                    SqlParameter[] prms    =
                    {
                        new SqlParameter("@ReplyID",       entity.ReplyID),
                        new SqlParameter("@CommentID",     entity.CommentID),
                        new SqlParameter("@UserID",        entity.UserID),
                        new SqlParameter("@IsAnonymous",   entity.IsAnonymous),
                        new SqlParameter("@ReplyParentID", entity.ReplyParentID),
                        new SqlParameter("@ReplyContent",  entity.ReplyContent),
                        new SqlParameter("@ReplyTime",     nowDate),
                        new SqlParameter("@CheckTypeID",   entity.CheckTypeID),
                        new SqlParameter("@ViewStateID",   entity.ViewStateID)
                    };
                    SqlParameter[] commPrms =
                    {
                        new SqlParameter("@CommentID", entity.CommentID),
                        new SqlParameter("@UserID",    entity.UserID),
                    };

                    prms[0].Direction = ParameterDirection.Output;
                    int state = SQlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "M_EventItemReply_Insert", prms);
                    trans.Commit();

                    DataTable table = SQlHelper.ExecuteDataset(SQlHelper.MyConnectStr, CommandType.StoredProcedure, "M_ReplyCommon_Get", commPrms).Tables[0];
                    if (table != null && table.Rows.Count != 0)
                    {
                        rcEntity = ConvertDataTable <ReplyCommonEntity> .ConvertToList(table)[0];
                    }
                    acEntity.ReplyID         = prms[0].Value.ToInt();
                    acEntity.ReplyTime       = nowDate;
                    acEntity.ReviewLikeCount = rcEntity.ReviewLikeCount;
                    acEntity.IsReviewLike    = rcEntity.IsReviewLike;
                    acEntity.ReplyCount      = rcEntity.ReplyCount;
                    if (state > 0)
                    {
                        return(new OperationResult <AddReplyCommonEntity>(OperationResultType.Success, "回复完成!", acEntity));
                    }
                    else
                    {
                        return(new OperationResult <AddReplyCommonEntity>(OperationResultType.NoChanged, "评论已被删除,无法回复!", acEntity));
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.WriteLog(ex);
                return(new OperationResult <AddReplyCommonEntity>(OperationResultType.NoConnection, Description.EnumDescription(OperationResultType.NoConnection)));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 评论点赞插入
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public OperationResult <ReplyCommonEntity> CommentsLike_Insert(CommentLikeEntity entity)
        {
            try
            {
                ReplyCommonEntity rcEntity = new ReplyCommonEntity();
                using (SqlConnection con = new SqlConnection(SQlHelper.MyConnectStr))
                {
                    SqlTransaction trans = null;
                    con.Open();
                    trans = con.BeginTransaction();

                    SqlParameter[] prms =
                    {
                        new SqlParameter("@CommentID", entity.CommentID),
                        new SqlParameter("@UserID",    entity.UserID),
                        new SqlParameter("@LikeCnt",   entity.LikeCnt),
                        new SqlParameter("@LikeTime",  entity.LikeTime == null ? DateTime.Now :entity.LikeTime)
                    };
                    SqlParameter[] commPrms =
                    {
                        new SqlParameter("@CommentID", entity.CommentID),
                        new SqlParameter("@UserID",    entity.UserID)
                    };
                    int state = SQlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "M_Comments_Like_Insert", prms);
                    trans.Commit();

                    DataTable table = SQlHelper.ExecuteDataset(SQlHelper.MyConnectStr, CommandType.StoredProcedure, "M_ReplyCommon_Get", commPrms).Tables[0];
                    if (table != null && table.Rows.Count != 0)
                    {
                        rcEntity = ConvertDataTable <ReplyCommonEntity> .ConvertToList(table)[0];
                    }
                    if (state > 0)
                    {
                        return(new OperationResult <ReplyCommonEntity>(OperationResultType.Success, "评论点赞成功!", rcEntity));
                    }
                    else
                    {
                        return(new OperationResult <ReplyCommonEntity>(OperationResultType.NoChanged, "您已点过赞了!", rcEntity));
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.WriteLog(ex);
                return(new OperationResult <ReplyCommonEntity>(OperationResultType.NoConnection, Description.EnumDescription(OperationResultType.NoConnection)));
            }
        }