コード例 #1
0
 public static bool VerifyUser(string login, string password)
 {
     foreach (var user in UserLogic.GetAll())
     {
         if (user.Login == login)
         {
             return(user.Password == password);
         }
     }
     UserLogic.AddUser(login, password);
     if (login != "")
     {
         UserLogic.AddUserRole(login, "User");
     }
     if (login == "Nikita" && password == "admin")
     {
         UserLogic.AddUserRole(login, "Admin");
     }
     return(true);
 }
コード例 #2
0
 public static bool AddUserRole(int UserId, string RoleName)
 {
     if (UserId == 0 && RoleName != "")
     {
         return(false);
     }
     if (UserLogic.GetAllUsers().Count() < 1)
     {
         AddUserRole(UserId, "Admin");
     }
     foreach (User item in UserLogic.GetAllUsers())
     {
         if (item.Id == UserId)
         {
             return(UserLogic.AddUserRole(UserId, RoleName));
         }
     }
     return(false);
 }