Esempio n. 1
0
            public async Task <IActionResult> Edit(string userId)
            {
                ShopUser user = await _userManager.FindByIdAsync(userId);

                if (user != null)
                {
                    var userRoles = await _userManager.GetRolesAsync(user);

                    var          allRoles = _roleManager.Roles.ToList();
                    ChangeRoleVM model    = new ChangeRoleVM
                    {
                        UserId    = user.Id,
                        UserName  = user.UserName,
                        UserRoles = userRoles,
                        AllRoles  = allRoles
                    };
                    return(View(model));
                }
                return(NotFound());
            }
        public async Task <IActionResult> Edit(string userid)
        {
            var user = await _userManager.FindByIdAsync(userid);

            if (user != null)
            {
                var userRoles = await _userManager.GetRolesAsync(user);

                var roles = await _roleManager.Roles.ToListAsync();

                var changeRole = new ChangeRoleVM
                {
                    UserId    = user.Id,
                    UserEmail = user.Email,
                    UserRoles = userRoles,
                    AllRoles  = roles
                };

                return(View(changeRole));
            }

            return(NotFound());
        }
Esempio n. 3
0
        public async Task <ChangeRoleVM> Get(Guid id)
        {
            // получаем пользователя
            ApplicationUser user = await _userManager.FindByIdAsync(id.ToString());

            ChangeRoleVM model = new ChangeRoleVM();

            if (user != null)
            {
                // получем список ролей пользователя
                var userRoles = await _userManager.GetRolesAsync(user);

                var allRoles = _roleManager.Roles.ToList();
                model = new ChangeRoleVM
                {
                    UserId    = user.Id,
                    UserEmail = user.Email,
                    UserRoles = userRoles,
                    AllRoles  = allRoles
                };
            }
            return(model);
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(string userId)
        {
            // получаем пользователя
            User user = await _userManager.FindByIdAsync(userId);

            if (user != null)
            {
                // получем список ролей пользователя
                var userRoles = await _userManager.GetRolesAsync(user);

                var          allRoles = _roleManager.Roles.ToList();
                ChangeRoleVM model    = new ChangeRoleVM
                {
                    UserId    = user.Id,
                    UserEmail = user.Email,
                    UserRoles = userRoles,
                    AllRoles  = allRoles
                };
                return(View(model));
            }

            return(NotFound());
        }