private List<SelectListItem> GetOrganizationForOrgAdmin(ClaimsPrincipal user)
        {
            int? organizationId = user.GetOrganizationId();
            if (organizationId.HasValue)
            {
                return _context.Organizations.Where(o => o.Id == organizationId)
                    .Select(t => new SelectListItem { Value = t.Id.ToString(), Text = t.Name })
                    .ToList();
            }

            return new List<SelectListItem>();
        }
Esempio n. 2
0
        public void GetOrganizationIdShouldReturnNullWhenNotAnInteger()
        {
            var principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(AllReady.Security.ClaimTypes.Organization, "ThisIsWRong") }));

            Assert.Null(principal.GetOrganizationId());
        }
Esempio n. 3
0
        public void GetOrganizationIdShouldReturnOrganizationId()
        {
            var principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(AllReady.Security.ClaimTypes.Organization, "12") }));

            Assert.Equal(12, principal.GetOrganizationId());
        }