public async Task <IActionResult> Index() { string authCode = null; var useAuthCode = TempData.ContainsKey(EnteredAuthCode); if (useAuthCode) { authCode = (string)TempData[EnteredAuthCode]; } var site = await GetCurrentSiteAsync(); if (!site.SinglePageSignUp) { return(RedirectToAction("Step1")); } var siteStage = GetSiteStage(); if (useAuthCode == false) { if (siteStage == SiteStage.BeforeRegistration) { if (site.RegistrationOpens.HasValue) { AlertInfo = $"You can join {site.Name} on {site.RegistrationOpens.Value.ToString("d")}"; } else { AlertInfo = $"Registration for {site.Name} has not opened yet"; } return(RedirectToAction("Index", "Home")); } else if (siteStage >= SiteStage.ProgramEnded) { AlertInfo = $"{site.Name} has ended, please join us next time!"; return(RedirectToAction("Index", "Home")); } } PageTitle = $"{site.Name} - Join Now!"; var systemList = await _siteService.GetSystemList(); var programList = await _siteService.GetProgramList(); var programViewObject = _mapper.Map <List <ProgramViewModel> >(programList); var districtList = await _schoolService.GetDistrictsAsync(true); SinglePageViewModel viewModel = new SinglePageViewModel() { RequirePostalCode = site.RequirePostalCode, ProgramJson = Newtonsoft.Json.JsonConvert.SerializeObject(programViewObject), SystemList = new SelectList(systemList.ToList(), "Id", "Name"), ProgramList = new SelectList(programList.ToList(), "Id", "Name"), CategorySelectionAction = nameof(SchoolCategory), PublicSelected = true, ShowPrivateOption = await _schoolService.AnyPrivateSchoolsAsync(), ShowCharterOption = await _schoolService.AnyCharterSchoolsAsync(), SchoolDistrictList = new SelectList(districtList.ToList(), "Id", "Name"), AskEmailReminder = siteStage == SiteStage.RegistrationOpen && await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskPreregistrationReminder) }; var askIfFirstTime = await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskIfFirstTime); if (askIfFirstTime) { viewModel.AskFirstTime = EmptyNoYes(); } var(askActivityGoal, defaultDailyGoal) = await GetSiteSettingIntAsync( SiteSettingKey.Users.DefaultDailyPersonalGoal); if (askActivityGoal) { viewModel.DailyPersonalGoal = defaultDailyGoal; var pointTranslation = programList.First().PointTranslation; viewModel.TranslationDescriptionPastTense = pointTranslation.TranslationDescriptionPastTense.Replace("{0}", "").Trim(); viewModel.ActivityDescriptionPlural = pointTranslation.ActivityDescriptionPlural; } if (systemList.Count() == 1) { var systemId = systemList.SingleOrDefault().Id; var branchList = await _siteService.GetBranches(systemId); if (branchList.Count() > 1) { branchList = branchList.Prepend(new Branch() { Id = -1 }); } else { viewModel.BranchId = branchList.SingleOrDefault().Id; } viewModel.BranchList = new SelectList(branchList.ToList(), "Id", "Name"); viewModel.SystemId = systemId; } if (programList.Count() == 1) { var programId = programList.SingleOrDefault().Id; var program = await _siteService.GetProgramByIdAsync(programId); viewModel.ProgramId = programList.SingleOrDefault().Id; viewModel.ShowAge = program.AskAge; viewModel.ShowSchool = program.AskSchool; } if (useAuthCode) { viewModel.AuthorizationCode = authCode; } return(View(viewModel)); }