private async void LoginHandler(object param) { var passwordBox = param as PasswordBox; Password = passwordBox.Password; if (string.IsNullOrEmpty(Password) && string.IsNullOrEmpty(Username)) { MessageBox.Show("Fields couldn't be empty.", "Exception", MessageBoxButton.OK, MessageBoxImage.Information); return; } var user = await _context.BakeshopWorkers.FirstOrDefaultAsync(u => u.Email == Username && u.Password == Password); if (user == null) { MessageBox.Show("Email or password incorrect.", "Exception", MessageBoxButton.OK, MessageBoxImage.Information); return; } CurrentUserManagment.FillUserWithData(user); var menuView = new MenuView(); menuView.Show(); CloseAction(); }
private void Logout() { var login = new LoginView(); login.Show(); CurrentUserManagment.ClearCurrentUser(); CloseAction(); }
public SuppliersViewModel() { _context = new BakeshopContext(); SortByFirstnameCommand = new RelayCommand(SortByFirstname); SortByLastnameCommand = new RelayCommand(SortByLastName); SortByPositionCommand = new RelayCommand(SortByPosition); GetToPreviousWindowCommand = new RelayCommand(GetToPreviousWindow); AddNewSupplierCommand = new RelayCommand(AddNewSupplier); EditSupplierCommand = new RelayCommand(EditSupplier); var currentUser = CurrentUserManagment.GetCurrentUser(); var IsAdminOrOwner = currentUser.Position == Positions.Owner || currentUser.Position == Positions.Manager ? true : false; IsAdminOrOwnerVisability = IsAdminOrOwner ? Visibility.Visible : Visibility.Hidden; LoadEmployees(); }
public RecipesViewModel() { _context = new BakeshopContext(); GetToPreviousWindowCommand = new RelayCommand(GetToPreviousWindow); NextPageCommand = new RelayCommand(NextPage); PreviousPageCommand = new RelayCommand(PreviousPage); AddNewRecipeCommand = new RelayCommand(AddNewRecipe); EditRecipeCommand = new RelayCommand(EditRecipe); DeleteRecipeCommand = new RelayCommand(DeleteRecipe); IsNextPageButtonEnabled = false; IsPreviousPageButtonEnabled = true; LoadFormulas(); var currentUser = CurrentUserManagment.GetCurrentUser(); var IsAdminOrOwner = currentUser.Position == Positions.Owner || currentUser.Position == Positions.Manager ? true : false; IsAdminOrOwnerVisability = IsAdminOrOwner ? Visibility.Visible : Visibility.Hidden; }