示例#1
0
        public void CreateAdminUsers()
        {
            ApplicationDbInitializer.AddUser(dataContext);
            var          roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(dataContext));
            IdentityRole admrole     = roleManager.FindByName("SuperUser");
            List <User>  users       = _userManager.Users.Where(u => u.Roles.Any(r => r.RoleId == admrole.Id)).ToList();

            Assert.IsTrue(users.Count > 0);
        }
示例#2
0
        public Boolean  CreateUser(int idUser, LoginUserType loginType, String email, String userName)
        {
            var dbUSer = new MyDbContext();
            ApplicationDbInitializer dbApp = new ApplicationDbInitializer();
            var res = dbApp.AddUser(idUser, loginType, email, userName);

            if (res)
            {
                var xuser = db.AspNetUsers.Where(x => x.UserName == userName).FirstOrDefault();
                xuser.IdUser = idUser;
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }