string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish) { Models.Post newPost; using (var session = MvcApplication.DocumentStore.OpenSession()) { var user = ValidateUser(username, password); var comments = new PostComments { Comments = new List <PostComments.Comment>(), Spam = new List <PostComments.Comment>() }; session.Store(comments); var postScheduleringStrategy = new PostSchedulingStrategy(session, DateTimeOffset.Now); var publishDate = post.dateCreated == null ? postScheduleringStrategy.Schedule() : postScheduleringStrategy.Schedule(new DateTimeOffset(post.dateCreated.Value)); newPost = new Models.Post { AuthorId = user.Id, Body = post.description, CommentsId = comments.Id, CreatedAt = DateTimeOffset.Now, SkipAutoReschedule = post.dateCreated != null, PublishAt = publishDate, Tags = post.categories, Title = post.title, CommentsCount = 0, AllowComments = true, }; session.Store(newPost); comments.Post = new PostComments.PostReference { Id = newPost.Id, PublishAt = publishDate }; session.SaveChanges(); } return(newPost.Id); }
string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish) { Models.Post newPost; using (var session = MvcApplication.DocumentStore.OpenSession()) { var user = ValidateUser(username, password); var comments = new PostComments { Comments = new List<PostComments.Comment>(), Spam = new List<PostComments.Comment>() }; session.Store(comments); var postScheduleringStrategy = new PostSchedulingStrategy(session, DateTimeOffset.Now); var publishDate = post.dateCreated == null ? postScheduleringStrategy.Schedule() : postScheduleringStrategy.Schedule(new DateTimeOffset(post.dateCreated.Value)); newPost = new Models.Post { AuthorId = user.Id, Body = post.description, CommentsId = comments.Id, CreatedAt = DateTimeOffset.Now, SkipAutoReschedule = post.dateCreated != null, PublishAt = publishDate, Tags = post.categories, Title = post.title, CommentsCount = 0, AllowComments = true, }; session.Store(newPost); comments.Post = new PostComments.PostReference { Id = newPost.Id, PublishAt = publishDate }; session.SaveChanges(); } return newPost.Id; }