public virtual async Task <List <McaGlaSofLookup> > RetrieveMcaGlaLookups(IPostcodesContext context, CancellationToken cancellationToken)
        {
            var mcaGlaFullNames = await context.McaglaFullNames?
                                  .Where(e => e.EffectiveTo == null)
                                  .ToDictionaryAsync(
                k => k.McaglaShortCode,
                v => v.FullName,
                StringComparer.OrdinalIgnoreCase,
                cancellationToken);

            var mcaGlaSofCodes = await context.McaglaSofs?.ToListAsync(cancellationToken);

            return(mcaGlaSofCodes.Select(m => new McaGlaSofLookup
            {
                SofCode = m.SofCode,
                McaGlaShortCode = m.McaglaShortCode,
                McaGlaFullName = mcaGlaFullNames.TryGetValue(m.McaglaShortCode, out var fullname) ? fullname : string.Empty,
                EffectiveFrom = m.EffectiveFrom,
                EffectiveTo = m.EffectiveTo
            }).ToList());
Example #2
0
 public PostcodesDataService(IPostcodesContext postcodesContext)
 {
     _postcodesContext = postcodesContext;
 }
 private PostcodesDataService NewService(IPostcodesContext postcodesContext)
 {
     return(new PostcodesDataService(postcodesContext));
 }