Exemple #1
0
        public EventListView GenerateEventListView(int venueId = 0, int cityId = 0)
        {
            var eventListView = new EventListView
            {
                SelectedVenue = venueId,
                SelectedCity  = cityId
            };

            var concertsList = new List <Concert>(ConcertDbContext.GetConcerts().Where(a => DateTime.Compare(a.ConcertDate, DateTime.Today) >= 0));

            // If Concerts have expired, roll dates forward
            if (concertsList.Count < 2)
            {
                if (!new ResetCode().RefreshConcerts(false))
                {
                    // If connection fails, prompt user on troubleshoot steps
                    UpdateStatus(string.Format("ERROR connecting to {0} database server.  Make sure: 1. The database server name, username and password in the web.config are correct, 2. Auditing is enabled on the Database Server, 3. Firewall rules allow access - including Azure Services, and 4. the Database server name resolves using nslookup.", WingtipTicketApp.Config.PrimaryDatabaseServer));
                }
            }

            foreach (var concert in concertsList)
            {
                if (eventListView.VenuesList.All(a => a.VenueId != concert.VenueId))
                {
                    eventListView.VenuesList.Add(VenuesDbContext.GetVenueByVenueId(concert.VenueId));
                }

                eventListView.ConcertsList.Add(concert);
                concert.Venue = eventListView.VenuesList.FirstOrDefault(a => a.VenueId == concert.VenueId);
            }

            return(eventListView);
        }