Add Photosynthesis Type

This commit is contained in:
2016-02-09 13:47:11 -05:00
parent 15d911c86b
commit d101c2294f
14 changed files with 133 additions and 29 deletions
@@ -7,10 +7,16 @@ namespace LeafWeb.Web.ViewModels.LeafInput
{
private static readonly IMapper Mapper;
[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 ConfirmViewModel()
+10 -2
View File
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using LeafWeb.Core.DAL;
namespace LeafWeb.Web.ViewModels.LeafInput
{
@@ -31,21 +32,28 @@ namespace LeafWeb.Web.ViewModels.LeafInput
[Required(ErrorMessage = "The site's name is required")]
public string SiteId { get; set; }
[Display(Name = "Photosynthetic Pathways")]
[Required(ErrorMessage = "A photosynthesis pathway must be chosen")]
public SelectListViewModel PhotosynthesisType { get; set; }
static CreateViewModel()
{
var config =
new MapperConfiguration(cfg =>
{
cfg.CreateMap<CreateViewModel, Core.Models.LeafInput>();
cfg.CreateMap<CreateViewModel, Core.Models.LeafInput>()
.ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
});
Mapper = config.CreateMapper();
}
public Core.Models.LeafInput GetFileInput()
public Core.Models.LeafInput GetFileInput(DataService db)
{
var leafInput = new Core.Models.LeafInput();
Mapper.Map(this, leafInput);
leafInput.PhotosynthesisType = db.GetPhotosynthesisType(PhotosynthesisType.Selected);
return leafInput;
}
}