Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace upr1PS
- {
- class LoginValidation
- {
- private string loginUserName;
- private string loginPassword;
- private string errorMessage;
- public static roles currentUserRole
- {
- get;
- private set;
- }
- public bool ValidationUserInput(User user)
- {
- return true;
- }
- public LoginValidation(string userName, string password)
- {
- this.loginUserName = userName;
- this.loginPassword = password;
- }
- public bool ValidateUserInput(User user)
- {
- //user.userName = UserData.TestUser
- //user.password = UserData.TestUsers.password;
- //user.userId = UserData.TestUsers.userId;
- //user.role = UserData.TestUsers.role;
- user.userName = this.loginUserName;
- user.password = this.loginPassword;
- currentUserRole = (roles)user.role;
- bool emptyUserName;
- emptyUserName = this.loginUserName.Equals(String.Empty);
- if (emptyUserName == true)
- {
- this.errorMessage = "Не е посочено потребителско име!";
- Console.WriteLine(this.errorMessage);
- return false;
- }
- Boolean emptyPassword;
- emptyPassword = this.loginPassword.Equals(String.Empty);
- if (emptyPassword == true)
- {
- this.errorMessage = "Не е посочена парола!";
- Console.WriteLine(this.errorMessage);
- return false;
- }
- if(this.loginUserName.Length < 5)
- {
- this.errorMessage = "username-a трябва да е по-дълъг от 5 символа";
- Console.WriteLine(this.errorMessage);
- return false;
- }
- if(this.loginPassword.Length < 5)
- {
- this.errorMessage = "паролата трябва да е по-дълга от 5 символа";
- Console.WriteLine(this.errorMessage);
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement