public UserDto GetUser(string email) { if (!ValidationUtil.IsValidEmail(email)) { throw new ArgumentException("Must be a properly formatted email", nameof(email)); } UserDto toReturn = null; toReturn = Users?.FirstOrDefault(user => user?.Email == email); return(toReturn); }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { ValidationResult result = new ValidationResult(true, null); this.email = (value ?? string.Empty).ToString(); if (this.email == null || string.IsNullOrWhiteSpace(this.email)) { result = new ValidationResult(false, "Email不能为空!"); } else { if (!ValidationUtil.IsValidEmail(this.email)) { result = new ValidationResult(false, "Email格式不正确,请重新输入!"); } } return(result); }
public bool AreCredentialsValid(string email, string password) { bool toReturn = false; if (!ValidationUtil.IsValidEmail(email)) { throw new ArgumentException("Must be a properly formatted email", nameof(email)); } if (password == null) { new ArgumentNullException(nameof(password)); } UserDto user = this.GetUser(email); if (user?.Email == email && user?.Password == password) { toReturn = true; } return(toReturn); }