예제 #1
0
        public async Task <IActionResult> UserEdit(string id)
        {
            //roles the user is assigned
            var RolesInUser = _DbPortal.GetT_PRT_ROLES_BelongingToUser(id);

            var allRoles = _roleManager.Roles.ToList();  //  get all roles

            var model = new UserEditViewModel
            {
                appUser   = await _userManager.FindByIdAsync(id),
                UserRoles = RolesInUser.Select(x => new SelectListItem
                {
                    Value = x.Name,
                    Text  = x.Name
                }),
                RoleNotInUser = allRoles.Except(RolesInUser).OrderBy(a => a.Name).Select(x => new SelectListItem
                {
                    Value = x.Name,
                    Text  = x.Name
                }),
                UserOrgs = _DbPortal.GetT_PRT_ORG_USERS_ByUserID(id),
                ddl_Orgs = _DbPortal.GetT_PRT_ORGANIZATIONS().Select(x => new SelectListItem
                {
                    Value = x.ORG_ID.ToString(),
                    Text  = x.ORG_NAME
                })
            };

            //forgot/reset password URL
            var code = await _userManager.GeneratePasswordResetTokenAsync(model.appUser);

            var callbackUrl = Url.ResetPasswordCallbackLink(model.appUser.Id, code, Request.Scheme);

            model.ForgotPasswordURL = callbackUrl;

            return(View(model));
        }