Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs =================================================================== diff -u -re3ec5f4669022733a11c4c3070747331bf36056f -ra26ca78511abc3f3e04021c203ed484402c3eba4 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs) (revision e3ec5f4669022733a11c4c3070747331bf36056f) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs) (revision a26ca78511abc3f3e04021c203ed484402c3eba4) @@ -57,37 +57,12 @@ return UpdateTargetCollectionData(targetDataCollection, importedDataCollection, sourceFilePath); } - protected override IEnumerable UpdateObjectAndDependentData(DikeProfile objectToUpdate, DikeProfile objectToUpdateFrom) - { - objectToUpdate.CopyProperties(objectToUpdateFrom); - - var affectedObjects = new List(); - affectedObjects.AddRange(UpdateDikeDependentData(objectToUpdate)); - - return affectedObjects; - } - protected override IEnumerable RemoveObjectAndDependentData(DikeProfile removedObject) { return GrassCoverErosionInwardsDataSynchronizationService.RemoveDikeProfile(FailureMechanism, removedObject); } - private IEnumerable UpdateDikeDependentData(DikeProfile objectToUpdate) - { - var affectedObjects = new List(); - foreach (GrassCoverErosionInwardsCalculation calculation in GetAffectedCalculationsWithDikeProfile(objectToUpdate)) - { - affectedObjects.Add(calculation.InputParameters); - affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(calculation)); - } - - affectedObjects.AddRange(GrassCoverErosionInwardsHelper.UpdateCalculationToSectionResultAssignments( - FailureMechanism.SectionResults, - FailureMechanism.Calculations.Cast())); - return affectedObjects; - } - private IEnumerable GetAffectedCalculationsWithDikeProfile(DikeProfile objectToUpdate) { IEnumerable affectedCalculations = @@ -112,5 +87,39 @@ return obj.Id.GetHashCode(); } } + + #region Update logic + + protected override IEnumerable UpdateObjectAndDependentData(DikeProfile objectToUpdate, DikeProfile objectToUpdateFrom) + { + objectToUpdate.CopyProperties(objectToUpdateFrom); + + var affectedObjects = new List(); + affectedObjects.AddRange(UpdateDikeDependentData(objectToUpdate)); + + return affectedObjects; + } + + private IEnumerable UpdateDikeDependentData(DikeProfile objectToUpdate) + { + var affectedObjects = new List(); + foreach (GrassCoverErosionInwardsCalculation calculation in GetAffectedCalculationsWithDikeProfile(objectToUpdate)) + { + affectedObjects.Add(calculation.InputParameters); + affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(calculation)); + + if (!objectToUpdate.ForeshoreGeometry.Any()) + { + calculation.InputParameters.UseForeshore = false; + } + } + + affectedObjects.AddRange(GrassCoverErosionInwardsHelper.UpdateCalculationToSectionResultAssignments( + FailureMechanism.SectionResults, + FailureMechanism.Calculations.Cast())); + return affectedObjects; + } + + #endregion } } \ No newline at end of file