Update automapper

This commit is contained in:
2016-09-24 00:06:34 -04:00
parent f473c64540
commit 6789c1b3b5
32 changed files with 254 additions and 206 deletions
+8 -6
View File
@@ -1,11 +1,10 @@
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using Heroic.AutoMapper;
using InventoryTraker.Web.Core;
namespace InventoryTraker.Web.Models
{
public class ProfileForm : IMapFrom<User>, IHaveCustomMappings
public class ProfileForm
{
[Required, Display(Name = "Full Name", Prompt = "Full Name (ex: John Doe)...")]
public string FullName { get; set; }
@@ -13,11 +12,14 @@ namespace InventoryTraker.Web.Models
[Required, DataType(DataType.EmailAddress), Display(Prompt = "your@email.com...")]
public string EmailAddress { get; set; }
public void CreateMappings(IMapperConfiguration configuration)
public class AutoMapperProfile : Profile
{
configuration.CreateMap<User, ProfileForm>()
.ForMember(d => d.FullName, opt => opt.MapFrom(s => s.UserName))
.ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.Email));
public AutoMapperProfile()
{
CreateMap<User, ProfileForm>()
.ForMember(d => d.FullName, opt => opt.MapFrom(s => s.UserName))
.ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.Email));
}
}
}
}