コード例 #1
0
        public async Task <IActionResult> Index()
        {
            // set up test user
            Entities.ApplicationUser defaultUser = new Entities.ApplicationUser()
            {
                UserName    = "******",
                Email       = "*****@*****.**",
                PhoneNumber = "000-000-0000",
            };

            // set up test Administrators role
            Entities.ApplicationRole administratorsRole = new Entities.ApplicationRole()
            {
                Name = "Administrators"
            };

            Entities.ApplicationUser user = await _userManager.FindByNameAsync(defaultUser.UserName);

            Entities.ApplicationRole role = await _roleManager.FindByNameAsync(administratorsRole.Name);

            if (user == null && role == null)
            {
                await _userManager.CreateAsync(defaultUser, "Testpassword#1");

                await _roleManager.CreateAsync(administratorsRole);

                await _userManager.AddToRolesAsync(defaultUser, new string[] { administratorsRole.Name });
            }

            return(View());
        }
コード例 #2
0
 public ApplicationUserViewModel(Entities.ApplicationUser user)
 {
     this.UserName    = user.UserName;
     this.FirstName   = user.FirstName;
     this.LastName    = user.LastName;
     this.Id          = user.Id;
     this.IsLockedOut = user.IsLockedOut;
 }
コード例 #3
0
        public async Task <ActionResult> Delete(string username)
        {
            Entities.ApplicationUser user = await _userManager.FindByNameAsync(username);

            await _userManager.DeleteAsync(user);

            return(RedirectToAction("cp", "home"));
        }
コード例 #4
0
 public UserReportViewModel(Entities.ApplicationUser user)
 {
     Id          = user.Id;
     UserName    = user.UserName;
     Roles       = string.Join("/", (from r in user.Roles select r.Role.Name));
     IsLockedOut = user.IsLockedOut;
     IsApproved  = user.IsApproved;
     LastLogin   = user.LastLoginDate;
 }
コード例 #5
0
        public async Task <ActionResult> SignIn(string username, string password)
        {
            Entities.ApplicationUser user = await _userManager.FindByNameAsync(username);

            if (await _userManager.CheckPasswordAsync(user, password))
            {
                await _signInManager.SignInAsync(user, false);
            }

            return(RedirectToAction("index", "home"));
        }
コード例 #6
0
 public EditUserViewModel(Entities.ApplicationUser user, string loggedOnUserName)
     : this()
 {
     this.UserName         = user.UserName;
     this.FirstName        = user.FirstName;
     this.LastName         = user.LastName;
     this.Email            = user.Email;
     this.UserId           = user.Id;
     this.IsLockedOut      = user.IsLockedOut;
     this.IsApproved       = user.IsApproved;
     this.LoggedOnUserName = loggedOnUserName;
 }
コード例 #7
0
        public async Task <ActionResult> RemoveUsersFromRoles(string usernames, string rolenames)
        {
            string[] userNames = usernames.Split(", ");
            string[] roleNames = rolenames.Split(", ");
            foreach (string userName in userNames)
            {
                Entities.ApplicationUser user = await _userManager.FindByNameAsync(userName);

                await _userManager.RemoveFromRolesAsync(user, roleNames);
            }

            return(RedirectToAction("cp", "home"));
        }
コード例 #8
0
        public async Task <ActionResult> Create(string username, string password, string confirm)
        {
            if (password == confirm)
            {
                Entities.ApplicationUser user = new Entities.ApplicationUser()
                {
                    UserName    = username,
                    Email       = "*****@*****.**",
                    PhoneNumber = "999-999-9999",
                };

                await _userManager.CreateAsync(user, password);
            }

            return(RedirectToAction("cp", "home"));
        }
コード例 #9
0
ファイル: EnvironmentViewModel.cs プロジェクト: syedshah/Doc
 public EnvironmentViewModel(Entities.ApplicationUser user)
 {
     this.Environments        = new List <String>();
     this.SelectedEnvironment = user.PreferredEnvironment;
 }
コード例 #10
0
ファイル: AdminRepository.cs プロジェクト: DF3203/Diploma
 public async Task <bool> CheckPasswordAsync(Entities.ApplicationUser user, string password)
 {
     return(await this.userManager.CheckPasswordAsync(user, password));
 }
コード例 #11
0
ファイル: AdminRepository.cs プロジェクト: DF3203/Diploma
        public async Task <IdentityResult> CreateUserAsync(Entities.ApplicationUser applicationUser, string password)
        {
            IdentityResult identityResult = await this.userManager.CreateAsync(applicationUser, password);

            return(identityResult);
        }
コード例 #12
0
ファイル: AdminRepository.cs プロジェクト: DF3203/Diploma
 public async Task <IdentityResult> AddUserDefaultRoleAsync(Entities.ApplicationUser applicationUser, string userRole)
 {
     return(await this.userManager.AddToRoleAsync(applicationUser, userRole));
 }