예제 #1
0
        public async Task <IViewComponentResult> InvokeAsync(ChooseVenueModel model)
        {
            var providerId = _providerContextProvider.GetProviderId(withLegacyFallback: true);

            List <SelectListItem> venues = new List <SelectListItem>();

            var result = await _sqlQueryDispatcher.ExecuteQuery(new GetVenuesByProvider()
            {
                ProviderId = providerId
            });

            var defaultItem = new SelectListItem {
                Text = "Select", Value = ""
            };

            foreach (var venue in result)
            {
                var item = new SelectListItem {
                    Text = venue.VenueName, Value = venue.VenueId.ToString()
                };
                venues.Add(item);
            }
            ;

            venues.Insert(0, defaultItem);

            model.Venues = venues;
            return(View("~/ViewComponents/Courses/ChooseVenue/Default.cshtml", model));
        }
예제 #2
0
        public async Task <IViewComponentResult> InvokeAsync(ChooseVenueModel model)
        {
            List <SelectListItem> venues = new List <SelectListItem>();

            var UKPRN = Session.GetInt32("UKPRN");

            if (UKPRN.HasValue)
            {
                var result = await _cosmosDbQueryDispatcher.ExecuteQuery(new GetVenuesByProvider()
                {
                    ProviderUkprn = UKPRN.Value
                });

                var defaultItem = new SelectListItem {
                    Text = "Select", Value = ""
                };

                foreach (var venue in result)
                {
                    var item = new SelectListItem {
                        Text = venue.VenueName, Value = venue.Id.ToString()
                    };
                    venues.Add(item);
                }
                ;

                venues.Insert(0, defaultItem);
            }

            model.Venues = venues;
            return(View("~/ViewComponents/Courses/ChooseVenue/Default.cshtml", model));
        }
예제 #3
0
        public async Task <IViewComponentResult> InvokeAsync(ChooseVenueModel model)
        {
            List <SelectListItem> venues = new List <SelectListItem>();

            var UKPRN = Session.GetInt32("UKPRN");

            if (UKPRN.HasValue)
            {
                var requestModel = new VenueSearchRequestModel {
                    SearchTerm = Session.GetInt32("UKPRN").Value.ToString()
                };
                var criteria = _venueSearchHelper.GetVenueSearchCriteria(requestModel);
                var result   = await _venueService.SearchAsync(criteria);

                if (result.IsSuccess)
                {
                    var defaultItem = new SelectListItem {
                        Text = "Select", Value = ""
                    };

                    foreach (var venue in result.Value.Value.Where(x => x.Status == VenueStatus.Live))
                    {
                        var item = new SelectListItem {
                            Text = venue.VenueName, Value = venue.ID
                        };
                        venues.Add(item);
                    }
                    ;

                    venues.Insert(0, defaultItem);
                }
            }

            model.Venues = venues;
            return(View("~/ViewComponents/Courses/ChooseVenue/Default.cshtml", model));
        }