44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using System.Linq;
|
|
using AutoMapper;
|
|
|
|
namespace LeafWeb.Web.ViewModels.ResultsAdmin
|
|
{
|
|
public class LeafInputViewModel
|
|
{
|
|
public int LeafInputId { get; set; }
|
|
public string LeafInputName { get; set; }
|
|
public string LeafInputIdentifier { get; set; }
|
|
public string LeafInputSiteId { get; set; }
|
|
public string LeafInputPhotosynthesisType { get; set; }
|
|
public bool HasLeafChart { get; set; }
|
|
public string CurrentStatus { get; set; }
|
|
//public string[] ErrorMessages { get; set; }
|
|
//public string[] LeafOutputFilenames { get; set; }
|
|
//public bool HasLeafChartOutputFile { get; set; }
|
|
|
|
static LeafInputViewModel()
|
|
{
|
|
Mapper.CreateMap<Core.Entities.LeafInput, LeafInputViewModel>()
|
|
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
|
|
.ForMember(dest => dest.HasLeafChart, opt => opt.ResolveUsing(src => src.OutputFiles.Any(o => o.IsLeafChartFile)))
|
|
.ForMember(dest => dest.LeafInputName, opt => opt.MapFrom(src => src.Name))
|
|
.ForMember(dest => dest.LeafInputIdentifier, opt => opt.MapFrom(src => src.Identifier))
|
|
.ForMember(dest => dest.LeafInputSiteId, opt => opt.MapFrom(src => src.SiteId))
|
|
.ForMember(dest => dest.LeafInputPhotosynthesisType, opt => opt.MapFrom(src => src.PhotosynthesisType.Name))
|
|
//.ForMember(dest => dest.ErrorMessages,
|
|
// opt => opt.ResolveUsing(
|
|
// src =>
|
|
// src.StatusHistory?
|
|
// .Where(sh => sh.Status == LeafInputStatusType.Exception)
|
|
// .Select(sh => sh.Description)
|
|
// .ToArray()
|
|
// ?? new string[] {}))
|
|
;
|
|
}
|
|
|
|
public LeafInputViewModel(Core.Entities.LeafInput leafInput)
|
|
{
|
|
Mapper.Map(leafInput, this);
|
|
}
|
|
}
|
|
} |