public async Task <IActionResult> Index(int page) { page = page == 0 ? 1 : page; var filter = new BaseFilter(page); var socialHeaders = await _socialManagementService.GetPaginatedListAsync(filter); var languages = await _languageService.GetActiveAsync(); var activeSocials = new List <ActiveSocials>(); foreach (var language in languages) { var current = await _socialService.GetAsync(language.Name); if (current != null) { var sb = new StringBuilder("<a href=\"") .Append(Url.Action(nameof(ViewSocial), new { socialHeaderId = current.SocialHeaderId, languageId = language.Id })) .Append("\"><span class=\"text-success gra-language-marker\" title=\"") .Append(language.Description) .Append("\">") .Append(language.Name) .AppendLine("</span></a>"); activeSocials.Add(new ActiveSocials { HeaderId = current.SocialHeaderId, LanguageId = language.Id, Link = sb.ToString() }); } } var viewmodel = new SocialListViewModel { ActiveSocials = activeSocials, CurrentPage = page, ItemCount = socialHeaders.Count, ItemsPerPage = filter.Take.Value, Languages = languages, SocialHeaders = socialHeaders.Data }; if (viewmodel.PastMaxPage) { return(RedirectToRoute(new { page = viewmodel.LastPage ?? 1 })); } return(View(viewmodel)); }
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), });