User profile editing and password
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user