Leaf Input Details
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.DAL;
|
||||
using LeafWeb.Core.Entities;
|
||||
|
||||
namespace LeafWeb.WebCms.Models
|
||||
{
|
||||
@@ -36,18 +37,20 @@ namespace LeafWeb.WebCms.Models
|
||||
|
||||
static LeafInputCreate()
|
||||
{
|
||||
Mapper.CreateMap<LeafInputCreate, Core.Entities.LeafInput>()
|
||||
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();
|
||||
PhotosynthesisType = new SelectListViewModel();
|
||||
}
|
||||
|
||||
public Core.Entities.LeafInput GetLeafInput(DataService db)
|
||||
public LeafInput GetLeafInput(DataService db)
|
||||
{
|
||||
var leafInput = new Core.Entities.LeafInput();
|
||||
var leafInput = new LeafInput();
|
||||
Mapper.Map(this, leafInput);
|
||||
|
||||
leafInput.PhotosynthesisType = db.GetPhotosynthesisType(PhotosynthesisType.Selected);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.Entities;
|
||||
|
||||
namespace LeafWeb.WebCms.Models
|
||||
{
|
||||
public class LeafInputDetails
|
||||
{
|
||||
[Display(Name = "Name")]
|
||||
[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)]
|
||||
[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 = "Identifier")]
|
||||
[Required(ErrorMessage = "A unique identifier is required")]
|
||||
public string Identifier { get; set; }
|
||||
|
||||
[Display(Name = "Site Id")]
|
||||
[Required(ErrorMessage = "The site's name is required")]
|
||||
public string SiteId { get; set; }
|
||||
|
||||
[Display(Name = "Photosyn. Pathway")]
|
||||
[Required(ErrorMessage = "A Photosynthetic pathway must be chosen")]
|
||||
public string PhotosynthesisType { get; set; }
|
||||
|
||||
[DataType(DataType.Date)]
|
||||
[Required]
|
||||
public DateTime Added { get; set; }
|
||||
|
||||
[UIHint("Status")]
|
||||
public string CurrentStatus { get; set; }
|
||||
|
||||
[UIHint("LeafInputStatusViewModels")]
|
||||
public List<LeafInputStatusViewModel> StatusHistory { get; set; }
|
||||
|
||||
static LeafInputDetails()
|
||||
{
|
||||
Mapper.CreateMap<LeafInputStatusType, string>().ConvertUsing(st => st.ToString());
|
||||
Mapper.CreateMap<LeafInputStatusType, LeafInputStatus>().ConvertUsing(st => new LeafInputStatus());
|
||||
Mapper.CreateMap<LeafInputStatus, LeafInputStatusViewModel>();
|
||||
Mapper.CreateMap<LeafInput, LeafInputDetails>();
|
||||
}
|
||||
|
||||
public LeafInputDetails(LeafInput leafInput)
|
||||
{
|
||||
Mapper.Map(leafInput, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.Entities;
|
||||
|
||||
namespace LeafWeb.WebCms.Models
|
||||
{
|
||||
public class LeafInputStatusViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[UIHint("Status")]
|
||||
public string Status { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Details { get; set; }
|
||||
public DateTime DateTime { get; set; }
|
||||
|
||||
static LeafInputStatusViewModel()
|
||||
{
|
||||
Mapper.CreateMap<LeafInputStatus, LeafInputStatusViewModel>()
|
||||
.ForMember(dest => dest.Status, opt => opt.MapFrom(li => li.Status.ToString()));
|
||||
}
|
||||
|
||||
public LeafInputStatusViewModel() { }
|
||||
|
||||
public LeafInputStatusViewModel(LeafInputStatus status)
|
||||
{
|
||||
Mapper.Map(status, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user