public Comment(String contentID) { try { Comment obj = new Comment(); MongoDatabase md = MongoDBHelper.MongoDB; MongoCollection<Comment> mc = md.GetCollection<Comment>(Comment.GetCollectionName()); obj = mc.FindOne(Query.EQ("_id", ObjectId.Parse(contentID))); this._id = obj._id; this.MemberID = obj.MemberID; this.Creater = new Moooyo.BiZ.Creater.Creater(obj.MemberID); this.CommentToID = obj.CommentToID; this.Content = obj.Content; this.CreatedTime = obj.CreatedTime; this.UpdateTime = obj.UpdateTime; this.CommentType = obj.CommentType; this.DeleteFlag = obj.DeleteFlag; } catch (System.Exception err) { throw new CBB.ExceptionHelper.OperationException( CBB.ExceptionHelper.ErrType.SystemErr, CBB.ExceptionHelper.ErrNo.DBOperationError, err); } }
/// <summary> /// 按回复对象编号获取一条回复 /// </summary> /// <param name="id">回复对象编号</param> /// <returns>回复对象</returns> public static Comment GetComment(String id) { Comment comment = new Comment(); try { MongoDatabase md = MongoDBHelper.MongoDB; MongoCollection<Comment> mc = md.GetCollection<Comment>(Comment.GetCollectionName()); comment = mc.FindOne(Query.EQ("_id", ObjectId.Parse(id))); return comment; } catch (System.Exception err) { throw new CBB.ExceptionHelper.OperationException( CBB.ExceptionHelper.ErrType.SystemErr, CBB.ExceptionHelper.ErrNo.DBOperationError, err); } }
/// <summary> /// 内容回复的添加或更新 /// </summary> /// <param name="obj">回复对象</param> /// <returns>添加或更新操作是否成功</returns> public Comment Save(Comment obj) { try { MongoDatabase md = MongoDBHelper.MongoDB; MongoCollection<Comment> mc = md.GetCollection<Comment>(Comment.GetCollectionName()); mc.Save(obj); //审核关键字 new Moooyo.BiZ.FilterWord.FilterWordController().FilterText(obj.Content, Comment.GetCollectionName(), obj.ID, "Content", obj.MemberID); return obj; } catch (System.Exception err) { throw new CBB.ExceptionHelper.OperationException( CBB.ExceptionHelper.ErrType.SystemErr, CBB.ExceptionHelper.ErrNo.DBOperationError, err); } }
/// <summary> /// 回复删除 /// </summary> /// <param name="ID">回复编号</param> /// <returns>删除是否成功</returns> public Boolean Remove(String ID) { try { Comment comment = new Comment(ID); comment.DeleteFlag = Comm.DeletedFlag.No; comment.Save(comment); return true; } catch (System.Exception err) { throw new CBB.ExceptionHelper.OperationException( CBB.ExceptionHelper.ErrType.SystemErr, CBB.ExceptionHelper.ErrNo.DBOperationError, err); } }