Add Safety FactorConverter
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,13 +14,18 @@ namespace DataAccess.DTOs.Converters
|
||||
public class HeadMaterialToDTOConvertStrategy : IConvertStrategy<HeadMaterialDTO, IHeadMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IHeadMaterial> updateStrategy;
|
||||
private IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy;
|
||||
|
||||
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy)
|
||||
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy,
|
||||
IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public HeadMaterialToDTOConvertStrategy() : this (new HeadMaterialUpdateStrategy())
|
||||
public HeadMaterialToDTOConvertStrategy() : this (
|
||||
new HeadMaterialUpdateStrategy(),
|
||||
new HelperMaterialToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
@@ -29,8 +35,20 @@ namespace DataAccess.DTOs.Converters
|
||||
|
||||
public HeadMaterialDTO Convert(IHeadMaterial source)
|
||||
{
|
||||
HeadMaterialDTO newItem = new() { Id = source.Id};
|
||||
TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}");
|
||||
HeadMaterialDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
var convertLogic = new DictionaryConvertStrategy<IHelperMaterial, IHelperMaterial>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user