public bool newRegistration(String login, String password)
 {
     using (UserContext db = new UserContext())
     {
             var users = db.Users;
             foreach (User u in users)
             {
                 if (u.login == login)
                     return false;
             }
             User newUser = new User { login = login, password = password };
             db.Users.Add(newUser);
             db.SaveChanges();
     }
     return true;
 }
 public string tryLogin(String login, String password)
 {
     using (UserContext db = new UserContext())
     {
         var users = db.Users;
         foreach (User u in users)
         {
             if (u.login == login && u.password == password)
             {
                 if (!usersOnline.ContainsKey(login))
                     return "LOGGED IN";
                 else
                     return "This user is already logged in!";
             }
         }
     }
     return "There is no user with such login/password combination!";
 }
Example #3
0
 /// <summary>
 /// Event fired when the Alchemy Websockets server instance sends data to a client.
 /// Logs the data to the console and performs no further action.
 /// </summary>
 /// <param name="context">The user's connection context</param>
 public static void OnSend(UserContext context)
 {
     Console.WriteLine("Data Send To : " + context.ClientAddress);
 }