public static BlogPost UpdateDetailsFrom(this BlogPost blogPost, Post post) { blogPost.Title = post.title; blogPost.Body = post.description; blogPost.PublishDate = post.dateCreated.ToUniversalTime(); blogPost.Categories = post.categories.ToList(); return blogPost; }
bool IMetaWeblog.UpdatePost( string postid, string username, string password, Post post, bool publish ) { ThrowExceptionIfAuthenticationFailsFor(username, password); using (var documentSetssion = DocuemntStore.OpenSession()) { var blogPost = documentSetssion.Load< BlogPost >( postid ); blogPost.UpdateDetailsFrom( post ); documentSetssion.SaveChanges(); } return true; }
string IMetaWeblog.AddPost( string blogid, string username, string password, Post post, bool publish ) { ThrowExceptionIfAuthenticationFailsFor( username, password ); var blogPost = new BlogPost( post.title ) { DateAdded = DateTime.Now, }.UpdateDetailsFrom(post); using( var documentSession = DocuemntStore.OpenSession() ) { documentSession.Store( blogPost ); documentSession.SaveChanges(); } return blogPost.Id; }