Beispiel #1
0
        public async Task <IActionResult> Index([FromQuery] PostCodeSearchRequestModel requestModel)
        {
            _logger.LogMethodEnter();

            PostCodeSearchResultModel model;

            PostCodeSearchCriteria criteria = new PostCodeSearchCriteria(requestModel.PostCode);

            var searchResult = await _postCodeSearchService.SearchAsync(criteria);

            AddressSelectionCriteria criteria1 = new AddressSelectionCriteria("GB|RM|B|51879423");
            var x = await _postCodeSearchService.RetrieveAsync(criteria1);

            if (searchResult.IsSuccess && searchResult.HasValue)
            {
                var items = _postCodeSearchHelper.GetPostCodeSearchResultItemModels(searchResult.Value.Value);
                model = new PostCodeSearchResultModel(
                    requestModel.PostCode, null, null,
                    items);
            }
            else
            {
                model = new PostCodeSearchResultModel(searchResult.Error);
            }

            _logger.LogMethodExit();

            return(ViewComponent(nameof(ViewComponents.PostCodeSearchResult.PostCodeSearchResult), model));
        }
        public async Task <IActionResult> Index(string postcode)
        {
            var result = await _postCodeSearchService.SearchAsync(new PostCodeSearchCriteria(postcode));

            var listItems = new List <SelectListItem>();

            foreach (var item in result.Value.Value)
            {
                listItems.Add(new SelectListItem(item.Text, item.Id));
            }

            var model = new PostcodeLookupModel
            {
                PostcodeLabelText = "Postcode",
                Postcode          = postcode,
                Items             = listItems
            };

            return(ViewComponent(nameof(ViewComponents.PostcodeLookup.PostcodeLookup), model));
        }