Beispiel #1
0
        public void AutoAssignProjectPriorityLandscapesAndDnrUplandRegions()
        {
            var detailedProjectLocations                    = ProjectLocations.Select(x => x.ProjectLocationGeometry).ToList();
            var projectHasDetailedLocations                 = HasProjectLocationDetail;
            var detailedProjectLocationsAggregated          = HasProjectLocationDetail ? detailedProjectLocations.Aggregate((x, y) => x.Union(y)) : null;
            var detailedProjectLocationsAggregatedMadeValid = HasProjectLocationDetail ? (detailedProjectLocationsAggregated.IsValid ? detailedProjectLocationsAggregated : detailedProjectLocationsAggregated.ToSqlGeometry().MakeValid().ToDbGeometryWithCoordinateSystem()) : null;

            var projectLocationPoint       = this.ProjectLocationPoint;
            var projectLocationPointExists = this.HasProjectLocationPoint;

            var updatedProjectPriorityLandscapes = HttpRequestStorage.DatabaseEntities.PriorityLandscapes
                                                   .Where(x => (projectHasDetailedLocations && x.PriorityLandscapeLocation.Intersects(detailedProjectLocationsAggregatedMadeValid)) || (projectLocationPointExists && x.PriorityLandscapeLocation.Intersects(projectLocationPoint)))
                                                   .ToList()
                                                   .Select(x => new ProjectPriorityLandscape(ProjectID, x.PriorityLandscapeID))
                                                   .ToList();

            if (!updatedProjectPriorityLandscapes.Any())
            {
                NoPriorityLandscapesExplanation =
                    "Neither the simple location nor the detailed location on this project intersects with any Priority Landscape.";
            }
            else
            {
                NoPriorityLandscapesExplanation = null;
            }


            ProjectPriorityLandscapes.Merge(updatedProjectPriorityLandscapes, HttpRequestStorage.DatabaseEntities.ProjectPriorityLandscapes.Local, (x, y) => x.ProjectID == y.ProjectID && x.PriorityLandscapeID == y.PriorityLandscapeID);

            var updatedProjectRegions = HttpRequestStorage.DatabaseEntities.DNRUplandRegions
                                        .Where(x => (projectHasDetailedLocations && x.DNRUplandRegionLocation.Intersects(detailedProjectLocationsAggregatedMadeValid)) || (projectLocationPointExists && x.DNRUplandRegionLocation.Intersects(projectLocationPoint)))
                                        .ToList()
                                        .Select(x => new ProjectRegion(ProjectID, x.DNRUplandRegionID))
                                        .ToList();

            if (!updatedProjectRegions.Any())
            {
                NoRegionsExplanation =
                    "Neither the simple location nor the detailed location on this project intersects with any DNR Upland Region.";
            }
            else
            {
                NoRegionsExplanation = null;
            }

            ProjectRegions.Merge(updatedProjectRegions, HttpRequestStorage.DatabaseEntities.ProjectRegions.Local, (x, y) => x.ProjectID == y.ProjectID && x.DNRUplandRegionID == y.DNRUplandRegionID);
        }
Beispiel #2
0
        public void AutoAssignProjectPriorityLandscapes(DbGeometry projectLocation)
        {
            var geometry = projectLocation.IsValid ? projectLocation : projectLocation.ToSqlGeometry().MakeValid().ToDbGeometryWithCoordinateSystem();

            var updatedProjectPriorityLandscapes = HttpRequestStorage.DatabaseEntities.PriorityLandscapes
                                                   .Where(x => x.PriorityLandscapeLocation.Intersects(geometry))
                                                   .ToList()
                                                   .Select(x => new ProjectPriorityLandscape(ProjectID, x.PriorityLandscapeID))
                                                   .ToList();

            ProjectPriorityLandscapes.Merge(updatedProjectPriorityLandscapes, HttpRequestStorage.DatabaseEntities.ProjectPriorityLandscapes.Local, (x, y) => x.ProjectID == y.ProjectID && x.PriorityLandscapeID == y.PriorityLandscapeID);

            var updatedProjectRegions = HttpRequestStorage.DatabaseEntities.DNRUplandRegions
                                        .Where(x => x.DNRUplandRegionLocation.Intersects(geometry))
                                        .ToList()
                                        .Select(x => new ProjectRegion(ProjectID, x.DNRUplandRegionID))
                                        .ToList();

            ProjectRegions.Merge(updatedProjectRegions, HttpRequestStorage.DatabaseEntities.ProjectRegions.Local, (x, y) => x.ProjectID == y.ProjectID && x.DNRUplandRegionID == y.DNRUplandRegionID);
        }