private ConcertModel PopulateSingleConcertFromDbReader(SqlDataReader dbReader) { var concertPerformer = new PerformerModel { PerformerId = dbReader.GetInt32(dbReader.GetOrdinal(@"performerId")), FirstName = dbReader.GetString(dbReader.GetOrdinal(@"performerFirstName")), LastName = dbReader.GetString(dbReader.GetOrdinal(@"performerLastName")), ShortName = dbReader.GetString(dbReader.GetOrdinal(@"performerShortName")) }; var concertToReturn = new ConcertModel { ConcertId = dbReader.GetInt32(dbReader.GetOrdinal(@"concertId")), ConcertDate = dbReader.GetDateTime(dbReader.GetOrdinal(@"concertDate")), ConcertName = dbReader.GetString(dbReader.GetOrdinal(@"concertName")), VenueId = dbReader.GetInt32(dbReader.GetOrdinal(@"venueId")), Description = dbReader.GetString(dbReader.GetOrdinal(@"concertDescription")), PerformerId = dbReader.GetInt32(dbReader.GetOrdinal(@"concertPerformerId")), PerformerModel = concertPerformer, SaveToDbServer = (dbReader.IsDBNull(dbReader.GetOrdinal(@"saveToDatabase"))) ? ((int)ServerTargetEnum.Primary) : ((ServerTargetEnum)dbReader.GetInt32(dbReader.GetOrdinal(@"saveToDatabase"))) }; return concertToReturn; }
private void PrepareData(ref int artistId, ref int cityId, ref int venueId, int eventId, List<LookupViewModel> eventList, List<LookupViewModel> artistList) { #region - Prepare selections - if (artistId == 0) { artistId = -1; } if (cityId == 0) { cityId = -1; } if (venueId == 0) { venueId = -1; } #endregion var selectedConcert = new ConcertModel(); if (eventId > 0 && eventList.Any(a => a.Value != null && (int)a.Value == eventId)) { selectedConcert = _concertRepository.GetConcerts(venueId, true).First(a => a.ConcertId == eventId); artistId = selectedConcert.PerformerId; artistList.RemoveAll(a => a.Value != selectedConcert.PerformerId); } else if (eventId == 0 || eventId == -1) { selectedConcert.ConcertId = -1; } }