I have a class user which looks like this:
public class User
{
public int UserId { get; set; }
[Required(ErrorMessage = \"A username is required.\")
Inheritance seems like a standard way of adding functionality in this case. How about having your RegistrationViewModel
derive from the UserViewModel
:
public class RegistrationViewModel : UserViewModel
{
[DisplayName("Password confirmation")]
[Required]
[Compare("Password", ErrorMessage = "The password do not match")]
public string PasswordConfirmation { get; set; }
}
and:
public ActionResult UsernameExists(string Username)
{
...
}