using System.ComponentModel.DataAnnotations;
using AutoMapper;
using InventoryTraker.Web.Core;

namespace InventoryTraker.Web.Models
{
	public class ProfileForm
	{
		[Required]
		[StringLength(128)]
		[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Need complete name")]
		public string UserName { 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>();
			}
		}
	}
}