private async Task <IActionResult> ShowExitPageAsync(SiteStage siteStage, int?branchId = null) { string siteName = HttpContext.Items[ItemKey.SiteName]?.ToString(); PageTitle = _sharedLocalizer[Annotations.Title.SeeYouSoon, siteName]; var exitPageViewModel = new ExitPageViewModel(); try { var culture = _userContextProvider.GetCurrentCulture(); exitPageViewModel.Social = await _socialService.GetAsync(culture.Name); } catch (GraException ex) { _logger.LogInformation(ex, "Unable to populate social card for exit page: {ErrorMessage}", ex.Message); } if (branchId == null) { try { exitPageViewModel.Branch = await _userService.GetUsersBranch(GetActiveUserId()); } catch (GraException) { } } if (exitPageViewModel.Branch == null && branchId.HasValue) { try { exitPageViewModel.Branch = await _siteService.GetBranchByIdAsync(branchId.Value); } catch (GraException) { } } return(siteStage switch { SiteStage.BeforeRegistration => View(ViewTemplates.ExitBeforeRegistration, exitPageViewModel), SiteStage.RegistrationOpen => View(ViewTemplates.ExitRegistrationOpen, exitPageViewModel), SiteStage.ProgramEnded => View(ViewTemplates.ExitProgramEnded, exitPageViewModel), SiteStage.AccessClosed => View(ViewTemplates.ExitAccessClosed, exitPageViewModel), _ => View(ViewTemplates.ExitProgramOpen, exitPageViewModel), });
private async Task <IActionResult> ShowExitPageAsync(SiteStage siteStage, int?branchId = null) { string siteName = HttpContext.Items[ItemKey.SiteName]?.ToString(); PageTitle = _sharedLocalizer[Annotations.Title.SeeYouSoon, siteName]; ExitPageViewModel exitPageViewModel = null; try { exitPageViewModel = new ExitPageViewModel { Branch = branchId == null ? await _userService.GetUsersBranch(GetActiveUserId()) : await _siteService.GetBranchByIdAsync((int)branchId) }; } catch (GraException ex) { _logger.LogInformation(ex, "Attempt to show exit page failed for branch id {BranchId}: {Message}", branchId, ex.Message); } switch (siteStage) { case SiteStage.BeforeRegistration: return(View(ViewTemplates.ExitBeforeRegistration, exitPageViewModel)); case SiteStage.RegistrationOpen: return(View(ViewTemplates.ExitRegistrationOpen, exitPageViewModel)); case SiteStage.ProgramEnded: return(View(ViewTemplates.ExitProgramEnded, exitPageViewModel)); case SiteStage.AccessClosed: return(View(ViewTemplates.ExitAccessClosed, exitPageViewModel)); default: return(View(ViewTemplates.ExitProgramOpen, exitPageViewModel)); } }
public PartialViewResult ExitPage() { var currentPage = _umbracoHelper.CurrentPage; var cultureName = GetCultureNameForPublishedContent(currentPage); var exitModel = _cacheProvider.CachedGet <ExitPageViewModel>(string.Format("{0}_{1}", "ExitPage", cultureName), () => { var exitViewModel = new ExitPageViewModel(); var homePageNode = _umbracoHelper.AncenstorOrSelf(currentPage, 1); var exitNode = _umbracoHelper.GetDescendantNodesOfType(homePageNode.Id, _nodeConfig.ExitNodeAlias).FirstOrDefault(); _umbracoMapper.Map(exitNode, exitViewModel); var dictionaryTerms = new ExitPageDictionaryViewModel(); _umbracoMapper.MapUsingDictionary(dictionaryTerms); exitViewModel.SetDictionary(dictionaryTerms); return(exitViewModel); }); return(PartialView("ExitPage", exitModel)); }