Add ResultsAdmin, delete action

This commit is contained in:
2016-05-20 22:47:28 -04:00
parent cff6a0d96f
commit 790e2494e3
6 changed files with 182 additions and 1 deletions
@@ -0,0 +1,51 @@
using System.Linq;
using AutoMapper;
namespace LeafWeb.Web.ViewModels.ResultsAdmin
{
public class LeafInputViewModel
{
private static readonly IMapper Mapper;
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()
{
var config =
new MapperConfiguration(cfg =>
{
cfg.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[] {}))
;
});
Mapper = config.CreateMapper();
}
public LeafInputViewModel(Core.Entities.LeafInput leafInput)
{
Mapper.Map(leafInput, this);
}
}
}