Leaf Input and Submit

This commit is contained in:
2016-12-06 11:53:30 -05:00
parent a3b8b7a881
commit 6fd7e46f5d
74 changed files with 56144 additions and 1291 deletions
-39
View File
@@ -1,39 +0,0 @@
using System.ComponentModel.DataAnnotations;
using AutoMapper;
namespace LeafWeb.WebCms.Models
{
public class LeafInputConfirm
{
[Display(Name = "Your name")]
public string Name { get; set; }
[Display(Name = "Your email")]
public string Email { get; set; }
[Display(Name = "Data identifier")]
public string Identifier { get; set; }
[Display(Name = "Site Id")]
public string SiteId { get; set; }
[Display(Name = "Photosynthetic Pathway")]
public SelectListViewModel PhotosynthesisType { get; set; }
public string[] Files { get; set; }
static LeafInputConfirm()
{
Mapper.CreateMap<LeafInputCreate, LeafInputConfirm>();
}
//public LeafInputConfirm(LeafInputCreate leafInputCreate, string[] files)
//{
// Mapper.Map(leafInputCreate, this);
// Files = files;
//}
//public LeafInputConfirm(IPublishedContent content, CultureInfo culture) : base(content, culture)
//{
//}
//public LeafInputConfirm(IPublishedContent content) : base(content)
//{
//}
}
}
+20 -18
View File
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using LeafWeb.Core.DAL;
namespace LeafWeb.WebCms.Models
{
@@ -10,24 +11,24 @@ namespace LeafWeb.WebCms.Models
[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Please provide your full name")]
public string Name { get; set; }
//[Display(Name = "Your email address")]
//[Required(ErrorMessage = "An email address is required")]
//[DataType(DataType.EmailAddress)]
//[RegularExpression(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}", ErrorMessage = "Must be an email address")]
//public string Email { get; set; }
[Display(Name = "Your email address")]
[Required(ErrorMessage = "An email address is required")]
[DataType(DataType.EmailAddress)]
[RegularExpression(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}", ErrorMessage = "Must be an email address")]
public string Email { get; set; }
//[Display(Name = "Confirm email address")]
//[Required(ErrorMessage = "Enter email exactly as above")]
//[Compare("Email")]
//public string EmailConfirm { get; set; }
[Display(Name = "Confirm email address")]
[Required(ErrorMessage = "Enter email exactly as above")]
[Compare("Email")]
public string EmailConfirm { get; set; }
//[Display(Name = "A unique identifier for this data")]
//[Required(ErrorMessage = "A unique identifier is required")]
//public string Identifier { get; set; }
[Display(Name = "A unique identifier for this data")]
[Required(ErrorMessage = "A unique identifier is required")]
public string Identifier { get; set; }
//[Display(Name = "The site's name/Fluxnet ID, if known")]
//[Required(ErrorMessage = "The site's name is required")]
//public string SiteId { get; set; }
[Display(Name = "The site's name/Fluxnet ID, if known")]
[Required(ErrorMessage = "The site's name is required")]
public string SiteId { get; set; }
[Display(Name = "Photosynthetic Pathways")]
[Required(ErrorMessage = "A Photosynthetic pathway must be chosen")]
@@ -35,7 +36,7 @@ namespace LeafWeb.WebCms.Models
static LeafInputCreate()
{
Mapper.CreateMap<LeafInputCreate, LeafWeb.Core.Entities.LeafInput>()
Mapper.CreateMap<LeafInputCreate, Core.Entities.LeafInput>()
.ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
}
@@ -44,11 +45,12 @@ namespace LeafWeb.WebCms.Models
//PhotosynthesisType = new SelectListViewModel();
}
public LeafWeb.Core.Entities.LeafInput GetFileInput()
public Core.Entities.LeafInput GetLeafInput(DataService db)
{
var leafInput = new LeafWeb.Core.Entities.LeafInput();
var leafInput = new Core.Entities.LeafInput();
Mapper.Map(this, leafInput);
leafInput.PhotosynthesisType = db.GetPhotosynthesisType(PhotosynthesisType.Selected);
return leafInput;
}
}
+55
View File
@@ -0,0 +1,55 @@
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);
}
}
}