private void ExecuteRegisterCommand(object parameter)
        {
            Validate();
            if (!string.IsNullOrEmpty(UserLoginString) && !string.IsNullOrEmpty(UserPasswordString)
                && !string.IsNullOrEmpty(UserConfirmPasswordString) && UserConfirmPasswordString == UserPasswordString)
            {
                try
                {
                    using (MKDbContext db = new MKDbContext())
                    {
                        User u = new User();
                        u.Login = UserLoginString;
                        u.Password = Security.EncryptPassword(UserLoginString, UserPasswordString);
                        u.HomeDirectoryPath = @".\Users\" + u.Login;

                        db.Users.Add(u);
                        db.SaveChanges();

                        GeneralVm.ActiveUser = u;

                        MainWindow mainWindow = new MainWindow();
                        CloseWindow();
                        mainWindow.Show();
                    }

                    //GeneralVM.ActiveUser = User.Find(UserLoginString, UserPasswordString);
                    //User.Users.Remove(User.Users.Values.ToList()[0].UserId);
                }
                catch (Exception)
                {
                    MessageBox.Show("Registration failer :(");
                }
            }
        }
Esempio n. 2
0
 public bool Equals(User other)
 {
     return UserId == other.UserId;
 }