Add steel material saving
This commit is contained in:
@@ -9,33 +9,20 @@ namespace DataAccess.DTOs
|
||||
public class HelperMaterialFromDTOConvertStrategy : ConvertStrategy<IHelperMaterial, IHelperMaterial>
|
||||
{
|
||||
const string MaterialIs = "Material type is: ";
|
||||
private IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> concreteConvertStrategy;
|
||||
private IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> reinforcementConvertStrategy;
|
||||
private IConvertStrategy<ElasticMaterial, ElasticMaterialDTO> elasticConvertStrategy;
|
||||
private IConvertStrategy<FRMaterial, FRMaterialDTO> frConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic());
|
||||
private IHelperMaterialFromDTOStrategyContainer strategyContainer;
|
||||
|
||||
public HelperMaterialFromDTOConvertStrategy() : this(
|
||||
new ConcreteLibMaterialFromDTOConvertStrategy(),
|
||||
new ReinforcementLibMaterialFromDTOConvertStrategy(),
|
||||
new ElasticMaterialFromDTOConvertStrategy(),
|
||||
new FRMaterialFromDTOConvertStrategy()
|
||||
)
|
||||
|
||||
private IHelperMaterialFromDTOStrategyContainer StrategyContainer => strategyContainer ??= new HelperMaterialFromDTOStrategyContainer();
|
||||
public HelperMaterialFromDTOConvertStrategy(IHelperMaterialFromDTOStrategyContainer strategyContainer)
|
||||
{
|
||||
this.strategyContainer = strategyContainer;
|
||||
}
|
||||
|
||||
public HelperMaterialFromDTOConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public HelperMaterialFromDTOConvertStrategy(
|
||||
IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> concreteConvertStrategy,
|
||||
IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> reinforcementConvertStrategy,
|
||||
IConvertStrategy<ElasticMaterial, ElasticMaterialDTO> elasticConvertStrategy,
|
||||
IConvertStrategy<FRMaterial, FRMaterialDTO> frConvertStrategy)
|
||||
{
|
||||
this.concreteConvertStrategy = concreteConvertStrategy;
|
||||
this.reinforcementConvertStrategy = reinforcementConvertStrategy;
|
||||
this.elasticConvertStrategy = elasticConvertStrategy;
|
||||
this.frConvertStrategy = frConvertStrategy;
|
||||
}
|
||||
|
||||
public override IHelperMaterial GetNewItem(IHelperMaterial source)
|
||||
{
|
||||
@@ -55,6 +42,10 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
return GetElasticMaterial(elastic);
|
||||
}
|
||||
else if (source is SteelLibMaterialDTO steel)
|
||||
{
|
||||
return GetSteelMaterial(steel);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": helper material type";
|
||||
@@ -63,43 +54,58 @@ namespace DataAccess.DTOs
|
||||
}
|
||||
}
|
||||
|
||||
private IHelperMaterial GetSteelMaterial(SteelLibMaterialDTO source)
|
||||
{
|
||||
var strategy = StrategyContainer.SteelConvertStrategy;
|
||||
TraceLogger?.AddMessage(MaterialIs + "Elastic material", TraceLogStatuses.Service);
|
||||
strategy.ReferenceDictionary = ReferenceDictionary;
|
||||
strategy.TraceLogger = TraceLogger;
|
||||
var newItem = strategy.Convert(source);
|
||||
strategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetElasticMaterial(ElasticMaterialDTO source)
|
||||
{
|
||||
var strategy = StrategyContainer.ElasticConvertStrategy;
|
||||
TraceLogger?.AddMessage(MaterialIs + "Elastic material", TraceLogStatuses.Service);
|
||||
elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
elasticConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = elasticConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
strategy.ReferenceDictionary = ReferenceDictionary;
|
||||
strategy.TraceLogger = TraceLogger;
|
||||
var newItem = strategy.Convert(source);
|
||||
strategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetFRMaterial(FRMaterialDTO source)
|
||||
{
|
||||
var strategy = StrategyContainer.FrConvertStrategy;
|
||||
TraceLogger?.AddMessage(MaterialIs + "Fiber reinforcement material", TraceLogStatuses.Service);
|
||||
frConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
frConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = frConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
strategy.ReferenceDictionary = ReferenceDictionary;
|
||||
strategy.TraceLogger = TraceLogger;
|
||||
var newItem = strategy.Convert(source);
|
||||
StrategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetReinforcementMaterial(ReinforcementLibMaterialDTO source)
|
||||
{
|
||||
var strategy = StrategyContainer.ReinforcementConvertStrategy;
|
||||
TraceLogger?.AddMessage(MaterialIs + "Reinforcement library material", TraceLogStatuses.Service);
|
||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = reinforcementConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
strategy.ReferenceDictionary = ReferenceDictionary;
|
||||
strategy.TraceLogger = TraceLogger;
|
||||
var newItem = strategy.Convert(source);
|
||||
StrategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetConcreteMaterial(ConcreteLibMaterialDTO source)
|
||||
{
|
||||
var strategy = StrategyContainer.ConcreteConvertStrategy;
|
||||
TraceLogger?.AddMessage(MaterialIs + "Concrete library material", TraceLogStatuses.Service);
|
||||
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
concreteConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = concreteConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
strategy.ReferenceDictionary = ReferenceDictionary;
|
||||
strategy.TraceLogger = TraceLogger;
|
||||
var newItem = strategy.Convert(source);
|
||||
StrategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HelperMaterialFromDTOStrategyContainer : IHelperMaterialFromDTOStrategyContainer
|
||||
{
|
||||
private IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> concreteConvertStrategy;
|
||||
private IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> reinforcementConvertStrategy;
|
||||
private IConvertStrategy<ElasticMaterial, ElasticMaterialDTO> elasticConvertStrategy;
|
||||
private IConvertStrategy<FRMaterial, FRMaterialDTO> frConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy;
|
||||
private IConvertStrategy<SteelLibMaterial, SteelLibMaterialDTO> steelConvertStrategy;
|
||||
public IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> ConcreteConvertStrategy => concreteConvertStrategy ??= new ConcreteLibMaterialFromDTOConvertStrategy();
|
||||
public IConvertStrategy<ElasticMaterial, ElasticMaterialDTO> ElasticConvertStrategy => elasticConvertStrategy ??= new ElasticMaterialFromDTOConvertStrategy();
|
||||
public IConvertStrategy<FRMaterial, FRMaterialDTO> FrConvertStrategy => frConvertStrategy ??= new FRMaterialFromDTOConvertStrategy();
|
||||
public IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> ReinforcementConvertStrategy => reinforcementConvertStrategy ??= new ReinforcementLibMaterialFromDTOConvertStrategy();
|
||||
public IUpdateStrategy<IHelperMaterial> SafetyFactorUpdateStrategy => safetyFactorUpdateStrategy ??= new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic());
|
||||
public IConvertStrategy<SteelLibMaterial, SteelLibMaterialDTO> SteelConvertStrategy => steelConvertStrategy ??= new SteelLibMaterialFromDTOConvertStrategy();
|
||||
}
|
||||
}
|
||||
@@ -7,35 +7,20 @@ using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
|
||||
public class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
|
||||
{
|
||||
private LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
|
||||
private LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy;
|
||||
private IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy;
|
||||
private IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
|
||||
private IHelperMaterialToDTOStrategyContainer strategyContainer;
|
||||
private IHelperMaterialToDTOStrategyContainer StrategyContainer => strategyContainer ??= new HelperMaterialToDTOStrategyContainer();
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public HelperMaterialToDTOConvertStrategy(
|
||||
LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy,
|
||||
LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy,
|
||||
IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy,
|
||||
IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy)
|
||||
public HelperMaterialToDTOConvertStrategy(IHelperMaterialToDTOStrategyContainer strategyContainer)
|
||||
{
|
||||
this.concreteConvertStrategy = concreteConvertStrategy;
|
||||
this.reinforcementConvertStrategy = reinforcementConvertStrategy;
|
||||
this.elasticConvertStrategy = elasticConvertStrategy;
|
||||
this.frMaterialConvertStrategy = frMaterialConvertStrategy;
|
||||
this.strategyContainer = strategyContainer;
|
||||
}
|
||||
|
||||
public HelperMaterialToDTOConvertStrategy() : this (
|
||||
new ConcreteLibMaterialToDTOConvertStrategy(),
|
||||
new ReinforcementLibMaterialToDTOConvertStrategy(),
|
||||
new ElasticMaterialToDTOConvertStrategy(),
|
||||
new FRMaterialToDTOConvertStrategy()
|
||||
)
|
||||
public HelperMaterialToDTOConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -46,7 +31,7 @@ namespace DataAccess.DTOs
|
||||
try
|
||||
{
|
||||
IHelperMaterial helperMaterial = GetMaterial(source);
|
||||
safetyFactorUpdateStrategy.Update(helperMaterial, source);
|
||||
StrategyContainer.SafetyFactorUpdateStrategy.Update(helperMaterial, source);
|
||||
return helperMaterial;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -75,14 +60,28 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
return ProcessElastic(elasticMaterial);
|
||||
}
|
||||
else if (source is ISteelLibMaterial steelLibMaterial)
|
||||
{
|
||||
return ProcessSteel(steelLibMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
|
||||
}
|
||||
}
|
||||
|
||||
private IHelperMaterial ProcessSteel(ISteelLibMaterial steelLibMaterial)
|
||||
{
|
||||
var strategy = StrategyContainer.SteelConvertStrategy;
|
||||
strategy.ReferenceDictionary = ReferenceDictionary;
|
||||
strategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<SteelLibMaterialDTO, ISteelLibMaterial>(this, strategy);
|
||||
return convertLogic.Convert(steelLibMaterial);
|
||||
}
|
||||
|
||||
private IHelperMaterial ProcessFRMaterial(IFRMaterial frMaterial)
|
||||
{
|
||||
var frMaterialConvertStrategy = StrategyContainer.FrMaterialConvertStrategy;
|
||||
frMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
frMaterialConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<FRMaterialDTO, IFRMaterial>(this, frMaterialConvertStrategy);
|
||||
@@ -91,6 +90,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private IHelperMaterial ProcessElastic(IElasticMaterial elasticMaterial)
|
||||
{
|
||||
var elasticConvertStrategy = StrategyContainer.ElasticConvertStrategy;
|
||||
elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
elasticConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ElasticMaterialDTO, IElasticMaterial>(this, elasticConvertStrategy);
|
||||
@@ -99,6 +99,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private IHelperMaterial ProcessReinforcement(IReinforcementLibMaterial reinforcementMaterial)
|
||||
{
|
||||
var reinforcementConvertStrategy = StrategyContainer.ReinforcementConvertStrategy;
|
||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial>(this, reinforcementConvertStrategy);
|
||||
@@ -107,6 +108,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private IHelperMaterial ProcessConcrete(IConcreteLibMaterial concreteLibMaterial)
|
||||
{
|
||||
var concreteConvertStrategy = StrategyContainer.ConcreteConvertStrategy;
|
||||
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
concreteConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>(this, concreteConvertStrategy);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HelperMaterialToDTOStrategyContainer : IHelperMaterialToDTOStrategyContainer
|
||||
{
|
||||
private LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
|
||||
private LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy;
|
||||
private LibMaterialToDTOConvertStrategy<SteelLibMaterialDTO, ISteelLibMaterial> steelConvertStrategy;
|
||||
private IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy;
|
||||
private IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
|
||||
public LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> ConcreteConvertStrategy => concreteConvertStrategy ??= new ConcreteLibMaterialToDTOConvertStrategy();
|
||||
public IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> ElasticConvertStrategy => elasticConvertStrategy ??= new ElasticMaterialToDTOConvertStrategy();
|
||||
public IConvertStrategy<FRMaterialDTO, IFRMaterial> FrMaterialConvertStrategy => frMaterialConvertStrategy ??= new FRMaterialToDTOConvertStrategy();
|
||||
public LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> ReinforcementConvertStrategy => reinforcementConvertStrategy ??= new ReinforcementLibMaterialToDTOConvertStrategy();
|
||||
public IUpdateStrategy<IHelperMaterial> SafetyFactorUpdateStrategy => safetyFactorUpdateStrategy ??= new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
|
||||
public LibMaterialToDTOConvertStrategy<SteelLibMaterialDTO, ISteelLibMaterial> SteelConvertStrategy => steelConvertStrategy ??= new SteelLibMaterialToDTOConvertStrategy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public interface IHelperMaterialFromDTOStrategyContainer
|
||||
{
|
||||
IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> ConcreteConvertStrategy { get; }
|
||||
IConvertStrategy<ElasticMaterial, ElasticMaterialDTO> ElasticConvertStrategy { get; }
|
||||
IConvertStrategy<FRMaterial, FRMaterialDTO> FrConvertStrategy { get; }
|
||||
IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> ReinforcementConvertStrategy { get; }
|
||||
IUpdateStrategy<IHelperMaterial> SafetyFactorUpdateStrategy { get; }
|
||||
IConvertStrategy<SteelLibMaterial, SteelLibMaterialDTO> SteelConvertStrategy { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public interface IHelperMaterialToDTOStrategyContainer
|
||||
{
|
||||
LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> ConcreteConvertStrategy { get; }
|
||||
IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> ElasticConvertStrategy { get; }
|
||||
IConvertStrategy<FRMaterialDTO, IFRMaterial> FrMaterialConvertStrategy { get; }
|
||||
LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> ReinforcementConvertStrategy { get; }
|
||||
IUpdateStrategy<IHelperMaterial> SafetyFactorUpdateStrategy { get; }
|
||||
LibMaterialToDTOConvertStrategy<SteelLibMaterialDTO, ISteelLibMaterial> SteelConvertStrategy { get; }
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
public override ReinforcementLibMaterialDTO GetMaterialDTO(IReinforcementLibMaterial source)
|
||||
{
|
||||
ReinforcementLibMaterialDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
ReinforcementLibMaterialDTO newItem = new(source.Id);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class SteelLibMaterialFromDTOConvertStrategy : ConvertStrategy<SteelLibMaterial, SteelLibMaterialDTO>
|
||||
{
|
||||
IUpdateStrategy<ISteelLibMaterial> updateStrategy;
|
||||
IUpdateStrategy<ISteelLibMaterial> UpdateStrategy => updateStrategy ??= new SteelLibMaterialUpdateStrategy();
|
||||
public override SteelLibMaterial GetNewItem(SteelLibMaterialDTO source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class SteelLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy<SteelLibMaterialDTO, ISteelLibMaterial>
|
||||
{
|
||||
private IUpdateStrategy<ISteelLibMaterial> updateStrategy;
|
||||
public override IUpdateStrategy<ISteelLibMaterial> UpdateStrategy => updateStrategy ??= new SteelLibMaterialUpdateStrategy();
|
||||
|
||||
public override SteelLibMaterialDTO GetMaterialDTO(ISteelLibMaterial source)
|
||||
{
|
||||
SteelLibMaterialDTO material = new(source.Id);
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,6 @@ using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
@@ -17,7 +12,9 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
const MaterialTypes materialType = MaterialTypes.Reinforcement;
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get; }
|
||||
|
||||
|
||||
[JsonProperty("MaterialEntityId")]
|
||||
public Guid MaterialEntityId
|
||||
{
|
||||
@@ -46,6 +43,10 @@ namespace DataAccess.DTOs
|
||||
[JsonIgnore]
|
||||
public List<IMaterialLogic> MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
|
||||
|
||||
public ReinforcementLibMaterialDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
|
||||
81
DataAccess/DTOs/DTOEntities/Materials/SteelLibMaterialDTO.cs
Normal file
81
DataAccess/DTOs/DTOEntities/Materials/SteelLibMaterialDTO.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class SteelLibMaterialDTO : ISteelLibMaterial
|
||||
{
|
||||
const MaterialTypes materialType = MaterialTypes.Steel;
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; }
|
||||
[JsonProperty("UlsFactor")]
|
||||
public double UlsFactor { get; set; } = 1.025;
|
||||
[JsonProperty("SlsFactor")]
|
||||
public double SlsFactor { get; set; } = 1.0;
|
||||
[JsonProperty("WorkConditionFactor")]
|
||||
public double WorkConditionFactor { get; set; } = 1.0;
|
||||
[JsonProperty("ThicknessFactor")]
|
||||
public double ThicknessFactor { get; set; } = 1.0;
|
||||
[JsonProperty("MaxPlasticStrainRatio")]
|
||||
public double MaxPlasticStrainRatio { get; set; } = 3.0;
|
||||
[JsonIgnore]
|
||||
public ILibMaterialEntity MaterialEntity { get; set; }
|
||||
[JsonProperty("SafetyFactors")]
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = [];
|
||||
[JsonProperty("MaterialEntityId")]
|
||||
public Guid MaterialEntityId
|
||||
{
|
||||
get => MaterialEntity.Id;
|
||||
set
|
||||
{
|
||||
MaterialEntity = ProgramSetting.MaterialRepository.Repository.Single(x => x.Id == value);
|
||||
}
|
||||
}
|
||||
[JsonProperty("MaterialLogicId")]
|
||||
public Guid MaterialLogicId
|
||||
{
|
||||
get => MaterialLogic.Id;
|
||||
set
|
||||
{
|
||||
MaterialLogic = MaterialLogics.Single(x => x.Id == value);
|
||||
}
|
||||
}
|
||||
[JsonIgnore]
|
||||
public IMaterialLogic MaterialLogic { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<IMaterialLogic> MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
|
||||
|
||||
|
||||
|
||||
public SteelLibMaterialDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,7 @@ namespace DataAccess.DTOs
|
||||
{ (typeof(List<IMaterialSafetyFactor>), "ListOfMaterialSafetyFactor") },
|
||||
{ (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") },
|
||||
{ (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") },
|
||||
{ (typeof(SteelLibMaterialDTO), "SteelLibMaterial") },
|
||||
};
|
||||
return newList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user