Add materials converting from DTOs

This commit is contained in:
Evgeny Redikultsev
2024-10-27 21:29:50 +05:00
parent b0c24126da
commit 223e69263f
71 changed files with 1398 additions and 253 deletions

View File

@@ -0,0 +1,35 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ElasticMaterialFromDTOConvertStrategy : ConvertStrategy<ElasticMaterial, ElasticMaterialDTO>
{
private readonly IUpdateStrategy<IElasticMaterial> updateStrategy;
public ElasticMaterialFromDTOConvertStrategy(IUpdateStrategy<IElasticMaterial> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public ElasticMaterialFromDTOConvertStrategy() : this (new ElasticUpdateStrategy())
{
}
public override ElasticMaterial GetNewItem(ElasticMaterialDTO source)
{
TraceLogger?.AddMessage("Elastic material converting is started", TraceLogStatuses.Service);
ElasticMaterial newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage("Elastic material converting has been finished succesfully", TraceLogStatuses.Service);
return newItem;
}
}
}