예제 #1
0
        public async Task <ActionResult> AuthorisationRequired(Guid pcsId)
        {
            using (IWeeeClient client = apiClient())
            {
                SchemeStatus status = await client.SendAsync(User.GetAccessToken(), new GetSchemeStatus(pcsId));

                if (status == SchemeStatus.Approved)
                {
                    return(RedirectToAction("Index", new { pcsId }));
                }

                string userIdString = User.GetUserId();
                bool   showLinkToSelectOrganisation = false;

                if (userIdString != null)
                {
                    Guid userId = new Guid(userIdString);

                    int activeUserCompleteOrganisationCount = await cache.FetchUserActiveCompleteOrganisationCount(userId);

                    showLinkToSelectOrganisation = (activeUserCompleteOrganisationCount > 1);
                }

                await SetBreadcrumb(pcsId);

                return(View(new AuthorizationRequiredViewModel
                {
                    Status = status,
                    ShowLinkToSelectOrganisation = showLinkToSelectOrganisation
                }));
            }
        }
예제 #2
0
        public ActionResult _WeeeTitle()
        {
            bool userIsInternal = ((ClaimsIdentity)User.Identity).HasClaim(
                ClaimTypes.AuthenticationMethod, Claims.CanAccessInternalArea);

            TitleViewModel model = new TitleViewModel();

            model.User           = User;
            model.UserIsInternal = userIsInternal;
            model.Breadcrumb     = breadcrumb;

            string userIdString = User.GetUserId();

            if (userIdString != null)
            {
                Guid userId = new Guid(userIdString);

                // MVC 5 doesn't allow child actions to run asynchronously, so we
                // have to schedule this task and block the calling thread.
                // Furthermore, this task will be scheduled on a thread with different
                // synchronization context than the one used by ASP.NET so we wont
                // have access to HttpContext.Current.
                var task = Task.Run(async() =>
                {
                    return(await cache.FetchUserActiveCompleteOrganisationCount(userId));
                });
                task.Wait();

                model.ShowLinkToSelectOrganisation = (task.Result > 1);
            }
            else
            {
                model.ShowLinkToSelectOrganisation = false;
            }

            return(PartialView(model));
        }
예제 #3
0
        public async Task <ActionResult> AuthorisationRequired(Guid pcsId)
        {
            using (var client = apiClient())
            {
                var status = await client.SendAsync(User.GetAccessToken(), new GetSchemeStatus(pcsId));

                if (status == SchemeStatus.Approved)
                {
                    return(RedirectToAction("Summary", "MemberRegistration"));
                }

                var userIdString = User.GetUserId();
                var showLinkToSelectOrganisation = false;

                if (userIdString != null)
                {
                    var userId = new Guid(userIdString);

                    var task = Task.Run(async() =>
                    {
                        return(await cache.FetchUserActiveCompleteOrganisationCount(userId));
                    });
                    task.Wait();

                    showLinkToSelectOrganisation = (task.Result > 1);
                }

                await SetBreadcrumb(pcsId, ManageMembersActivity);

                return(View(new AuthorizationRequiredViewModel
                {
                    Status = status,
                    ShowLinkToSelectOrganisation = showLinkToSelectOrganisation
                }));
            }
        }