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); }
/// <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); }