using System.Linq; using AutoMapper; using LeafWeb.Core.Entities; using LeafWeb.Core.Utility; namespace LeafWeb.Core.Remote { public class PiscalLeafInput { public int LeafInputId { get; set; } public string PhotosyntheticType { get; set; } public string PiscalDirectoryName { get; set; } public bool SuppressStorageCopy { get; set; } public PiscalLeafInputFile[] InputFiles { get; set; } public string NotifyCompleteUrl { get; set; } static PiscalLeafInput() { Mapper.CreateMap() .ForMember(dest => dest.PiscalDirectoryName, 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())); } public PiscalLeafInput() { } public PiscalLeafInput(LeafInput leafInput) { Mapper.Map(leafInput, this); } } }