コード例 #1
0
        public ExecuteResult AddComment(BlogCommentAddPageDTO dto, IUserBasicInfo userInfo)
        {
            ExecuteResult result = new ExecuteResult()
            {
                IsSuccess = true
            };

            BlogCommentEntity commentEntity = Mapper.DynamicMap <BlogCommentEntity>(dto);

            commentEntity.InsertTime = DateTime.Now;
            commentEntity.UserID     = userInfo.UserID;
            commentEntity.RealName   = userInfo.RealName;

            MyTransaction transaction = this._commentDal.OpenTransaction();

            try
            {
                this._commentDal.Add(commentEntity);

                this._blogDal.UpdateBlogComment(dto.BlogID, 1);

                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }

            return(result);
        }
コード例 #2
0
        public ActionResult AjaxAddComment(BlogCommentAddPageDTO dto)
        {
            var result = _blogCommentService.AddComment(dto, UserContext.CurrentUser);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }