public void deleteComment_Res(long commentId) { try { _commentResRepository.Db.Ado.BeginTran(); //删除评论 _commentResRepository.DeleteByKey(commentId); //删除对应的所有回复[ccCommentReply_Res] _commentReplyResRepository.DeleteAllReplyByCommentId(commentId); //删除评论点赞 _praizeRepository.DeletePraized_Comment_Res(commentId, null); //删除评论对应的所有回复 点赞 _praizeRepository.DeletePraized_AllReplyBelowComment(commentId); _commentResRepository.Db.Ado.CommitTran(); } catch (Exception ex) { _commentResRepository.Db.Ado.RollbackTran(); NLogUtil.cc_ErrorTxt("CommentServices deleteComment_Res:" + ex.Message); throw new Exception("删除评论失败"); } }
private long handPraize_Comment(SubmitPraize submitPraize) { DbResult <bool> transResult = null; long resultId = 0; if (submitPraize.praizeDirection == OperationDirection.plus) { if (_praizeRepository.HasPraized_Comment_Res(Convert.ToInt64(submitPraize.refCode), submitPraize.userId).Result > 0) { return(0); } EPraize_Comment praize = new EPraize_Comment { praizeDate = DateTime.Now, PraizeType = PraizeType.good, commentId = Convert.ToInt64(submitPraize.refCode), userId = submitPraize.userId, RefCode = submitPraize.parentRefCode, bookCode = submitPraize.bookCode, }; transResult = _praizeRepository.Db.Ado.UseTran(() => { resultId = _praizeRepository.AddPraize_Comment(praize); _praizeRepository.UpdateCommentPraized_GoodNum(Convert.ToInt64(submitPraize.refCode), OperationDirection.plus); }); } else { transResult = _praizeRepository.Db.Ado.UseTran(() => { _praizeRepository.DeletePraized_Comment_Res(Convert.ToInt64(submitPraize.refCode), submitPraize.userId); _praizeRepository.UpdateCommentPraized_GoodNum(Convert.ToInt64(submitPraize.refCode), OperationDirection.minus); }); } if (transResult != null && !transResult.IsSuccess) { throw new Exception(transResult.ErrorMessage); } return(resultId); }