/// <summary> /// get (the) touchpoint id from (the) Postcode /// </summary> /// <param name="theCandidate">the candidate</param> /// <param name="usingScope">using (the logging) scope</param> /// <returns>the LAD code</returns> public async Task <string> GetTouchpointIDFromPostcode(string theCandidate, IScopeLoggingContext usingScope) { await usingScope.EnterMethod(); await usingScope.Information($"seeking postcode '{theCandidate}'"); var result = await Postcode.LookupAsync(theCandidate); It.IsNull(result) .AsGuard <InvalidPostcodeException>(theCandidate); It.IsEmpty(result.Postcode) .AsGuard <InvalidPostcodeException>(theCandidate); await usingScope.Information($"found postcode for '{result.Postcode}'"); await usingScope.Information($"seeking local authority '{result.Codes.AdminDistrict}'"); var authority = await Authority.Get(result.Codes.AdminDistrict); await usingScope.Information($"found local authority '{authority.LADCode}'"); await usingScope.ExitMethod(); return(authority.TouchpointID); }