48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
using StructureHelperCommon.Models;
|
|
using StructureHelperCommon.Models.WorkPlanes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DataAccess.DTOs.Converters
|
|
{
|
|
public class WorkPlanePropertyToDTOConvertStrategy : ConvertStrategy<WorkPlanePropertyDTO, IWorkPlaneProperty>
|
|
{
|
|
private IUpdateStrategy<IWorkPlaneProperty> updateStrategy;
|
|
public WorkPlanePropertyToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
|
IShiftTraceLogger traceLogger)
|
|
{
|
|
ReferenceDictionary = referenceDictionary;
|
|
TraceLogger = traceLogger;
|
|
}
|
|
public override WorkPlanePropertyDTO GetNewItem(IWorkPlaneProperty source)
|
|
{
|
|
InitializeStrategies();
|
|
try
|
|
{
|
|
GetNewItemBySource(source);
|
|
return NewItem;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
TraceErrorByEntity(this, ex.Message);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
private void GetNewItemBySource(IWorkPlaneProperty source)
|
|
{
|
|
NewItem = new(source.Id);
|
|
updateStrategy.Update(NewItem, source);
|
|
}
|
|
|
|
private void InitializeStrategies()
|
|
{
|
|
updateStrategy ??= new WorkPlanePropertyUpdateStrategy();
|
|
}
|
|
}
|
|
}
|