Add LeafOutputViewModel and test

This commit is contained in:
2016-03-02 13:02:27 -05:00
parent 659d9b811e
commit c80d048c39
5 changed files with 106 additions and 0 deletions
@@ -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);
}
}
}
+12
View File
@@ -0,0 +1,12 @@
@model LeafWeb.Web.ViewModels.LeafOutput.LeafOutputViewModel
@{
ViewBag.Title = "Users";
var grid = new WebGrid(Model, rowsPerPage: 45);
}
<h1>EDO Results</h1>
<div class="row">
</div>
+2
View File
@@ -940,6 +940,7 @@
<Compile Include="Utility\Validation.cs" />
<Compile Include="ViewModels\LeafInput\ConfirmViewModel.cs" />
<Compile Include="ViewModels\LeafInput\CreateViewModel.cs" />
<Compile Include="ViewModels\LeafOutput\LeafOutputViewModel.cs" />
<Compile Include="ViewModels\SelectListViewModel.cs" />
</ItemGroup>
<ItemGroup>
@@ -977,6 +978,7 @@
<Content Include="Views\Shared\_StatusMessage.cshtml" />
<Content Include="Views\Shared\_ValidationField.cshtml" />
<Content Include="Views\Shared\EditorTemplates\SelectListViewModel.cshtml" />
<Content Include="Views\LeafOutput\Index.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>