Automap viewmodels for details display
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Utility;
|
||||
using LeafWeb.WebCms.Models;
|
||||
|
||||
namespace LeafWeb.WebCms.App_Start
|
||||
{
|
||||
public static class AutoMapperConfig
|
||||
{
|
||||
public static void RegisterMappings()
|
||||
{
|
||||
Mapper.CreateMap<LeafInputCreate, LeafInput>()
|
||||
.ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
||||
Mapper.CreateMap<LeafInput, LeafInputCreate>()
|
||||
.ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
||||
|
||||
// LeafInputDetails
|
||||
Mapper.CreateMap<LeafInputFile, string>().ConvertUsing(file => file?.Contents.GetString());
|
||||
Mapper.CreateMap<LeafOutputFile, string>().ConvertUsing(file => file?.FileContents.Contents.GetString());
|
||||
Mapper.CreateMap<LeafInputStatusType, string>().ConvertUsing(st => st.ToString());
|
||||
Mapper.CreateMap<LeafInputStatusType, LeafInputStatus>().ConvertUsing(st => new LeafInputStatus());
|
||||
Mapper.CreateMap<LeafInput, LeafInputDetails>()
|
||||
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
|
||||
.ForMember(dest => dest.HasLeafChart,
|
||||
opt => opt.ResolveUsing(src => src.OutputFiles.Any(o => o.IsLeafChartFile)));
|
||||
|
||||
// LeafInputData
|
||||
Mapper.CreateMap<LeafInputData, LeafInputDataViewModel>();
|
||||
|
||||
// LeafInputDataCurveViewModel
|
||||
Mapper.CreateMap<LeafInputDataCurve, LeafInputDataCurveViewModel>();
|
||||
|
||||
// LeafInputDataSite
|
||||
Mapper.CreateMap<LeafInputDataSite, LeafInputDataSiteViewModel>();
|
||||
|
||||
// LeafInputStatus
|
||||
Mapper.CreateMap<LeafInputStatus, LeafInputStatusViewModel>()
|
||||
.ForMember(dest => dest.Status, opt => opt.MapFrom(li => li.Status.ToString()));
|
||||
|
||||
//AutoMapper.AutoMapperMappingException {"Missing type map configuration or unsupported mapping.
|
||||
//
|
||||
//Mapping types:
|
||||
//HashSet`1 -> LeafInputData
|
||||
//System.Collections.Generic.HashSet`1[[LeafWeb.Core.Entities.LeafInputDataCurve, Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> LeafWeb.Core.Entities.LeafInputData
|
||||
//
|
||||
//Destination path:
|
||||
//LeafInputDetails.LeafInputData.LeafInputData.LeafInputData0[0]
|
||||
//
|
||||
//Source value:
|
||||
//System.Collections.Generic.HashSet`1[LeafWeb.Core.Entities.LeafInputDataCurve]"}
|
||||
Mapper.CreateMap<ICollection<LeafInputDataCurve>, LeafInputData>()
|
||||
.ForAllMembers(opt => opt.Ignore());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,10 @@ namespace LeafWeb.WebCms.App_Start
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
DataService.RegisterInitializer();
|
||||
HangfireBootstrapper.Instance.Start();
|
||||
BackloadBundles.RegisterBundles(BundleTable.Bundles);
|
||||
AutoMapperConfig.RegisterMappings();
|
||||
|
||||
HangfireBootstrapper.Instance.Start();
|
||||
BackloadBundles.RegisterBundles(BundleTable.Bundles);
|
||||
|
||||
// route for downloading results, see also URL rewrite rules in web.config
|
||||
RouteTable.Routes.MapRoute(
|
||||
|
||||
Reference in New Issue
Block a user