55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
using System.Linq;
|
|
using AutoMapper;
|
|
using LeafWeb.Core.Entities;
|
|
|
|
namespace LeafWeb.WebCms.Models
|
|
{
|
|
public class ResultStatusViewModel
|
|
{
|
|
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 ResultStatusViewModel()
|
|
{
|
|
Mapper.CreateMap<LeafInput, ResultStatusViewModel>()
|
|
.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.LeafOutputFilenames,
|
|
// opt => opt.ResolveUsing(
|
|
// src =>
|
|
// src.OutputFiles?
|
|
// .Select(o => o.Filename)
|
|
// .ToArray()
|
|
// ?? new string[] {}))
|
|
//.ForMember(dest => dest.HasLeafChartOutputFile,
|
|
// opt => opt.ResolveUsing(
|
|
// file => file.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 ResultStatusViewModel(LeafInput leafInput)
|
|
{
|
|
Mapper.Map(leafInput, this);
|
|
}
|
|
}
|
|
} |