Esempio n. 1
0
        public async Task <IActionResult> RolAta(int uid, int rid, [FromForm] GetAllUsersDtoHelper gelen)
        {
            //1:User bulup rolünü update ediceksin.
            var roller = new List <string>()
            {
                RoleNames.Admin,
                RoleNames.Member,
                RoleNames.Moderator,
                RoleNames.Validator,
                RoleNames.Writer
            };
            var user = _userManager.FindByIdAsync(uid.ToString()).Result;
            var getuserdefaultRole = await _userManager.GetRolesAsync(user);

            var getirRole = _appRoleService.GetRoleById(rid);
            await _userManager.RemoveFromRolesAsync(user, roller);

            await _userManager.RemoveFromRoleAsync(user, getuserdefaultRole[0]);

            await _userManager.AddToRoleAsync(user, getirRole.Result.Name);

            //_genericServiceAppUSER.UpdateUserRole(gelen.appUsers.Id,gelen.appRoles.Id);
            return(RedirectToAction("Temp2"));
        }