public async Task <GetLocationsQueryResult> Handle(GetLocationsQuery request, CancellationToken cancellationToken)
        {
            var postcodeRegexFull = @"^[A-Za-z]{1,2}[0-9]{1}([0-9]|[A-Za-z]){0,1}";
            var postcodeRegexOneLetterOneNumber = @"^[A-Za-z]{1}[0-9]{1}";

            if (request.Query.Length < 3 && Regex.IsMatch(request.Query, postcodeRegexOneLetterOneNumber))
            {
                var postcodes = await _postcodeService.GetPostcodesByOutcodeQuery(request.Query, request.ResultCount);

                var districtName = await _postcodeService.GetDistrictNameByOutcodeQuery(request.Query);

                var results = postcodes.ToList();

                if (districtName != null)
                {
                    results.Insert(0, districtName);
                }

                return(new GetLocationsQueryResult
                {
                    SuggestedLocations = results
                });
            }

            else if (request.Query.Length >= 3 && Regex.IsMatch(request.Query, postcodeRegexFull))
            {
                var postcodes = await _postcodeService.GetPostcodesByOutcodeQuery(request.Query, request.ResultCount);

                var districtName = await _postcodeService.GetDistrictNameByOutcodeQuery(request.Query);

                var results = postcodes.ToList();
                if (districtName != null)
                {
                    results.Insert(0, districtName);
                }

                return(new GetLocationsQueryResult
                {
                    SuggestedLocations = results
                });
            }
            else if (request.Query.Length >= 3)
            {
                var result = await _locationService.GetLocationsByQuery(request.Query, request.ResultCount);

                return(new GetLocationsQueryResult
                {
                    SuggestedLocations = result.Select(c => (SuggestedLocation)c).ToList()
                });
            }

            return(new GetLocationsQueryResult
            {
                SuggestedLocations = null
            });
        }
        public async Task <GetOutcodeQueryResult> Handle(GetOutcodeQuery request, CancellationToken cancellationToken)
        {
            var result = await _service.GetDistrictNameByOutcodeQuery(request.Outcode);

            return(new GetOutcodeQueryResult
            {
                Outcode = result
            });
        }