Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index([FromQuery] AddressSelectionRequestModel requestModel)
        {
            _logger.LogMethodEnter();

            AddressSelectionResult model;

            AddressSelectionCriteria criteria = new AddressSelectionCriteria(requestModel.Id);
            var searchResult = await _postCodeSearchService.RetrieveAsync(criteria);

            if (searchResult.IsSuccess && searchResult.HasValue)
            {
                model = new AddressSelectionResult(
                    searchResult.Value.Id,
                    searchResult.Value.Line1,
                    searchResult.Value.Line2,
                    searchResult.Value.City,
                    searchResult.Value.County,
                    searchResult.Value.PostCode);
            }
            else
            {
                model = new AddressSelectionResult(searchResult.Error);
            }

            _logger.LogMethodExit();

            return(ViewComponent(nameof(ViewComponents.PostCodeSearchResult.PostCodeSearchResult), model));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> VenueAddressSelectionConfirmation(VenueAddressSelectionConfirmationRequestModel requestModel)
        {
            var viewModel = new VenueAddressSelectionConfirmationViewModel();

            if (!string.IsNullOrEmpty(requestModel.PostcodeId))
            {
                var criteria     = new AddressSelectionCriteria(requestModel.PostcodeId);
                var searchResult = await _postCodeSearchService.RetrieveAsync(criteria);

                if (searchResult.IsSuccess && searchResult.HasValue)
                {
                    viewModel.Address = new AddressModel
                    {
                        Id           = searchResult.Value.Id,
                        AddressLine1 = searchResult.Value.Line1,
                        AddressLine2 = searchResult.Value.Line2,
                        TownOrCity   = searchResult.Value.City,
                        County       = searchResult.Value.County,
                        Postcode     = searchResult.Value.PostCode
                    };
                    viewModel.Id = requestModel.Id;
                }
                else
                {
                    viewModel.Error = searchResult.Error;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(requestModel.Id))
                {
                    var criteria           = new GetVenueByIdCriteria(requestModel.Id);
                    var getVenueByIdResult = await _venueService.GetVenueByIdAsync(criteria);

                    if (getVenueByIdResult.IsSuccess && getVenueByIdResult.HasValue)
                    {
                        viewModel.Address = new AddressModel
                        {
                            //Id = getVenueByIdResult.Value.ID,
                            AddressLine1 = getVenueByIdResult.Value.Address1,
                            AddressLine2 = getVenueByIdResult.Value.Address2,
                            TownOrCity   = getVenueByIdResult.Value.Town,
                            County       = getVenueByIdResult.Value.County,
                            Postcode     = getVenueByIdResult.Value.PostCode
                        };
                    }

                    viewModel.Id = requestModel.Id;
                }
            }

            viewModel.VenueName = requestModel.VenueName;

            return(View(viewModel));
        }