Пример #1
0
        private async Task <IActionResult> ShowLandingPageAsync(Site site, SiteStage siteStage)
        {
            string siteName = HttpContext.Items[ItemKey.SiteName]?.ToString();

            PageTitle = siteName;
            switch (siteStage)
            {
            case SiteStage.BeforeRegistration:
                var viewModel = new BeforeRegistrationViewModel
                {
                    SignUpSource = nameof(SiteStage.BeforeRegistration),
                    SiteName     = siteName
                };
                if (site != null)
                {
                    viewModel.CollectEmail = await _siteLookupService
                                             .GetSiteSettingBoolAsync(site.Id,
                                                                      SiteSettingKey.Users.CollectPreregistrationEmails);

                    if (site.RegistrationOpens != null)
                    {
                        viewModel.RegistrationOpens
                                  = ((DateTime)site.RegistrationOpens).ToString("D");
                        PageTitle = _sharedLocalizer[Annotations.Title.RegistrationOpens,
                                                     siteName,
                                                     viewModel.RegistrationOpens];
                    }
                }
                return(View(ViewTemplates.BeforeRegistration, viewModel));

            case SiteStage.RegistrationOpen:
                PageTitle = _sharedLocalizer[Annotations.Title.JoinNow, siteName];
                return(View(ViewTemplates.RegistrationOpen, siteName));

            case SiteStage.ProgramEnded:
                return(View(ViewTemplates.ProgramEnded, siteName));

            case SiteStage.AccessClosed:
                var acViewModel = new AccessClosedViewModel
                {
                    SignUpSource = nameof(SiteStage.AccessClosed),
                };
                if (site != null)
                {
                    acViewModel.SiteName     = site.Name;
                    acViewModel.CollectEmail = await _siteLookupService
                                               .GetSiteSettingBoolAsync(site.Id,
                                                                        SiteSettingKey.Users.CollectAccessClosedEmails);
                }
                return(View(ViewTemplates.AccessClosed, acViewModel));

            default:
                PageTitle = _sharedLocalizer[Annotations.Title.JoinNow, siteName];
                return(View(ViewTemplates.ProgramOpen, siteName));
            }
        }
Пример #2
0
 public async Task <IActionResult> PreviewLanding(string id)
 {
     if (UserHasPermission(Permission.AccessMissionControl))
     {
         SiteStage stage = ParseStage(id);
         return(await ShowLandingPageAsync(await GetCurrentSiteAsync(), stage));
     }
     else
     {
         return(RedirectToAction(nameof(Index)));
     }
 }
Пример #3
0
        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),
            });
Пример #4
0
        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));
            }
        }