public static EventListView FromSearchHits(IEnumerable<ConcertSearchHit> hits)
        {
            var city = new City();
            var view = new EventListView()
            {

                ConcertsList = hits.Select(h => new Concert
                {
                    ConcertId = int.Parse(h.ConcertId),
                    ConcertName = h.ConcertName,
                    ConcertDate = h.ConcertDate.LocalDateTime,
                    Performer = new Performer
                    {
                        PerformerId = h.PerformerId, ShortName = h.PerformerName
                    },
                    PerformerId = h.PerformerId,
                    Venue = new Venue
                    {
                        VenueId = h.VenueId, VenueName = h.VenueName, Description = h.PerformerName, VenueCity = new City
                        {
                            CityName = h.VenueCity
                        }
                    },
                    VenueId = h.VenueId
                }).ToList(),
                VenuesList = hits.Select(h => new
                {
                    h.VenueId, h.VenueName, h.VenueCity, h.VenueState
                })
                                 .Distinct()
                                 .Select(v => new Venue
                                 {
                                     VenueId = v.VenueId, VenueName = v.VenueName, VenueCity = new City
                                     {
                                         CityName = v.VenueCity, State = new State
                                         {
                                             StateName = v.VenueState
                                         }
                                     }
                                 })
                                 .ToList()
            };

            return view;
        }
Exemplo n.º 2
0
        private Venue populateSingleVenueFromDbReader(SqlDataReader dbReader)
        {
            var venueCountry = new Country
            {
                CountryName = dbReader.GetString(dbReader.GetOrdinal(@"countryName"))
            };
            var venueState = new State
            {
                StateName = dbReader.GetString(dbReader.GetOrdinal(@"stateName")),
                Description = (dbReader.IsDBNull(dbReader.GetOrdinal(@"stateDescription"))) ? "":
                                    dbReader.GetString(dbReader.GetOrdinal(@"stateDescription")),
                Country = venueCountry
            };
            var venueCity = new City
            {
                CityName = dbReader.GetString(dbReader.GetOrdinal(@"cityName")),
                CityId = dbReader.GetInt32(dbReader.GetOrdinal("cityId")),
                Description = (dbReader.IsDBNull(dbReader.GetOrdinal(@"cityDescription"))) ? "" :
                                    dbReader.GetString(dbReader.GetOrdinal(@"cityDescription")),
                State = venueState
            };
            var venueToReturn = new Venue
            {
                VenueName = dbReader.GetString(dbReader.GetOrdinal(@"venueName")),
                Capacity = dbReader.GetInt32(dbReader.GetOrdinal(@"venueCapacity")),
                Description = (dbReader.IsDBNull(dbReader.GetOrdinal(@"venueDescription"))) ? "" :
                                    dbReader.GetString(dbReader.GetOrdinal(@"venueDescription")),
                VenueCity = venueCity,
                VenueId = dbReader.GetInt32(dbReader.GetOrdinal(@"venueId"))
            };

            return venueToReturn;
        }
Exemplo n.º 3
0
 private List<City> getCitiesInternal()
 {
     List<City> citiesList = new List<City>();
     try
     {
         using (var conn = new SqlConnection(constructVenuesConnectString()))
         {
             conn.Open();
             using (var queryCommand = new SqlCommand(CONST_GetAllCities, conn))
             using (SqlDataReader reader = queryCommand.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     Country cityCountry = new Country
                     {
                         CountryName = reader.GetString(reader.GetOrdinal("countryName")),
                         CountryId = reader.GetInt32(reader.GetOrdinal("countryId"))
                     };
                     State cityState = new State
                     {
                         StateName = reader.GetString(reader.GetOrdinal("stateName")),
                         StateId = reader.GetInt32(reader.GetOrdinal("stateId")),
                         Country = cityCountry
                     };
                     City cityToAdd = new City
                     {
                         CityId = reader.GetInt32(reader.GetOrdinal("cityId")),
                         CityName = reader.GetString(reader.GetOrdinal("cityName")),
                         Description = (reader.IsDBNull(reader.GetOrdinal("cityDescription"))) ? "" :
                                         reader.GetString(reader.GetOrdinal("cityDescription")),
                         State = cityState
                     };
                     citiesList.Add(cityToAdd);
                 }
             }
         }
     }
     catch { }
     return citiesList;
 }