Exemple #1
0
        public static Place FindPlaceByRoad(Road road)
        {
            using (var context = new CopacesCcDbContext())
            {
                //var fullPlaceName = road.Jurisdiction;
                //var placeName = fullPlaceName
                //    .Replace("COUNTY", "")
                //    .Replace("CITY", "")
                //    .Trim();

                //var matchPlace = context.Places.Where(p => p.Name == placeName).ToList();
                //if (!matchPlace.Any())
                //    return null;

                //// Sometimes a city and a county may have the same name,
                //// like Newton County and Newton City, so futher filtering
                //// is needed
                //Place place;
                //if (matchPlace.Count > 1)
                //{
                //    var type = fullPlaceName.ToUpper().Contains("COUNTY") ? "County" : "City";
                //    place = matchPlace.First(p => p.Type == type);
                //}
                //else
                //    place = matchPlace.First();
                var placeName = road.Jurisdiction;
                var placeType = road.PlaceType;
                var findQuery = context.Places.Where(p => p.Name == placeName && p.Type == placeType);
                if (findQuery.Any())
                    return findQuery.First();
                return null;
            }
        }
Exemple #2
0
 public static void ProcessNewRoad(Road road)
 {
     var place = FindPlaceByRoad(road);
     if (place != null)
         place.Roads.Add(road);
 }