Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace upr1PS
  8. {
  9. class LoginValidation
  10. {
  11. private string loginUserName;
  12. private string loginPassword;
  13. private string errorMessage;
  14.  
  15. public static roles currentUserRole
  16. {
  17. get;
  18.  
  19. private set;
  20.  
  21. }
  22.  
  23.  
  24. public bool ValidationUserInput(User user)
  25. {
  26. return true;
  27. }
  28.  
  29. public LoginValidation(string userName, string password)
  30. {
  31. this.loginUserName = userName;
  32. this.loginPassword = password;
  33. }
  34.  
  35.  
  36.  
  37. public bool ValidateUserInput(User user)
  38. {
  39.  
  40. //user.userName = UserData.TestUser
  41. //user.password = UserData.TestUsers.password;
  42. //user.userId = UserData.TestUsers.userId;
  43. //user.role = UserData.TestUsers.role;
  44.  
  45. user.userName = this.loginUserName;
  46. user.password = this.loginPassword;
  47.  
  48.  
  49. currentUserRole = (roles)user.role;
  50.  
  51.  
  52. bool emptyUserName;
  53.  
  54. emptyUserName = this.loginUserName.Equals(String.Empty);
  55.  
  56. if (emptyUserName == true)
  57. {
  58. this.errorMessage = "Не е посочено потребителско име!";
  59. Console.WriteLine(this.errorMessage);
  60. return false;
  61. }
  62.  
  63. Boolean emptyPassword;
  64. emptyPassword = this.loginPassword.Equals(String.Empty);
  65.  
  66. if (emptyPassword == true)
  67. {
  68. this.errorMessage = "Не е посочена парола!";
  69. Console.WriteLine(this.errorMessage);
  70. return false;
  71. }
  72.  
  73. if(this.loginUserName.Length < 5)
  74. {
  75. this.errorMessage = "username-a трябва да е по-дълъг от 5 символа";
  76. Console.WriteLine(this.errorMessage);
  77. return false;
  78. }
  79.  
  80. if(this.loginPassword.Length < 5)
  81. {
  82. this.errorMessage = "паролата трябва да е по-дълга от 5 символа";
  83. Console.WriteLine(this.errorMessage);
  84. }
  85.  
  86. return true;
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement