Leaf Input functional

This commit is contained in:
2016-02-03 13:39:50 -05:00
parent 54b9eacd09
commit 10f7a23d31
11 changed files with 299 additions and 45 deletions
+21 -1
View File
@@ -1,10 +1,12 @@
using System.ComponentModel.DataAnnotations;
using System.Web;
using AutoMapper;
namespace LeafWeb.Web.ViewModels.LeafInput
{
public class CreateViewModel
{
private static readonly IMapper Mapper;
[Display(Name = "Your name")]
[Required(ErrorMessage = "Name required")]
[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Please provide your full name")]
@@ -28,5 +30,23 @@ namespace LeafWeb.Web.ViewModels.LeafInput
[Display(Name = "The site's name/Fluxnet ID, if known")]
[Required(ErrorMessage = "The site's name is required")]
public string SiteId { get; set; }
static CreateViewModel()
{
var config =
new MapperConfiguration(cfg =>
{
cfg.CreateMap<CreateViewModel, Core.Models.LeafInput>();
});
Mapper = config.CreateMapper();
}
public Core.Models.LeafInput GetFileInput()
{
var leafInput = new Core.Models.LeafInput();
Mapper.Map(this, leafInput);
return leafInput;
}
}
}