public async Task <IActionResult> SetCurrentRole(SignedInViewModel model) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(model.CurrentRole)) { var user = await _userManager.GetUserAsync(this.User); user.CurrentRole = model.CurrentRole; await _userManager.UpdateAsync(user); } } return(SafeRedirect(null)); }
public async Task <IViewComponentResult> InvokeAsync() { if (_signInManager.IsSignedIn(this.UserClaimsPrincipal)) { var user = await _userManager.GetUserAsync(this.UserClaimsPrincipal); var roles = await _userManager.GetRolesAsync(user); var model = new SignedInViewModel(user.UserName, roles) { CurrentRole = user.CurrentRole }; return(View("SignedIn", model)); } return(View()); }