Beispiel #1
0
        private static User CreateAdminUser(IDocumentSession session)
        {
            var user = session.Query<User>().FirstOrDefault(u => u.Email.Equals("*****@*****.**"));

            if (user == null)
            {
                user = new User { Firstname = "John", Lastname = "Carter", Email = "*****@*****.**" };

                user.SetPassword("admin");

                session.Store(user);
            }

            return user;
        }
Beispiel #2
0
        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);
            }
        }