public async Task <IViewComponentResult> InvokeAsync() { var isLoggedIn = User.Identity.IsAuthenticated; if (!isLoggedIn) { return(View(new ApplicationAreasViewModel())); } var role = await _currentUserService.GetRoleAsync(); return(View(new ApplicationAreasViewModel { AreasForUser = AllAreas.Where(ai => ai.ForRoles.Contains(role.Name)).ToList() })); }
public async Task <IActionResult> Manage(string returnUrl) { var user = await _currentUserService.GetUserAsync(); var role = await _currentUserService.GetRoleAsync(); var vm = new ManageViewModel { UserId = user.Id, UserName = user.UserName, Email = user.Email, FirstName = user.FirstName, LastName = user.LastName, HasBranch = role.HasBranch, HasCar = role.HasCar, ReturnUrl = returnUrl }; if (vm.HasBranch) { vm.AllBranches = await _branchesDao.GetAllAsync(); var branch = await _currentUserService.GetBranchAsync(); vm.BranchId = branch?.Id ?? default(long); } if (vm.HasCar) { vm.AllCars = await _carsDao.GetAllAsync(); var car = await _currentUserService.GetCarAsync(); vm.CarId = car?.Id ?? default(long); } return(View(vm)); }
public async Task <IViewComponentResult> InvokeAsync() { var vm = new AccountViewModel { CurrentUrl = Request.PathAndQuery() }; var isLoggedIn = User.Identity.IsAuthenticated; vm.IsLoggedIn = isLoggedIn; if (!isLoggedIn) { return(View(vm)); } vm.User = await _currentUserService.GetUserAsync(); if (vm.User == null) { vm.IsLoggedIn = false; return(View(vm)); } var role = await _currentUserService.GetRoleAsync(); vm.HasBranch = role.HasBranch; vm.HasCar = role.HasCar; if (vm.HasBranch) { vm.Branch = await _currentUserService.GetBranchAsync(); } if (vm.HasCar) { vm.Car = await _currentUserService.GetCarAsync(); } return(View(vm)); }