public async Task <bool> Handle(ValidatePostcodeQuery request, CancellationToken cancellationToken) { if (String.IsNullOrWhiteSpace(request.Postcode)) { return(false); } var status = await _postcodeService.GetPostcodeStatus(request.Postcode); switch (status) { case "England": case "Wales": case "Scotland": case "Northern Ireland": return(true); default: return(false); } }
private async Task <ProviderSearchResponseCodes> GetPostcodeStatus(string postcode) { var status = await _postcodeIoService.GetPostcodeStatus(postcode); switch (status) { case "Wales": return(ProviderSearchResponseCodes.WalesPostcode); case "Scotland": return(ProviderSearchResponseCodes.ScotlandPostcode); case "Northern Ireland": return(ProviderSearchResponseCodes.NorthernIrelandPostcode); case "Terminated": return(ProviderSearchResponseCodes.PostCodeTerminated); case "Error": return(ProviderSearchResponseCodes.PostCodeInvalidFormat); } return(ProviderSearchResponseCodes.Success); }