Пример #1
0
        void Submit(object obj)
        {
            string password            = (obj as PasswordBox).Password;
            var    validate            = new DataValidations.DataValidation();
            var    constants           = new Constants();
            var    validateCompanyData = new CompanyValidations();

            if (UserName == Constants.usernamedMaster && SecurePasswordHasher.Verify(password, constants.passwordEmployeeHashed))
            {
                MasterView masterView = new MasterView();
                loginView.Close();
                masterView.Show();
                return;
            }

            else if (validateCompanyData.IsCorrectUser(userName, password))
            {
                var db         = new CompanyDBRepository();
                int userDataId = db.GetUserDataId(userName);
                if (userDataId != 0)
                {
                    var typeOfUser = validateCompanyData.GetUserType(userDataId);
                    if (typeOfUser == nameof(tblManager))
                    {
                        var notImplemented = new NotImplemntedView();
                        notImplemented.Show();
                        loginView.Close();
                        return;
                    }
                    if (typeOfUser == nameof(tblAdministrator))
                    {
                        var typeOfAdministrator = validateCompanyData.GetAdministratorType(userDataId);
                        if (typeOfAdministrator == "System")
                        {
                            AdministratorView administrator = new AdministratorView(typeOfAdministrator);
                            administrator.Show();
                            loginView.Close();
                            return;
                        }
                        else
                        {
                            var notImplemented = new NotImplemntedView();
                            notImplemented.Show();
                            loginView.Close();
                            return;
                        }
                    }
                    if (typeOfUser == nameof(tblEmployee))
                    {
                        var notImplemented = new NotImplemntedView();
                        notImplemented.Show();
                        loginView.Close();
                        return;
                    }
                }
            }
            else
            {
                WarningView warning = new WarningView(loginView);
                warning.Show("User name or password are not correct!");
                return;
            }
        }