Add Safety FactorConverter

This commit is contained in:
Evgeny Redikultsev
2024-10-06 17:53:49 +05:00
parent 58b6e0eb8b
commit 018a989ba6
21 changed files with 387 additions and 86 deletions

View File

@@ -1,5 +1,6 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using System;
@@ -12,13 +13,30 @@ namespace DataAccess.DTOs.Converters
{
public class ConcreteLibMaterialToDTOConvertStrategy : IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>
{
private IUpdateStrategy<IConcreteLibMaterial> updateStrategy = new ConcreteLibUpdateStrategy();
private IUpdateStrategy<ILibMaterial> libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy();
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ConcreteLibMaterialDTO Convert(IConcreteLibMaterial source)
{
Check();
ConcreteLibMaterialDTO newItem = new()
{
Id = source.Id
};
try
{
updateStrategy.Update(newItem, source);
libMaterialUpdateStrategy.Update(newItem, source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
return newItem;
}
private void Check()