예제 #1
0
        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();
        }
예제 #2
0
        private void Logout()
        {
            var login = new LoginView();

            login.Show();
            CurrentUserManagment.ClearCurrentUser();
            CloseAction();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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;
        }