/// <summary>
        /// Assign role admin to employee
        /// Containing: - assign role admin
        ///             - assign admin related permissions
        /// </summary>
        /// <param name="employeeId">Id of employee</param>
        public void AssignAdminRole(int employeeId)
        {
            //get employee by id
            Employee employee = employeeLogic.GetEmployeeById(employeeId);

            if (employee == null)
            {
                Debug.WriteLine($"ERROR during AssignAdminRole : No employee with id {employee} found.");
                throw new Exception();
            }
            //call database logic
            db.UpdateEmployeeRole(employeeId, (int)Role.ROLE_ADMIN);

            Employee.Employees = db.GetAllEmployees();
        }
Exemple #2
0
        /// <summary>
        /// Login with email and password
        /// </summary>
        /// <param name="emailAddress">Email address</param>
        /// <param name="password">Password</param>
        /// <returns>true if login successfull</returns>
        public bool Login(string emailAddress, string password)
        {
            //Get user account
            UserAccountEntry userCredentials = db.GetUserAccountCredentials(emailAddress);

            if (userCredentials == null)
            {
                return(false);
            }

            //verify password
            if (PasswordCryptoLogic.VerifyPassword(password, userCredentials.PasswordSalt, userCredentials.PasswordHash))
            {
                Employee employee = db.GetEmployeeById(userCredentials.EmployeeId);

                if (employee == null)
                {
                    Debug.WriteLine($"ERROR during retrieving employee with id {userCredentials.EmployeeId}");
                    throw new Exception();
                }
                employee.EmailAddress = emailAddress;

                userCredentials = null;


                //Get all trainings
                Training.Trainings = db.GetTrainings();

                //Get all training bookings of current user
                employee.TrainingBooking = db.GetTrainingBooking(employee.Id);

                if (employee.Role.Equals(Role.ROLE_ADMIN))
                {
                    Employee.Employees = db.GetAllEmployees();
                }

                //assign employee object to global employee
                Global.employee = employee;


                return(true);
            }

            return(false);
        }
Exemple #3
0
 public List <Employee> GetAllEmployees()
 {
     return(db.GetAllEmployees());
 }