private IEnumerable <LookupViewModel> PopulateEvents(int venueId)
        {
            var eventList = new List <LookupViewModel>()
            {
                new LookupViewModel(0, "<New Event>")
            };

            foreach (var venue in _concertRepository
                     .GetConcerts(venueId, true)
                     .Select(c => new LookupViewModel(c.ConcertId, c.ConcertName)))
            {
                if (eventList.All(v => v.Value != venue.Value))
                {
                    eventList.Add(venue);
                }
            }

            return(eventList);
        }
Beispiel #2
0
        private async Task <ConcertListViewModel> GetSearchedConcerts(string searchValue)
        {
            // If search results contains multiple events
            var suggestions = await WingtipTicketApp.SearchIndexClient.Documents.SuggestAsync(searchValue, "sg", new SuggestParameters
            {
                UseFuzzyMatching = true
            }, CancellationToken.None);

            var concertList = new List <ConcertModel>(_concertRepository.GetConcerts());
            var venueList   = _venueRepository.GetVenues();

            var viewModel = new ConcertListViewModel()
            {
                ConcertList = new List <ConcertListViewModel.ConcertViewModel>(),
                VenueList   = venueList.Select(v => new ConcertListViewModel.VenueViewModel()
                {
                    VenueId      = v.VenueId,
                    VenueName    = v.VenueName,
                    CityId       = v.VenueCityModel.CityId,
                    CityName     = v.VenueCityModel.CityName,
                    StateId      = v.VenueCityModel.StateModel.StateId,
                    StateName    = v.VenueCityModel.StateModel.StateName,
                    ConcertCount = v.ConcertQty
                }).ToList()
            };

            foreach (var suggestion in suggestions)
            {
                var suggestedConcert      = concertList.Find(c => c.ConcertId.Equals(Convert.ToInt32(suggestion.Document["ConcertId"])));
                var suggestedConcertVenue = venueList.Find(v => v.VenueId.Equals(suggestedConcert.VenueId));

                suggestedConcert.VenueModel = suggestedConcertVenue;
                viewModel.ConcertList.Add(new ConcertListViewModel.ConcertViewModel()
                {
                    ConcertId = suggestedConcert.ConcertId,
                    Name      = suggestedConcert.ConcertName,
                    Date      = suggestedConcert.ConcertDate,
                    Performer = suggestedConcert.PerformerModel.ShortName,
                    Venue     = suggestedConcert.VenueModel.VenueName
                });
            }

            return(viewModel);
        }
Beispiel #3
0
 /// <see cref="IConcertService.GetConcerts()"/>
 public IEnumerable <EventModel> GetConcerts()
 {
     return(_concertRepository.GetConcerts().Select(ConcertModelHelper.GetConcertModel));
 }