private void Login()
        {
            if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
            {
                using (UnitOfWork uow = new UnitOfWork())
                {
                    var user = uow.GetRepository <UserModel>().GetAll().FirstOrDefault(x => x.Username.Equals(Username) &&
                                                                                       x.Password.Equals(Password));

                    if (user != null)
                    {
                        using (TodoMenuWindow todoMenuWindow = new TodoMenuWindow())
                        {
                            LoginWindow.Close();
                            LoginWindow.Dispose();
                            todoMenuWindow.ShowDialog();
                        }
                    }
                    else
                    {
                        MessageBox.Show("This username has already taken. Select different one.", "Username has taken", System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please fill in the required fields.");
            }
        }
 private void Register()
 {
     if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
     {
         using (UnitOfWork uow = new UnitOfWork())
         {
             if (!uow.GetRepository <UserModel>().Any(x => x.Username.Equals(Username)))
             {
                 uow.GetRepository <UserModel>().Add(new UserModel()
                 {
                     Username = Username,
                     Password = Password
                 });
                 uow.SaveChanges();
                 MessageBox.Show("User created successfully.", "Success", System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
                 using (TodoMenuWindow todoMenuWindow = new TodoMenuWindow())
                 {
                     LoginWindow.Close();
                     LoginWindow.Dispose();
                     todoMenuWindow.ShowDialog();
                 }
             }
             else
             {
                 MessageBox.Show("This username has already taken. Select different one.", "Username has taken", System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
     else
     {
         MessageBox.Show("Alanları Doldurunuz");
     }
 }
Exemplo n.º 3
0
 public TodoMenuViewModel(TodoMenuWindow todoMenuWindow)
 {
     TodoMenuWindow = todoMenuWindow;
 }