Add LeafOutputViewModel and test
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
|
||||
namespace LeafWeb.Web.ViewModels.LeafOutput
|
||||
{
|
||||
public class LeafOutputViewModel
|
||||
{
|
||||
private static readonly IMapper Mapper;
|
||||
|
||||
public int LeafInputFileId { get; set; }
|
||||
public string LeafInputFilename { get; set; }
|
||||
public string CurrentStatus { get; set; }
|
||||
public string[] LeafOutputFilenames { get; set; }
|
||||
public string LeafInputIdentifier { get; set; }
|
||||
public string LeafInputSiteId { get; set; }
|
||||
public string LeafInputPhotosynthesisType { get; set; }
|
||||
|
||||
static LeafOutputViewModel()
|
||||
{
|
||||
var config =
|
||||
new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<Core.Entities.LeafInputFile, LeafOutputViewModel>()
|
||||
.ForMember(dest => dest.LeafInputFileId, opt => opt.MapFrom(src => src.Id))
|
||||
.ForMember(dest => dest.LeafInputFilename, opt => opt.MapFrom(src => src.Filename))
|
||||
.ForMember(dest => dest.LeafOutputFilenames,
|
||||
opt => opt.ResolveUsing(file => file.LeafOutputFiles?.Select(o => o.Filename).ToArray() ?? new string[] {}))
|
||||
.ForMember(dest => dest.LeafInputIdentifier, opt => opt.MapFrom(src => src.LeafInput.Identifier))
|
||||
.ForMember(dest => dest.LeafInputSiteId, opt => opt.MapFrom(src => src.LeafInput.SiteId))
|
||||
.ForMember(dest => dest.LeafInputPhotosynthesisType, opt => opt.MapFrom(src => src.LeafInput.PhotosynthesisType.Name));
|
||||
});
|
||||
Mapper = config.CreateMapper();
|
||||
}
|
||||
|
||||
public LeafOutputViewModel(Core.Entities.LeafInputFile leafInput)
|
||||
{
|
||||
Mapper.Map(leafInput, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user