コード例 #1
0
        public void CreateNewUser(string name, string pw)
        {
            Users u      = new Users();
            bool  unique = true;

            u.Username = name;
            u.Password = pw;
            var users = db.GetUsers();

            foreach (var x in users)
            {
                if (x.Username == name)
                {
                    Console.WriteLine("Sorry, username already exists. Choose another.");
                    Console.WriteLine("-------------------------------------");
                    unique = false;
                    break;
                }
            }
            if (unique)
            {
                db.AddUser(u);
                Console.WriteLine("Account created successfully");
                Console.WriteLine("-------------------------------------");
            }
        }