Files
InventoryTracker/InventoryTraker.Web/Models/ProfileForm.cs
T
2016-08-08 14:47:35 -04:00

23 lines
746 B
C#

using System.ComponentModel.DataAnnotations;
using AutoMapper;
using Heroic.AutoMapper;
using InventoryTraker.Web.Core;
namespace InventoryTraker.Web.Models
{
public class ProfileForm : IMapFrom<User>, IHaveCustomMappings
{
[Required, Display(Name = "Full Name", Prompt = "Full Name (ex: John Doe)...")]
public string FullName { get; set; }
[Required, DataType(DataType.EmailAddress), Display(Prompt = "your@email.com...")]
public string EmailAddress { get; set; }
public void CreateMappings(IMapperConfiguration configuration)
{
configuration.CreateMap<User, ProfileForm>()
.ForMember(d => d.FullName, opt => opt.MapFrom(s => s.UserName))
.ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.Email));
}
}
}