Esempio n. 1
0
 public void LogInAutomatically(Common_Library.AccountBase a)
 {
     Wait();
     Models.Account account = DataService.Account.GetAccount(new Models.Account()
     {
         UserName = a.UserName, Password = a.Password
     });
     if (account != null)
     {
         OnlineUser onlineUser = OnlineUsers.FirstOrDefault(o => o.HasAccount(account.UserName));
         if (onlineUser != null)
         {
             onlineUser.AddConnectionId(Context.ConnectionId);
         }
         else
         {
             onlineUser = OnlineUser.CreateNewOnlineUser(account, Context.ConnectionId);
             OnlineUsers.Add(onlineUser);
         }
         Clients.Client(Context.ConnectionId).LogInComplete();
     }
     else
     {
         Clients.Client(Context.ConnectionId).AccountNotExist();
     }
     Signal();
 }
Esempio n. 2
0
 public void LogIn(Common_Library.AccountBase a)
 {
     Wait();
     Models.Account account = new Models.Account()
     {
         UserName = a.UserName, Password = a.Password
     };
     if (DataService.Account.LogIn(account) && OnlineUsers.FirstOrDefault(o => o.HasAccount(account.UserName)) == null)
     {
         Clients.Client(Context.ConnectionId).LogInSuccessfully();
     }
     else
     {
         Clients.Client(Context.ConnectionId).LogInFailed();
     }
     Signal();
 }
Esempio n. 3
0
 public void CreateAccount(Common_Library.AccountBase a)
 {
     Wait();
     Models.Account account = new Models.Account()
     {
         UserName = a.UserName, Password = a.Password
     };
     if (DataService.Account.Add(account))
     {
         Clients.Client(Context.ConnectionId).CreateAccountSuccessfully();
     }
     else
     {
         Clients.Client(Context.ConnectionId).CreateAccountFailed();
     }
     Signal();
 }
Esempio n. 4
0
 public void ChangePassword(Common_Library.AccountBase account, string NewPassword)
 {
     Wait();
     if (DataService.Account.LogIn(new Account()
     {
         UserName = account.UserName, Password = account.Password
     }))
     {
         DataService.Account.ChangePassword(new Account()
         {
             UserName = account.UserName, Password = account.Password
         }, NewPassword);
         Clients.Client(Context.ConnectionId).ChangePasswordComplete();
     }
     else
     {
         Clients.Client(Context.ConnectionId).PasswordIsNotValid();
     }
     Signal();
 }