SHARE
TWEET

Untitled

a guest Oct 2nd, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public UserDto GetUser(string email) {
  2.     if (!ValidationUtil.IsValidEmail(email))
  3.         throw new ArgumentException("Must be a properly formatted email", nameof(email));
  4.     UserDto toReturn = null;
  5.     toReturn = Users?.FirstOrDefault(user => user?.Email == email);
  6.     return toReturn;
  7. }
  8.  
  9. public bool AreCredentialsValid(string email, string password) {
  10.     bool toReturn = false;
  11.     if (!ValidationUtil.IsValidEmail(email))
  12.         throw new ArgumentException("Must be a properly formatted email", nameof(email));
  13.     if (password == null)
  14.         new ArgumentNullException(nameof(password));
  15.     UserDto user = this.GetUser(email);
  16.     if (user?.Email == email && user?.Password == password)
  17.         toReturn = true;
  18.     return toReturn;
  19. }
  20.  
  21. public UserDto GetUserIfCredentialsAreValid(string email, string password) {
  22.     UserDto toReturn = null;
  23.     if (AreCredentialsValid(email, password))
  24.         toReturn = GetUser(email);
  25.     return toReturn;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top