using System;
using Application.Ringtoets.Storage.DbContext;
using Ringtoets.Integration.Data;
namespace Application.Ringtoets.Storage.Converters
{
///
/// Converter for to
/// and to .
///
public class DikeAssessmentSectionEntityConverter : IEntityConverter
{
///
/// Converts to .
///
/// The to convert.
/// A new instance of , based on the properties of .
/// Thrown when is null.
public DikeAssessmentSection ConvertEntityToModel(DikeAssessmentSectionEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException("entity");
}
var dikeAssessmentSection = new DikeAssessmentSection
{
StorageId = entity.DikeAssessmentSectionEntityId,
Name = entity.Name
};
if (entity.Norm != null)
{
dikeAssessmentSection.FailureMechanismContribution.Norm = entity.Norm.Value;
}
return dikeAssessmentSection;
}
///
/// Converts to .
///
/// The to convert.
/// A reference to the to be saved.
/// Thrown when:
/// - is null
/// - is null.
///
public void ConvertModelToEntity(DikeAssessmentSection modelObject, DikeAssessmentSectionEntity entity)
{
if (modelObject == null)
{
throw new ArgumentNullException("modelObject");
}
if (entity == null)
{
throw new ArgumentNullException("entity");
}
entity.DikeAssessmentSectionEntityId = modelObject.StorageId;
entity.Name = modelObject.Name;
entity.Norm = modelObject.FailureMechanismContribution.Norm;
}
}
}