Exemplo n.º 1
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.º 2
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;
 }