Maps to 'City' table in application database schema
        public static ConcertListModel FromSearchHits(IEnumerable<ConcertSearchHit> hits)
        {
            var city = new CityModel();
            var view = new ConcertListModel()
            {

                ConcertsList = hits.Select(h => new ConcertModel
                {
                    ConcertId = int.Parse(h.ConcertId),
                    ConcertName = h.ConcertName,
                    ConcertDate = h.ConcertDate.LocalDateTime,
                    PerformerModel = new PerformerModel
                    {
                        PerformerId = h.PerformerId, ShortName = h.PerformerName
                    },
                    PerformerId = h.PerformerId,
                    VenueModel = new VenueModel
                    {
                        VenueId = h.VenueId, VenueName = h.VenueName, Description = h.PerformerName, VenueCityModel = new CityModel
                        {
                            CityName = h.VenueCity
                        }
                    },
                    VenueId = h.VenueId
                }).ToList(),
                VenuesList = hits.Select(h => new
                {
                    h.VenueId, h.VenueName, h.VenueCity, h.VenueState
                })
                                 .Distinct()
                                 .Select(v => new VenueModel
                                 {
                                     VenueId = v.VenueId, VenueName = v.VenueName, VenueCityModel = new CityModel
                                     {
                                         CityName = v.VenueCity, StateModel = new StateModel
                                         {
                                             StateName = v.VenueState
                                         }
                                     }
                                 })
                                 .ToList()
            };

            return view;
        }
        public static ConcertListModel FromSearchHits(IEnumerable <ConcertSearchHit> hits)
        {
            var city = new CityModel();
            var view = new ConcertListModel()
            {
                ConcertsList = hits.Select(h => new ConcertModel
                {
                    ConcertId      = int.Parse(h.ConcertId),
                    ConcertName    = h.ConcertName,
                    ConcertDate    = h.ConcertDate.LocalDateTime,
                    PerformerModel = new PerformerModel
                    {
                        PerformerId = h.PerformerId, ShortName = h.PerformerName
                    },
                    PerformerId = h.PerformerId,
                    VenueModel  = new VenueModel
                    {
                        VenueId = h.VenueId, VenueName = h.VenueName, Description = h.PerformerName, VenueCityModel = new CityModel
                        {
                            CityName = h.VenueCity
                        }
                    },
                    VenueId = h.VenueId
                }).ToList(),
                VenuesList = hits.Select(h => new
                {
                    h.VenueId, h.VenueName, h.VenueCity, h.VenueState
                })
                             .Distinct()
                             .Select(v => new VenueModel
                {
                    VenueId = v.VenueId, VenueName = v.VenueName, VenueCityModel = new CityModel
                    {
                        CityName = v.VenueCity, StateModel = new StateModel
                        {
                            StateName = v.VenueState
                        }
                    }
                })
                             .ToList()
            };

            return(view);
        }
        private bool UpsertVenue(EventAdministrationViewModel viewModel, CityModel cityModelFromDb, out VenueModel venueModelFromDb)
        {
            // Add venue if it doesn't exist
            if (!string.IsNullOrWhiteSpace(viewModel.NewVenue))
            {
                venueModelFromDb = _venueRepository.GetVenues().FirstOrDefault(ven => String.CompareOrdinal(ven.VenueName, viewModel.NewVenue.Trim()) == 0);

                if (venueModelFromDb == null)
                {
                    venueModelFromDb = _venueRepository.AddNewVenue(viewModel.NewVenue, cityModelFromDb.CityId);

                    if (venueModelFromDb == null)
                    {
                        DisplayMessage(String.Format(" Failed to add new Venue '{0}'. Cannot Continue.", viewModel.NewVenue));
                        return false;
                    }
                }
            }
            else
            {
                venueModelFromDb = _venueRepository.GetVenues().FirstOrDefault(ven => ven.VenueId == viewModel.VenueId);
            }

            return true;
        }
        private bool UpsertCity(EventAdministrationViewModel viewModel, out CityModel cityModelFromDb)
        {
            // Add city if it doesn't exist
            if (!string.IsNullOrWhiteSpace(viewModel.NewCity))
            {
                cityModelFromDb = _cityRepository.GetCityByName(viewModel.NewCity.Trim());

                if (cityModelFromDb == null)
                {
                    cityModelFromDb = _cityRepository.AddNewCity(viewModel.NewCity);

                    if (cityModelFromDb == null)
                    {
                        DisplayMessage(String.Format(" Failed to add new City '{0}'. Cannot Continue.", viewModel.NewCity));
                        return false;
                    }
                }
            }
            else
            {
                cityModelFromDb = _cityRepository.GetCityById(viewModel.CityId);
            }

            return true;
        }