Ejemplo n.º 1
0
        private async Task AddCatchmentEntity(Entities.Catchment catchmentEntity, CatchmentIdentity catchmentIdentity)
        {
            await this.ExecuteInContextAsync(async dbContext =>
            {
                dbContext.Catchments.Add(catchmentEntity);

                await dbContext.SaveChangesAsync();
            });

            // AFTER the catchment is added, set its grid units!
            await this.GridUnitsRepository.SetGridUnitsForCatchment(catchmentIdentity);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// A way to add a multipolygon. Avoids erroneous conversion from multiple polygons containing holes to a simple list of coordinates.
        /// </summary>
        public async Task Add(GeoJsonMultiPolygonJsonString geoJsonMultiPolygonJsonString, Catchment otherCatchmentInfo)
        {
            var geographyFactory = await this.GeometryFactoryProvider.GetGeometryFactoryAsync();

            var multiPolygonGeometry = geoJsonMultiPolygonJsonString.ToMultiPolygon(geographyFactory);

            var catchmentEntity = new Entities.Catchment {
                Identity = otherCatchmentInfo.Identity.Value,
                Name     = otherCatchmentInfo.Name,
                Boundary = multiPolygonGeometry,
            };

            await this.AddCatchmentEntity(catchmentEntity, otherCatchmentInfo.Identity);
        }