Exemple #1
0
        private void CheckForCoreData(IDocumentStore ds, IContext context)
        {
            // In case the versioning bundle is installed, make sure it will version
            // only what we opt-in to version
            using (IDocumentSession s = ds.OpenSession())
            {
                var store = new FlexMembershipUserStore <User, Role>(s);

                var membership = new FlexMembershipProvider(store, new AspnetEnvironment());
                var roles      = new FlexRoleProvider(store);
                if (!membership.HasLocalAccount("sallen"))
                {
                    membership.CreateAccount(new User {
                        Username = "******", Password = "******", FavoriteNumber = 24
                    });
                }
                if (!roles.RoleExists("admin"))
                {
                    roles.CreateRole("admin");
                }
                if (!roles.IsUserInRole("sallen", "admin"))
                {
                    roles.AddUsersToRoles(new[] { "sallen" }, new[] { "admin" });
                }
            }
        }
Exemple #2
0
        protected override void Seed(Models.MovieDb context)
        {
            var seed = ConfigurationManager.AppSettings["seed"];

            if (seed != "false")
            {
                var membership = new FlexMembershipProvider(new UserStore(context), new AspnetEnvironment());
                var roles      = new FlexRoleProvider(new RoleStore(context));

                if (!membership.HasLocalAccount("sallen"))
                {
                    membership.CreateAccount(new User {
                        Username = "******", Password = "******", FavoriteNumber = 24
                    });
                }
                if (!roles.RoleExists("admin"))
                {
                    roles.CreateRole("admin");
                }
                if (!roles.IsUserInRole("sallen", "admin"))
                {
                    roles.AddUsersToRoles(new[] { "sallen" }, new[] { "admin" });
                }
            }

            base.Seed(context);
        }