Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -ra760d63747f5c44e99f4e747ace1b4e51c040362 -r6a9a423fddb189769e43cc9d69d4dd828a6f68e2 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision a760d63747f5c44e99f4e747ace1b4e51c040362) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 6a9a423fddb189769e43cc9d69d4dd828a6f68e2) @@ -52,6 +52,7 @@ private readonly Dictionary failureMechanismSections = new Dictionary(); private readonly Dictionary hydraulicLocations = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary calculationGroups = new Dictionary(new ReferenceEqualityComparer()); + private readonly Dictionary pipingCalculations = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary stochasticSoilModels = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary stochasticSoilProfiles = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary soilProfiles = new Dictionary(new ReferenceEqualityComparer()); @@ -96,6 +97,22 @@ /// Registers a create or update operation for and the /// that was constructed with the information. /// + /// The that was registered. + /// The which needed to registered. + /// Thrown when either: + /// + /// is null + /// is null + /// + public void Register(PipingCalculationEntity entity, PipingCalculationScenario model) + { + Register(pipingCalculations, entity, model); + } + + /// + /// Registers a create or update operation for and the + /// that was constructed with the information. + /// /// The that was registered. /// The which needed to be registered. /// Thrown when either: @@ -224,15 +241,97 @@ /// Checks whether a create or update operations has been registered for the given /// . /// - /// The to check for. + /// The to check for. /// true if the was created before, false otherwise. /// Thrown when is null. + internal bool Contains(StochasticSoilModel model) + { + return ContainsValue(stochasticSoilModels, model); + } + + /// + /// Checks whether a create or update operations has been registered for the given + /// . + /// + /// The to check for. + /// true if the was created before, false otherwise. + /// Thrown when is null. + internal bool Contains(StochasticSoilProfile model) + { + return ContainsValue(stochasticSoilProfiles, model); + } + + /// + /// Checks whether a create or update operations has been registered for the given + /// . + /// + /// The to check for. + /// true if the was created before, false otherwise. + /// Thrown when is null. internal bool Contains(PipingSoilProfile model) { return ContainsValue(soilProfiles, model); } /// + /// Checks whether a create or update operations has been registered for the given + /// . + /// + /// The to check for. + /// true if the was created before, false otherwise. + /// Thrown when is null. + internal bool Contains(HydraulicBoundaryLocation model) + { + return ContainsValue(hydraulicLocations, model); + } + + /// + /// Checks whether a create or update operations has been registered for the given + /// . + /// + /// The to check for. + /// true if the was created before, false otherwise. + /// Thrown when is null. + internal bool Contains(RingtoetsPipingSurfaceLine model) + { + return ContainsValue(surfaceLines, model); + } + + /// + /// Obtains the which was registered for + /// the given . + /// + /// The for which a read/update + /// operation has been registered. + /// The created . + /// Thrown when is null. + /// Thrown when no create operation + /// has been registered for . + /// Use to find out whether + /// a create operation has been registered for . + internal StochasticSoilModelEntity Get(StochasticSoilModel model) + { + return Get(stochasticSoilModels, model); + } + + /// + /// Obtains the which was registered for + /// the given . + /// + /// The for which a read/update + /// operation has been registered. + /// The created . + /// Thrown when is null. + /// Thrown when no create operation + /// has been registered for . + /// Use to find out whether + /// a create operation has been registered for . + internal StochasticSoilProfileEntity Get(StochasticSoilProfile model) + { + return Get(stochasticSoilProfiles, model); + } + + /// /// Obtains the which was registered for the given /// . /// @@ -241,14 +340,48 @@ /// Thrown when is null. /// Thrown when no create operation /// has been registered for . - /// Use to find out whether a create operation has + /// Use to find out whether a create operation has /// been registered for . internal SoilProfileEntity Get(PipingSoilProfile model) { return Get(soilProfiles, model); } /// + /// Obtains the which was registered for the given + /// . + /// + /// The for which a + /// read/update operation has been registered. + /// The constructed . + /// Thrown when is null. + /// Thrown when no create/update operation + /// has been registered for . + /// Use to find out + /// whether a create/update operation has been registered for . + internal SurfaceLineEntity Get(RingtoetsPipingSurfaceLine model) + { + return Get(surfaceLines, model); + } + + /// + /// Obtains the which was registered for the + /// given . + /// + /// The for which a + /// read/update operation has been registered. + /// The constructed . + /// Thrown when is null. + /// Thrown when no create/update operation + /// has been registered for . + /// Use to find out + /// whether a create/update operation has been registered for . + internal HydraulicLocationEntity Get(HydraulicBoundaryLocation model) + { + return Get(hydraulicLocations, model); + } + + /// /// Registers a create or update operation for and the /// that was constructed with the information. /// @@ -291,8 +424,6 @@ /// Thrown when is null. /// Thrown when no create operation /// has been registered for . - /// Use to find out whether a create or update - /// operation has been registered for . internal SurfaceLinePointEntity GetSurfaceLinePoint(Point3D model) { return Get(surfaceLinePoints, model); @@ -350,6 +481,11 @@ calculationGroups[entity].StorageId = entity.CalculationGroupEntityId; } + foreach (var entity in pipingCalculations.Keys) + { + pipingCalculations[entity].StorageId = entity.PipingCalculationEntityId; + } + foreach (var entity in stochasticSoilModels.Keys) { stochasticSoilModels[entity].StorageId = entity.StochasticSoilModelEntityId; @@ -432,6 +568,13 @@ .Except(calculationGroups.Keys); calculationGroupEntities.RemoveRange(calculationGroupEntitiesToRemove); + var pipingCalculationEntities = dbContext.PipingCalculationEntities; + var pipingCalculationEntitiesToRemove = pipingCalculationEntities + .Local + .Where(entity => entity.PipingCalculationEntityId > 0) + .Except(pipingCalculations.Keys); + pipingCalculationEntities.RemoveRange(pipingCalculationEntitiesToRemove); + var stochasticSoilModelEntities = dbContext.StochasticSoilModelEntities; var stochasticSoilModelEntitiesToRemove = stochasticSoilModelEntities .Local