User profile editing and password

This commit is contained in:
2016-09-26 11:13:59 -04:00
parent 6789c1b3b5
commit 75b7c02979
54 changed files with 373 additions and 209 deletions
+24 -7
View File
@@ -6,19 +6,36 @@ namespace InventoryTraker.Web.Models
{
public class ProfileForm
{
[Required, Display(Name = "Full Name", Prompt = "Full Name (ex: John Doe)...")]
public string FullName { get; set; }
[Required]
[StringLength(128)]
[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Need complete name")]
public string UserName { get; set; }
[Required, DataType(DataType.EmailAddress), Display(Prompt = "your@email.com...")]
public string EmailAddress { get; set; }
[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; }
[DataType(DataType.Password)]
public string CurrentPassword { get; set; }
[DataType(DataType.Password)]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Compare("NewPassword")]
public string ConfirmPassword { get; set; }
public override string ToString()
{
return $"UserName: {UserName}, email: {Email}";
}
public class AutoMapperProfile : Profile
{
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));
CreateMap<User, ProfileForm>();
}
}
}