示例#1
0
文件: Post.cs 项目: frg/congress
 public Post(SetterPost setterPost)
 {
     Title = setterPost.Title;
     Content = setterPost.Content;
     VoteCount = 1;
     CreatedByUID = setterPost.CreatedByUID;
     CreatedAt = DateTime.UtcNow;
     DeletedAt = null;
     Archived = false;
 }
示例#2
0
文件: Post.cs 项目: frg/congress
        public static WriteConcernResult Create(MongoDBConnection db, SetterPost setterPost)
        {
            if (IsUniquePost(db, setterPost) == null && UserPostsHoursAgo(db, setterPost.CreatedByUID).Count() < 2)
            {
                Post post = new Post(setterPost);
                var createdPostResult = db.Posts.Insert(post);

                // create vote for post by user
                db.Votes.Insert(new SetterVote(post.Id, setterPost.CreatedByUID, 1));

                return createdPostResult;
            }

            return null;
        }
示例#3
0
文件: Post.cs 项目: frg/congress
        public static Post IsUniquePost(MongoDBConnection db, SetterPost setterPost)
        {
            if (db.Posts.Count() > 0)
            {
                // use db.collection.find({_id: "myId"}, {_id: 1}).limit(1) instead
                return db.Posts.FindOneAs<Post>(Query<Post>.Where(i => i.Title == setterPost.Title && i.DeletedAt == null));
            }

            return null;
        }
示例#4
0
 // POST: api/Post
 public bool Post(SetterPost setterPost)
 {
     setterPost.CreatedByUID = Helper.GenerateClientUID();
     return (PostShepherd.Create(db, setterPost) != null);
 }