public override DeleteCommentInfoResponseBody ExecuteCore() { DeleteCommentInfoResponseBody res = new DeleteCommentInfoResponseBody(); t_circle_comment model = db.t_circle_comment.Where(l => l.id == this.request.CommentId).FirstOrDefault(); if (model != null) { db.t_circle_comment.Remove(model); var circleModel = db.t_circle.Where(c => c.id == model.circle_id).FirstOrDefault(); if (circleModel != null) { bool isChanged = string.IsNullOrEmpty(this.request.CircleUpdateTime) || this.request.CircleUpdateTime != GenericUtility.FormatDate2(circleModel.update_time); circleModel.update_time = DateTime.Now; db.SaveChanges(); if (!isChanged) { res.CircleLastUpdateTime = GenericUtility.FormatDate2(circleModel.update_time); } } else { db.SaveChanges(); } } res.Status = ResultStatus.Success; return(res); }
public override AddCommentInfoResponseBody ExecuteCore() { AddCommentInfoResponseBody res = new AddCommentInfoResponseBody(); var circleModel = db.t_circle.Where(c => c.id == this.request.CircleId).FirstOrDefault(); if (circleModel == null) { throw new Exception("你评论的信息已经被用户删除"); } bool isChanged = string.IsNullOrEmpty(this.request.CircleUpdateTime) || this.request.CircleUpdateTime != GenericUtility.FormatDate2(circleModel.update_time); t_circle_comment model = new t_circle_comment() { com_user_id = this.request.CommentUserId, com_content = this.request.Content, circle_id = this.request.CircleId, reply_user_id = this.request.ReplyUserId, id = 0, comment_time = DateTime.Now, }; db.t_circle_comment.Add(model); circleModel.comment_count = circleModel.comment_count + 1; circleModel.update_time = DateTime.Now; db.SaveChanges(); var userList = db.t_user.Where(i => i.id == model.com_user_id || i.id == model.reply_user_id).Select(i => new { i.id, i.name, i.symbol, i.head_image }).ToList(); CircleCommentInfo info = new CircleCommentInfo() { CommentId = model.id, Content = model.com_content, CommentTime = model.comment_time.ToString("yyyy-MM-dd HH:mm:ss"), CommentUserId = model.com_user_id, //CommentUserImage = model.com, //CommentUserName = model.content_info, CircleId = model.circle_id, ReplyUserId = model.reply_user_id, //ReplyUserImage = model.content_info, //ReplyUserName = model.content_info, }; if (userList != null && userList.Count > 0) { if (info.CommentUserId > 0) { var comUser = userList.Where(u => u.id == info.CommentUserId).FirstOrDefault(); info.CommentUserName = UserUtility.GetShowName(comUser.name, comUser.symbol); info.CommentUserImage = comUser.head_image; } if (info.ReplyUserId > 0) { var repUser = userList.Where(u => u.id == info.ReplyUserId).FirstOrDefault(); info.ReplyUserName = UserUtility.GetShowName(repUser.name, repUser.symbol); info.ReplyUserImage = repUser.head_image; } } res.CommentInfo = info; if (!isChanged) { res.CircleLastUpdateTime = GenericUtility.FormatDate2(circleModel.update_time); } return(res); }