public async Task OnGet() { //ApplicationUserViewModels = await _applicationUserDataService.GetAllUsers(); var LoggedInIdString = User.Claims.FirstOrDefault(x => x.Type == "sub").Value; var LoggedInId = Guid.Parse(LoggedInIdString); LoggedInUser = await _applicationUserDataService.GetUserById(new GetUserByIdCommand { Id = LoggedInId }); foreach (var role in LoggedInUser.ActiveRoles) { if (role.Name.ToLower() == "kontor") { OfficeRoleIsChecked = true; } if (role.Name.ToLower() == "lager") { WareHouseRoleIsChecked = true; } if (role.Name.ToLower() == "transporter") { TransporterRoleIsChecked = true; } if (role.Name.ToLower() == "client") { ClientRoleIsChecked = true; } if (role.Name.ToLower() == "admin") { AdminRoleIsChecked = true; } } }
public async Task OnGet() { //ApplicationUserViewModels = await _applicationUserDataService.GetAllUsers(); var LoggedInIdString = User.Claims.FirstOrDefault(x => x.Type == "sub").Value; var LoggedInId = Guid.Parse(LoggedInIdString); LoggedInUser = await _applicationUserDataService.GetUserById(new GetUserByIdCommand { Id = LoggedInId }); }
public async Task <IViewComponentResult> InvokeAsync() { var id = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "sub").Value; var currentUser = HttpContext.Session.GetObject <ApplicationUserViewModel>(id); if (currentUser == null) { var user = await _applicationUserDataService.GetUserById(new GetUserByIdCommand { Id = Guid.Parse(id) }); HttpContext.Session.SetObject(id, user); return(View(user)); } return(View(currentUser)); }