public IList <UniqueLearnerNumber> GetUlnLookup(IList <long?> searchUlns, CancellationToken cancellationToken) { var uniqueUlns = searchUlns.Distinct(); var unknownUlns = uniqueUlns.Where(uln => Ulns.All(u => u.ULN != uln)).ToList(); if (unknownUlns.Any()) { Ulns.AddRange(_referenceDataRepository.GetUlnLookup(unknownUlns, cancellationToken)); } return(Ulns.Where(x => searchUlns.Contains(x.ULN)).ToList()); }
public IEnumerable <long> GetUlnLookup(IEnumerable <long?> searchUlns, CancellationToken cancellationToken) { var uniqueUlns = searchUlns.Distinct().ToList(); var unknownUlns = uniqueUlns.Where(uln => Ulns.All(u => u != uln)).ToList(); if (!unknownUlns.Any()) { return(Ulns.Where(u => uniqueUlns.Contains(u))); } PopulateUlnLookup(unknownUlns, cancellationToken); return(Ulns.Where(u => unknownUlns.Contains(u))); }
public void PopulateUlnLookup(IEnumerable <long?> unknownUlns, CancellationToken cancellationToken) { var result = _referenceDataRepository.GetUlnLookup(unknownUlns, cancellationToken); if (result == null) { return; } foreach (var uln in result) { if (!Ulns.Contains(uln)) { Ulns.Add(uln); } } }