Serialize converters were added
This commit is contained in:
27
DataAccess/DTOs/FileVersionDTO.cs
Normal file
27
DataAccess/DTOs/FileVersionDTO.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
[JsonObject(IsReference = true)]
|
||||
public class FileVersionDTO : IFileVersion
|
||||
{
|
||||
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("VersionNumber")]
|
||||
public int VersionNumber { get; set; }
|
||||
[JsonProperty("SubVersionNumber")]
|
||||
public int SubVersionNumber { get; set; }
|
||||
public FileVersionDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
DataAccess/DTOs/FileVersionDTOConvertStrategy.cs
Normal file
41
DataAccess/DTOs/FileVersionDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FileVersionDTOConvertStrategy : IConvertStrategy<FileVersion, FileVersionDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public FileVersionDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
public FileVersionDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FileVersionDTO ConvertTo(FileVersion source)
|
||||
{
|
||||
FileVersionDTO fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
|
||||
public FileVersion ConvertFrom(FileVersionDTO source)
|
||||
{
|
||||
FileVersion fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
35
DataAccess/DTOs/ProjectDTO.cs
Normal file
35
DataAccess/DTOs/ProjectDTO.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ProjectDTO : IProject
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonIgnore]
|
||||
public string FullFileName { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool IsNewFile { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool IsActual { get; set; }
|
||||
|
||||
[JsonProperty("VisualAnalyses")]
|
||||
public List<IVisualAnalysis> VisualAnalyses { get; private set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string FileName { get; set; }
|
||||
|
||||
public ProjectDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user