Example #1
0
        private void PopulateWithInitialData()
        {
            var task = UserTasks.CreateUserNoAuthCheckAsync(this, Defaults.UserAdmin,
                                                            "Administrator", Defaults.UserAdminPassword, UserRole.Admin);

            task.Wait();
            var adminUser = task.Result;

            SaveChanges();

            var now = DateTime.UtcNow;

            var rootTopic = new Topic()
            {
                Title       = "Root Topic",
                RoleToRead  = UserRole.Guest,
                RoleToEdit  = UserRole.Admin,
                IsRootEntry = true,
                Modified    = now,
                Created     = now
            };

            var rootPost = new Post()
            {
                Parent     = rootTopic,
                Modified   = now,
                Created    = now,
                Title      = Defaults.PostTitle,
                Body       = Defaults.PostBody,
                User       = adminUser,
                RoleToRead = UserRole.Guest,
                RoleToEdit = UserRole.Admin
            };

            topics.Add(rootTopic);
            posts.Add(rootPost);
            SaveChanges();

            var dbInfo = new DatabaseInfo
            {
                MajVersion  = 1,
                MinVersion  = 2,
                ForumTitle  = "New Forum",
                RootTopicId = rootTopic.Id
            };

            databaseInfo.Add(dbInfo);
            SaveChanges();
        }
Example #2
0
        private List <User> CreateUsers(int count)
        {
            var users = new List <User>();

            for (int i = 0; i < count; ++i)
            {
                string email      = $"testUser{i+1}@localhost";
                string diplayName = $"Test User {i+1}";
                string password   = $"pwd";
                var    userTask   = UserTasks.CreateUserNoAuthCheckAsync(_context, email, diplayName, "pwd", UserRole.User);
                userTask.Wait();
                var user = userTask.Result;
                users.Add(user.CloneForExport());
            }
            return(users);
        }