Add materials converting from DTOs
This commit is contained in:
34
DataAccess/DTOs/Converters/Point2DFromDTOConvertStrategy.cs
Normal file
34
DataAccess/DTOs/Converters/Point2DFromDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class Point2DFromDTOConvertStrategy : ConvertStrategy<Point2D, Point2DDTO>
|
||||
{
|
||||
private IUpdateStrategy<IPoint2D> updateStrategy;
|
||||
|
||||
public Point2DFromDTOConvertStrategy(IUpdateStrategy<IPoint2D> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public Point2DFromDTOConvertStrategy() : this (new Point2DUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override Point2D GetNewItem(Point2DDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Point 2D converting is started");
|
||||
Point2D newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Point 2D converting has been finished");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user