public async Task <IActionResult> Index() { if (!AuthUser.Identity.IsAuthenticated) { return(RedirectToSignIn()); } if (!UserHasPermission(Permission.AccessPerformerRegistration)) { // not authorized for Performer registration, redirect to authorization code return(RedirectToAction(nameof(AuthorizationCode))); } var settings = await _performerSchedulingService.GetSettingsAsync(); var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings); if (schedulingStage == PsSchedulingStage.Unavailable) { return(RedirectToAction(nameof(Controllers.HomeController.Index), "Home", new { Area = string.Empty })); } var hasPermission = UserHasPermission(Permission.AccessPerformerRegistration); var userId = GetId(ClaimType.UserId); var performer = await _performerSchedulingService.GetPerformerByUserIdAsync(userId, includeBranches : true); if (hasPermission && (performer != null || schedulingStage == PsSchedulingStage.RegistrationOpen)) { return(RedirectToAction(nameof(Dashboard))); } var viewModel = new IndexViewModel { HasPermission = hasPermission, Settings = settings, SchedulingStage = schedulingStage }; return(View(viewModel)); }