Add Photosynthesis Type
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace LeafWeb.Web.ViewModels
|
||||
{
|
||||
public class SelectListViewModel
|
||||
{
|
||||
public SelectList ListItems { get; set; }
|
||||
public string Selected { get; set; }
|
||||
|
||||
public SelectListItem SelectedItem
|
||||
{
|
||||
get { return ListItems.FirstOrDefault(li => li.Value == Selected); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user