コード例 #1
0
        public bool CreateUser(string username, string password, BE.User.RoleTypes roleTypes, object obj, string email)
        {
            string hashPassword = User.GetSha512FromString(password);
            User   user         = new User(roleTypes, obj, username, hashPassword, email);

            if (DS.DataSource.users.Any(_user => _user.Username == username))
            {
                return(false);
            }
            DS.DataSource.users.Add(user);
            return(true);
        }
コード例 #2
0
 public bool CreateUser(string username, string password, BE.User.RoleTypes roleTypes, object obj, string email)
 {
     if (username == string.Empty)
     {
         throw new Exception("username is empty");
     }
     if (email == string.Empty)
     {
         throw new Exception("email is empty");
     }
     if (!IsValidEmailAddress(email))
     {
         throw new Exception("email is not valid email address");
     }
     if (password == string.Empty)
     {
         throw new Exception("password is empty");
     }
     if (roleTypes == User.RoleTypes.School && !(obj is string))
     {
         throw new Exception("to user as School should be connect to string");
     }
     if (roleTypes == User.RoleTypes.Teacher && !(obj is string))
     {
         throw new Exception("to user as Teacher should be connect to string");
     }
     if (roleTypes == User.RoleTypes.Trainee && !(obj is Trainee))
     {
         throw new Exception("to user as trainee should be connect to Trainee");
     }
     if (roleTypes == User.RoleTypes.Tester && !(obj is Tester))
     {
         throw new Exception("to user as Tester should be connect to Tester");
     }
     return(dal.CreateUser(username, password, roleTypes, obj, email));
 }