Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs
===================================================================
diff -u -rd86b1c6e4ebde1570bec162a9043bbb437de5d9c -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs (.../StochasticSoilProfileUpdateExtensions.cs) (revision d86b1c6e4ebde1570bec162a9043bbb437de5d9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs (.../StochasticSoilProfileUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// All rights reserved.
using System;
-using System.Linq;
using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Exceptions;
-using Application.Ringtoets.Storage.Properties;
using Ringtoets.Piping.Data;
namespace Application.Ringtoets.Storage.Update
@@ -47,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this StochasticSoilProfile profile, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -59,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- StochasticSoilProfileEntity entity = GetCorrespondingStochasticSoilProfileEntity(profile, context);
+ StochasticSoilProfileEntity entity = profile.GetCorrespondingEntity(
+ context.StochasticSoilProfileEntities,
+ o => o.StochasticSoilProfileEntityId);
+
entity.Probability = Convert.ToDecimal(profile.Probability);
if (profile.SoilProfile.IsNew())
@@ -73,17 +74,5 @@
registry.Register(entity, profile);
}
-
- private static StochasticSoilProfileEntity GetCorrespondingStochasticSoilProfileEntity(StochasticSoilProfile profile, IRingtoetsEntities context)
- {
- try
- {
- return context.StochasticSoilProfileEntities.Single(sspe => sspe.StochasticSoilProfileEntityId == profile.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(StochasticSoilProfileEntity).Name, profile.StorageId), exception);
- }
- }
}
}
\ No newline at end of file