Exemple #1
0
        private void FindPersonnelObject()
        {
            List <Personnel> allPersonnel = Database.GetPersonnel();
            Personnel        person       = allPersonnel.Find(personnel => (personnel.ID == userNameOrID || personnel.Email == userNameOrID));
            bool             isVerified   = person.VerifyPassword(password);

            if (isVerified)
            {
                Person = person;
            }
            else
            {
                Person = null;
            }
        }
Exemple #2
0
        public Personnel CreateNewEmployee(string name, string password, string email, string department, int vacationDays, bool isManager = false)
        {
            Personnel employee = new Personnel();

            employee.SetPassword(password);
            employee.Name = MakeTitleCase(name);
            if (EmailIsAvailable(email))
            {
                employee.Email = email;
            }
            else
            {
                employee.Email = "invalid";
            }
            employee.Department            = department;
            employee.isManager             = isManager;
            employee.isAdmin               = false;
            employee.AvailableVacationDays = vacationDays;
            employee.SetID();
            Database.AddPersonnel(employee);
            return(employee);
        }
Exemple #3
0
        public bool CreateNewVacationDate(DateTime start, DateTime end, Personnel person)
        {
            VacationDate vacation = new VacationDate();

            vacation.StartDate     = start;
            vacation.EndDate       = end;
            vacation.EmployeeID    = person.ID;
            vacation.EmployeeName  = MakeTitleCase(person.Name);
            vacation.EmployeeEmail = person.Email;
            vacation.Department    = person.Department;
            vacation.IsVerified    = false;
            vacation.VerifyTimeIsLinear();
            if (VacationDateIsUnique(vacation))
            {
                if (person.UpdateAvailableVacationDays(vacation))
                {
                    Database.AddVacationDate(vacation);
                    return(true);
                }
            }
            return(false);
        }
Exemple #4
0
        public Personnel CreateNewAdmin(string email, string password, string name = "Admin of the Human Resource Department")
        {
            CreateAdminDepartmentIfNone();
            Personnel admin = new Personnel();

            admin.SetPassword(password);
            admin.Name = MakeTitleCase(name);
            if (EmailIsAvailable(email))
            {
                admin.Email = email;
            }
            else
            {
                admin.Email = "invalid";
            }
            admin.isManager  = true;
            admin.isAdmin    = true;
            admin.Department = "Human Resources Department";
            admin.SetID();
            admin.AvailableVacationDays = -1;
            Database.AddPersonnel(admin);
            return(admin);
        }
Exemple #5
0
        public bool Login(string id, string password)
        {
            bool isValid;

            try
            {
                Login login = new Login(id, password);
                if (login.Person != null)
                {
                    CurrentUser = login.Person;
                    department  = InitializeDepartment();
                    isValid     = true;
                }
                else
                {
                    isValid = false;
                }
            }
            catch
            {
                isValid = false;
            }
            return(isValid);
        }