示例#1
0
        public async Task <ActionResult <Party> > LookupPartyBySSNOrOrgNo([FromBody] string lookupValue)
        {
            Party result = await _partiesWrapper.LookupPartyBySSNOrOrgNo(lookupValue);

            if (result != null)
            {
                return(Ok(result));
            }

            return(NotFound());
        }
示例#2
0
        public async Task <Person?> GetPerson(string nationalIdentityNumber, string lastName, int activeUser)
        {
            string uniqueCacheKey = PersonLookupFailedAttempts + activeUser;

            _ = _memoryCache.TryGetValue(uniqueCacheKey, out int failedAttempts);
            if (failedAttempts >= _personLookupSettings.MaximumFailedAttempts)
            {
                _logger.LogInformation(
                    "User {userId} has performed too many failed person lookup attempts.", activeUser);

                throw new TooManyFailedLookupsException();
            }

            Party?party = await _partiesService.LookupPartyBySSNOrOrgNo(nationalIdentityNumber);

            string nameFromParty = party?.Person?.LastName ?? string.Empty;

            if (nameFromParty.Length > 0 && nameFromParty.IsSimilarTo(lastName))
            {
                return(party !.Person);
            }

            failedAttempts += 1;
            MemoryCacheEntryOptions memoryCacheOptions = new MemoryCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(_personLookupSettings.FailedAttemptsCacheLifetimeSeconds)
            };

            _memoryCache.Set(uniqueCacheKey, failedAttempts, memoryCacheOptions);
            return(null);
        }
        public async Task <ActionResult <Party> > PostPartyLookup([FromBody] PartyLookup partyLookup)
        {
            string lookupValue = partyLookup.OrgNo ?? partyLookup.Ssn;

            Party party = await _partiesWrapper.LookupPartyBySSNOrOrgNo(lookupValue);

            if (party == null)
            {
                return(NotFound());
            }

            return(Ok(party));
        }