private CartoViewModel InitModel()
        {
            var model = new CartoViewModel();

            model.LastSaved  = _cartoPlaceService.LastSaved;
            model.HasChanges = _cartoPlaceService.HasChanges;

            model.Places = _cartoPlaceService.ListPlaces();

            model.Countries  = _cartoPlaceService.ListCountries();
            model.PlaceTypes = _cartoPlaceService.ListPlaceTypes();

            model.SourceCountries = _tripSheetService.ListCountries();
            model.SourceYears     = _tripSheetService.ListYears();

            return(model);
        }
        public ActionResult Places(int?year, string country = "")
        {
            var model = new OrthoPlacesViewModel();

            model.Years        = _tripSheetService.ListYears();
            model.SelectedYear = year;

            model.Countries       = _tripSheetService.ListCountries();
            model.SelectedCountry = GeoCountryInfo.Find(country);

            var places = new List <OrthoPlaceImportModel>();
            var import = _tripSheetService.ListPlaces(year, country);

            foreach (var data in import)
            {
                var place = new OrthoPlaceImportModel();
                place.Data = data;
                places.Add(place);

                // find existing place by region
                var r = GeoRegionInfo.Find(data.Region);
                if (r != null)
                {
                    place.Place = _cartoPlaceService.FindPlace(r, data.Name, true);
                }

                // find existing place by country
                if (place.Place == null)
                {
                    var c = GeoCountryInfo.Find(data.Country);
                    if (c != null)
                    {
                        place.Place = _cartoPlaceService.FindPlace(c, data.Name, true);
                    }
                }
            }
            model.Places = places;

            return(View(model));
        }