Ejemplo n.º 1
0
        private async Task <SelectVenueModel> GetVenuesByUkprn(int ukprn)
        {
            var selectVenue = new SelectVenueModel
            {
                LabelText       = "Select course venue",
                HintText        = "Select all that apply.",
                AriaDescribedBy = "Select all that apply.",
                Ukprn           = ukprn
            };

            var venues = await _cosmosDbQueryDispatcher.ExecuteQuery(new GetVenuesByProvider()
            {
                ProviderUkprn = ukprn
            });

            selectVenue.VenueItems = venues.Select(v => new VenueItemModel()
            {
                Id        = v.Id.ToString(),
                VenueName = v.VenueName
            }).ToList();

            if (selectVenue.VenueItems.Count == 1)
            {
                selectVenue.HintText        = string.Empty;
                selectVenue.AriaDescribedBy = string.Empty;
            }

            return(selectVenue);
        }
Ejemplo n.º 2
0
        private async Task <SelectVenueModel> GetVenuesForProvider()
        {
            var providerContext = _providerContextProvider.GetProviderContext(withLegacyFallback: true);

            var selectVenue = new SelectVenueModel
            {
                LabelText       = "Select course venue",
                HintText        = "Select all that apply.",
                AriaDescribedBy = "Select all that apply.",
                Ukprn           = providerContext.ProviderInfo.Ukprn
            };

            var venues = await _sqlQueryDispatcher.ExecuteQuery(new GetVenuesByProvider()
            {
                ProviderId = providerContext.ProviderInfo.ProviderId
            });

            selectVenue.VenueItems = venues.Select(v => new VenueItemModel()
            {
                Id        = v.VenueId.ToString(),
                VenueName = v.VenueName
            }).ToList();

            if (selectVenue.VenueItems.Count == 1)
            {
                selectVenue.HintText        = string.Empty;
                selectVenue.AriaDescribedBy = string.Empty;
            }

            return(selectVenue);
        }
        private async Task <SelectVenueModel> GetVenuesByUkprn(int ukprn)
        {
            var selectVenue = new SelectVenueModel
            {
                LabelText       = "Select course venue",
                HintText        = "Select all that apply.",
                AriaDescribedBy = "Select all that apply.",
                Ukprn           = ukprn
            };
            var requestModel = new VenueSearchRequestModel {
                SearchTerm = ukprn.ToString()
            };
            var criteria = _venueSearchHelper.GetVenueSearchCriteria(requestModel);
            var result   = await _venueService.SearchAsync(criteria);

            if (result.IsSuccess)
            {
                var items      = _venueSearchHelper.GetVenueSearchResultItemModels(result.Value.Value);
                var venueItems = new List <VenueItemModel>();

                foreach (var venueSearchResultItemModel in items)
                {
                    venueItems.Add(new VenueItemModel
                    {
                        Id        = venueSearchResultItemModel.Id,
                        VenueName = venueSearchResultItemModel.VenueName
                    });
                }

                if (venueItems.Count == 1)
                {
                    selectVenue.HintText        = string.Empty;
                    selectVenue.AriaDescribedBy = string.Empty;
                }

                selectVenue.VenueItems = venueItems;
            }

            return(selectVenue);
        }