Automap viewmodels for details display
This commit is contained in:
@@ -35,40 +35,7 @@ namespace LeafWeb.WebCms.Models
|
||||
[Display(Name = "Range")]
|
||||
[RegularExpression(@"^([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "± longitude degrees")]
|
||||
public string lonr { get; set; }
|
||||
|
||||
static LeafDataQuery()
|
||||
{
|
||||
//Mapper.CreateMap<LeafInputCreate, LeafInput>()
|
||||
// .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
||||
//Mapper.CreateMap<LeafInput, LeafInputCreate>()
|
||||
// .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
||||
}
|
||||
|
||||
public LeafDataQuery()
|
||||
{
|
||||
//PhotosynthesisType = new SelectListViewModel();
|
||||
}
|
||||
|
||||
public NameValueCollection GetNameValueCollection(string prefix="")
|
||||
{
|
||||
var nvs = new NameValueCollection();
|
||||
|
||||
prefix =
|
||||
string.IsNullOrEmpty(prefix)
|
||||
? ""
|
||||
: prefix + ".";
|
||||
|
||||
foreach (var pi in typeof(LeafDataQuery).GetProperties())
|
||||
{
|
||||
var value = pi.GetValue(this, null);
|
||||
if (value == null)
|
||||
continue;
|
||||
nvs.Add(prefix + pi.Name, value?.ToString());
|
||||
}
|
||||
|
||||
return nvs;
|
||||
}
|
||||
|
||||
|
||||
public bool HasExtendedParameters =>
|
||||
!(
|
||||
string.IsNullOrEmpty(siteid)
|
||||
|
||||
@@ -40,14 +40,6 @@ namespace LeafWeb.WebCms.Models
|
||||
[EnforceTrue(ErrorMessage = "Terms of Service must be accepted to continue")]
|
||||
public bool TermsOfService { get; set; }
|
||||
|
||||
static LeafInputCreate()
|
||||
{
|
||||
Mapper.CreateMap<LeafInputCreate, LeafInput>()
|
||||
.ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
||||
Mapper.CreateMap<LeafInput, LeafInputCreate>()
|
||||
.ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
||||
}
|
||||
|
||||
public LeafInputCreate()
|
||||
{
|
||||
PhotosynthesisType = new SelectListViewModel();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.Entities;
|
||||
|
||||
namespace LeafWeb.WebCms.Models
|
||||
{
|
||||
public class LeafInputDataCurveViewModel
|
||||
{
|
||||
/// <summary>Sample CO2 concentration</summary>
|
||||
//[ParseInfo(17, units: "umol/mol")]
|
||||
public double? CO2S { get; set; }
|
||||
|
||||
public LeafInputDataCurveViewModel() {}
|
||||
|
||||
public LeafInputDataCurveViewModel(LeafInputDataCurve leafInputDataCurve)
|
||||
{
|
||||
Mapper.Map(leafInputDataCurve, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,72 +25,8 @@ namespace LeafWeb.WebCms.Models
|
||||
[DisplayFormat(DataFormatString = "{0} m")]
|
||||
public double? Elevation { get; set; }
|
||||
|
||||
/*
|
||||
/// <summary>the year when the A/Ci data is taken</summary>
|
||||
[DisplayFormat(DataFormatString = "{0} year")]
|
||||
public string SampleYear { get; set; }
|
||||
|
||||
|
||||
/// <summary>the day of year (since 1 Jan) when the A/Ci data is taken</summary>
|
||||
[ParseInfo(6, units: "day")]
|
||||
public int? SampleDayOfYear { get; set; }
|
||||
|
||||
/// <summary>the approximate start day (since 1 Jan) of growing season</summary>
|
||||
[ParseInfo(7, units: "day")]
|
||||
public int? GrowSeasonStart { get; set; }
|
||||
|
||||
/// <summary>the approximate end day (since 1 Jan) of growing season</summary>
|
||||
[ParseInfo(8, units: "day")]
|
||||
public int? GrowSeasonEnd { get; set; }
|
||||
|
||||
/// <summary>stand age since the last disturbance</summary>
|
||||
[ParseInfo(9, units: "year")]
|
||||
public double? StandAge { get; set; }
|
||||
|
||||
/// <summary>the height of the canopy</summary>
|
||||
[ParseInfo(10, units: "m")]
|
||||
public double? CanopyHeight { get; set; }
|
||||
|
||||
/// <summary>the leaf area index in the middle of growing season</summary>
|
||||
[ParseInfo(11, units: "m2/m2")]
|
||||
public double? LeafAreaIndex { get; set; }
|
||||
|
||||
/// <summary>the species of the leaf sample</summary>
|
||||
/// <remarks>don't leave blank between letters</remarks>
|
||||
[ParseInfo(12, units: "dimensionless")]
|
||||
public string SpeciesSampled { get; set; }
|
||||
|
||||
/// <summary>the average time interval between two consecutive A/Ci data points</summary>
|
||||
[ParseInfo(13, alternateTitle: "AveTimeResolution", units: "minutes")]
|
||||
public double? AverageTimeResolution { get; set; }
|
||||
|
||||
/// <summary>the height at which the leaf is located</summary>
|
||||
[ParseInfo(14, units: "m")]
|
||||
public double? SampleHeight { get; set; }
|
||||
|
||||
/// <summary>the age of the leaf</summary>
|
||||
[ParseInfo(15, units: "day")]
|
||||
public int? LeafAge { get; set; }
|
||||
|
||||
/// <summary>specific leaf area of the sample</summary>
|
||||
[ParseInfo(16, units: "cm2/g")]
|
||||
public double? SpecificLeafArea { get; set; }
|
||||
|
||||
/// <summary>dry leaf nitrogen content of the sample</summary>
|
||||
[ParseInfo(17, units: "%")]
|
||||
public double? LfNitrogenContent { get; set; }
|
||||
|
||||
/// <summary>dry leaf carbon content of the sample</summary>
|
||||
[ParseInfo(18, units: "%")]
|
||||
public double? LfCarbonContent { get; set; }
|
||||
|
||||
/// <summary>dry leaf phosphorus content of the sample</summary>
|
||||
[ParseInfo(19, units: "%")]
|
||||
public double? LfPhosphContent { get; set; }
|
||||
*/
|
||||
static LeafInputDataSiteViewModel()
|
||||
{
|
||||
Mapper.CreateMap<LeafInputDataSite, LeafInputDataSiteViewModel>();
|
||||
}
|
||||
|
||||
public LeafInputDataSiteViewModel() {}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.WebCms.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Descriptive information about the investigator,
|
||||
/// contact information, the site,the sample leaf and its general environmental condition
|
||||
/// </summary>
|
||||
public class LeafInputDataViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[ParseInfo(3, alternateTitle: "Site name in full", exampleValue: "Your site's identifier / name")]
|
||||
public string SiteName { get; set; }
|
||||
|
||||
public LeafInputDataSiteViewModel Site { get; set; }
|
||||
|
||||
public List<LeafInputDataCurveViewModel> Data { get; set; }
|
||||
|
||||
public LeafInputDataViewModel() {}
|
||||
|
||||
public LeafInputDataViewModel(LeafInputData data)
|
||||
{
|
||||
Mapper.Map(data, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace LeafWeb.WebCms.Models
|
||||
[Required(ErrorMessage = "Name required")]
|
||||
[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Please provide full name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
[Display(Name = "Email address")]
|
||||
[Required(ErrorMessage = "An email address is required")]
|
||||
[DataType(DataType.EmailAddress)]
|
||||
@@ -52,13 +52,6 @@ namespace LeafWeb.WebCms.Models
|
||||
[Display(Name = "Time In Progress")]
|
||||
public TimeSpan TimeInProgress { get; set; }
|
||||
|
||||
[UIHint("LeafInputDataSiteViewModels")]
|
||||
public List<LeafInputDataSiteViewModel> Sites { get; set; }
|
||||
|
||||
|
||||
[UIHint("LeafInputStatusViewModels")]
|
||||
public List<LeafInputStatusViewModel> StatusHistory { get; set; }
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public bool HasLeafChart { get; set; }
|
||||
|
||||
@@ -76,22 +69,12 @@ namespace LeafWeb.WebCms.Models
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public bool IsCancellable { get; set; }
|
||||
|
||||
[UIHint("LeafInputDataViewModels")]
|
||||
public List<LeafInputDataViewModel> LeafInputData { get; set; }
|
||||
|
||||
static 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<LeafInputStatus, LeafInputStatusViewModel>();
|
||||
Mapper.CreateMap<LeafInputDataSite, LeafInputDataSiteViewModel>();
|
||||
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)))
|
||||
.ForMember(dest => dest.Sites, opt =>
|
||||
opt.ResolveUsing(li => li.LeafInputData.Select(d => d.Site)));
|
||||
}
|
||||
[UIHint("LeafInputStatusViewModels")]
|
||||
public List<LeafInputStatusViewModel> StatusHistory { get; set; }
|
||||
|
||||
public LeafInputDetails(LeafInput leafInput)
|
||||
{
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace LeafWeb.WebCms.Models
|
||||
|
||||
static LeafInputStatusViewModel()
|
||||
{
|
||||
Mapper.CreateMap<LeafInputStatus, LeafInputStatusViewModel>()
|
||||
.ForMember(dest => dest.Status, opt => opt.MapFrom(li => li.Status.ToString()));
|
||||
}
|
||||
|
||||
public LeafInputStatusViewModel() { }
|
||||
|
||||
Reference in New Issue
Block a user