public void CreatesAnAgencySpecificIdWhenNoneExists()
        {
            var agencyEntity = new AgencyEntity("test", "test");

            updateContext.Add(agencyEntity);
            updateContext.SaveChanges();


            repository.GetPersonAgencyId((PersonIdentity)personOne.Id, (AgencyIdentity)agencyEntity.Id).Should()
            .NotBeNull();
        }
Esempio n. 2
0
        public IActionResult GetPersonForAgency(long id, [Required, NotNull] string agencySystemName)
        {
            var agency = IdentityRepository.GetAgency(agencySystemName);

            if (agency == null)
            {
                ModelState.AddModelError(nameof(agencySystemName), $"{agencySystemName} was not found");
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Debug.Assert(agency != null, nameof(agency) + " != null");

            var personIdentity = new PersonIdentity(id);

            if (!IdentityRepository
                .GetPeopleWithIdentifiers(new[] { personIdentity }, agency.RootIdentifierNames(), UserProvider)
                .TryGetValue(personIdentity, out var identifiers))
            {
                return(NotFound(id));
            }

            var personIdForAgency = IdentityRepository.GetPersonAgencyId(personIdentity, agency.Id);

            return(Ok(new AgencyPersonDto(personIdForAgency, IdentifierDtoMarshaller.MarshallToDtos(identifiers))));
        }