private static void CreateInitialPost(User adminUser, IDocumentSession session) { bool hasPosts = session.Query<Post>().Any(); if (!hasPosts) { var welcomePost = new Post { Title = "Welcome to your new blog!!!", Body = "Hi, LTA Blog would like to congratulate you for creating your new blog site!!!", AllowComments = false, AuthorId = adminUser.Id, CreatedAt = DateTimeOffset.Now, IsActive = true }; welcomePost.Tags.Add("General"); session.Store(welcomePost); } }
public static User GetPostAuthor(this IDocumentSession session, Post post) { var user = session.Load<User>(post.AuthorId); return user; }