Submit all LeafInputFiles together
This commit is contained in:
@@ -1,18 +1,48 @@
|
||||
using AutoMapper;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.Core.Remote
|
||||
{
|
||||
public class PiscalLeafInput
|
||||
{
|
||||
private static readonly IMapper Mapper;
|
||||
public int LeafInputId { get; set; }
|
||||
public string PhotosyntheticType { get; set; }
|
||||
public string DirectoryName { get; set; }
|
||||
public PiscalLeafInputFile[] InputFiles { get; set; }
|
||||
|
||||
static PiscalLeafInput()
|
||||
{
|
||||
var config =
|
||||
new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<LeafInput, PiscalLeafInput>()
|
||||
.ForMember(dest => dest.DirectoryName,
|
||||
opt => opt.MapFrom(src => PiscalUtility.GetPiscalDirectoryName(src)))
|
||||
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
|
||||
.ForMember(dest => dest.InputFiles, opt => opt.MapFrom(src => src.InputFiles.Select(f => new PiscalLeafInputFile(f)).ToArray()))
|
||||
.ForMember(
|
||||
dest => dest.PhotosyntheticType,
|
||||
opt => opt.MapFrom(src => src.PhotosynthesisType.Id.WhitespaceToUnderscore()));
|
||||
});
|
||||
Mapper = config.CreateMapper();
|
||||
}
|
||||
|
||||
public PiscalLeafInput() { }
|
||||
|
||||
public PiscalLeafInput(LeafInput leafInput)
|
||||
{
|
||||
Mapper.Map(leafInput, this);
|
||||
}
|
||||
}
|
||||
|
||||
public class PiscalLeafInputFile
|
||||
{
|
||||
private static readonly IMapper Mapper;
|
||||
|
||||
public int LeafInputId { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public byte[] Contents { get; set; }
|
||||
public string DirectoryName { get; set; }
|
||||
public string PhotosyntheticType { get; set; }
|
||||
|
||||
static PiscalLeafInputFile()
|
||||
{
|
||||
@@ -20,14 +50,8 @@ namespace LeafWeb.Core.Remote
|
||||
new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<LeafInputFile, PiscalLeafInputFile>()
|
||||
.ForMember(dest => dest.DirectoryName,
|
||||
opt => opt.MapFrom(src => PiscalUtility.GetPiscalDirectoryName(src)))
|
||||
.ForMember(dest => dest.Filename, opt =>
|
||||
opt.MapFrom(src => src.Filename.WhitespaceToUnderscore().FilterValidFilename()))
|
||||
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
|
||||
.ForMember(
|
||||
dest => dest.PhotosyntheticType,
|
||||
opt => opt.MapFrom(src => src.LeafInput.PhotosynthesisType.Id.WhitespaceToUnderscore()));
|
||||
.ForMember(dest => dest.Filename, opt =>
|
||||
opt.MapFrom(src => src.Filename.WhitespaceToUnderscore().FilterValidFilename()));
|
||||
});
|
||||
Mapper = config.CreateMapper();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user