Пример #1
0
 /// <summary>
 /// Ryan Blake
 /// Created: 2015/02/12
 /// Method takes in new and old employee parameters and then submits them to the Data Access Layer method to update the employee record for oldEmploy
 /// This will also take the place of a 'Delete' method
 ///     The user will simply mark the employee inactive which will change the
 ///     bit value in the table to a 0 to represent false
 /// </summary>
 /// <remarks>
 /// Tony Noel
 /// Updated: 2015/04/13
 /// Updated to comply with the ResultsEdit class of error codes.
 /// </remarks>
 /// <param name="oldEmployee">The Employee object containing old information</param>
 /// <param name="newEmployee">The Employee object with the new information</param>
 /// <exception cref="Exception">EmployeeAccessor method will throw exception to Manager saying that the employee could not be found to edit</exception>
 /// <returns>Employee information is updatd in the table and an integer is returned to represent rows affected</returns>
 public ResultsEdit EditCurrentEmployee(Employee oldEmployee, Employee newEmployee)
 {
     try
     {
         if (oldEmployee.Active && !newEmployee.Active)
         {
             newEmployee.Password = "";
         }
         if (!oldEmployee.Active && newEmployee.Active)
         {
             if (newEmployee.Password == null || string.IsNullOrWhiteSpace(newEmployee.Password))
             {
                 throw new ApplicationException("You must set a password");
             }
         }
         int result = EmployeeAccessor.UpdateEmployee(oldEmployee, newEmployee);
         if (result == 1)
         {
             return(ResultsEdit.Success);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(ResultsEdit.DatabaseError);
 }
Пример #2
0
        public bool AddNewEmployee(string firstName, string lastName, string localPhone, string emailAddress, string userName, string password)
        {
            try
            {
                var emp = new Employee()
                {
                    FirstName    = firstName,
                    LastName     = lastName,
                    LocalPhone   = localPhone,
                    EmailAddress = emailAddress,
                    UserName     = userName,
                    Password     = HashMethods.HashSha256(password)
                };
                if (EmployeeAccessor.InsertEmployee(emp) == 1)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Retrieves all Active Employees From Database
        /// </summary>
        /// <param name="isEmployed">True or False boolean paramter to retrieveCountry active or inactive employees respecetively</param>
        /// <returns>A list of active or inactive Employee objects from Database.</returns>
        public List <Employee> RetrieveEmployees(bool isEmployed)
        {
            var employeeList = new List <Employee>();

            employeeList = EmployeeAccessor.RetrieveEmployees(isEmployed);

            return(employeeList);
        }
Пример #4
0
        public void EmployeeAddEmployeeAccess()
        {
            //Adds fake employee to Data base
            int rows = EmployeeAccessor.AddEmployee(testEmp);

            //Asserts that one row was affected.
            Assert.AreEqual(1, rows);
        }
Пример #5
0
        /// <summary>
        /// Delete AddressType
        /// </summary>
        /// <param name="addressTypeID"></param>
        /// <returns></returns>
        public bool DeleteAddressType(int addressTypeID)
        {
            bool result = false;

            result = EmployeeAccessor.DeleteAddresstype(addressTypeID);

            return(result);
        }
Пример #6
0
        /// <summary>
        /// Updates Address Type Information
        /// </summary>
        /// <param name="addressType"></param>
        /// <returns></returns>
        public bool UpdateAddressType(AddressType addressType)
        {
            bool result = false;

            result = EmployeeAccessor.UpdateAddressType(addressType);

            return(result);
        }
Пример #7
0
        /// <summary>
        /// Retrieves AddressTypes by ID
        /// </summary>
        /// <param name="addresstypeID">Address Type Integer ID</param>
        /// <param name="retrieveAll">Retrieve all signal</param>
        /// <returns>A list of Address Types</returns>
        public List <AddressType> RetrieveAddressTypeByID(int addresstypeID, bool retrieveAll)
        {
            List <AddressType> addressTypesList = new List <AddressType>();

            addressTypesList = EmployeeAccessor.RetrieveAddressTypesByID(addresstypeID, retrieveAll);

            return(addressTypesList);
        }
Пример #8
0
        /// <summary>
        /// Deletes Clearance Level
        /// </summary>
        /// <param name="clearanceLevelId">Clearance Level ID</param>
        /// <returns></returns>
        public bool DeleteCleranceLevel(int clearanceLevelId)
        {
            bool result = false;

            result = EmployeeAccessor.DeleteClearanceLevel(clearanceLevelId);

            return(result);
        }
Пример #9
0
        /// <summary>
        /// Update Clearance levels
        /// </summary>
        /// <param name="clearanceLevel"></param>
        /// <returns></returns>
        public bool UpdateClearanceLevel(ClearanceLevel clearanceLevel)
        {
            bool result = false;

            result = EmployeeAccessor.UpdateClearanceLevel(clearanceLevel);

            return(result);
        }
Пример #10
0
        /// <summary>
        /// Delete User Role By ID
        /// </summary>
        /// <param name="userRolesID"></param>
        /// <returns></returns>
        public bool DeleteUserRoleByID(int userRolesID)
        {
            bool result = false;

            result = EmployeeAccessor.DeleteUserRoles(userRolesID);

            return(result);
        }
Пример #11
0
        /// <summary>
        /// Updates User Roles
        /// </summary>
        /// <param name="userRoles"></param>
        /// <returns>Returns a boolean</returns>
        public bool UpdateUserRoles(UserRoles userRoles)
        {
            bool result = false;

            result = EmployeeAccessor.UpdateUserRoles(userRoles);

            return(result);
        }
Пример #12
0
        /// <summary>
        /// Retrieves Job Positions based on DepartmentID
        /// </summary>
        /// <param name="departmentId">Retrieves ID</param>
        /// <param name="isRetrieveAll">Paramter to indicate if all should be retrieved</param>
        /// <returns>List of User Roles</returns>
        public List <UserRoles> RetrieveUserRolesByDeptID(string departmentId, bool isRetrieveAll)
        {
            var jobPositions = new List <UserRoles>();

            jobPositions = EmployeeAccessor.RetrieveUserRoles(departmentId, isRetrieveAll);

            return(jobPositions);
        }
Пример #13
0
        //UserRole CRUD

        /// <summary>
        /// Creates new User Roles
        /// </summary>
        /// <param name="userRole"></param>
        /// <returns>Returns confirmation</returns>
        public bool CreateUserRole(UserRoles userRole)
        {
            bool result = false;

            result = EmployeeAccessor.CreateUserRole(userRole);

            return(result);
        }
Пример #14
0
        /// <summary>
        /// Deletes Departments
        /// </summary>
        /// <param name="departmentID"></param>
        /// <returns></returns>
        public bool DeleteDepartment(string departmentID) //potentially dangerous
        {
            bool result = false;

            result = EmployeeAccessor.DeleteDepartment(departmentID);

            return(result);
        }
Пример #15
0
        /// <summary>
        /// Updates Department Information
        /// </summary>
        /// <param name="department"></param>
        /// <returns></returns>
        public bool UpdateDepartment(Department department)
        {
            bool result = false;

            result = EmployeeAccessor.UpdateDepartment(department);

            return(result);
        }
Пример #16
0
        /// <summary>
        /// Updates Employee information
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public bool UpdateEmployeeByID(Employee employee)
        {
            bool result = false;

            //Set Hire Date - control must be created in presentation layer
            employee.HireDate = DateTime.Now;

            //Handle Empty SSN Issue
            employee.SSNo = employee.SSNo != null ? employee.SSNo : String.Empty;

            //Handle Empty Pic Url issue
            employee.PicUrl = employee.PicUrl != null ? employee.PicUrl : String.Empty;

            //User isBlocked :: False
            employee.isBlocked = false;

            //Update Employee Details
            result = EmployeeAccessor.UpdateEmployeeByID(employee);

            //Update Employee Address
            int count = 0;

            try
            {
                if (employee.Address != null)
                {
                    foreach (var addressElement in employee.Address)
                    {
                        if (addressElement.UserAddressId != 0) // Update Employee Address
                        {
                            count += EmployeeAccessor.UpdateAddressByUserID(employee.UserId, addressElement);
                        }
                        else // Create New Address
                        {
                            count += EmployeeAccessor.CreateAddressByUserID(employee.UserId, addressElement);
                        }
                    }

                    //Check if write was successful
                    if (employee.UserId != 0 && count == employee.Address.Count)
                    {
                        result = true;
                    }

                    else
                    {
                        result = false;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            //Perform update for addresses
            return(result);
        }
Пример #17
0
        public void EmployeeGetEmployeeLoginAccess()
        {
            //Grabs the fake emp ID
            int      ID   = TestCleanupAccessor.getTestEmp();
            Employee fake = EmployeeAccessor.GetEmployeeLogin(ID, Password);

            //Asserts that the employee record being returned matches the fake employee record in the setup
            Assert.AreEqual("Test", fake.FirstName);
        }
Пример #18
0
        public void EmployeeGetEmployeeByIDAccess()
        {
            //Grab the fake employeeID number
            int ID = TestCleanupAccessor.getTestEmp();
            //Callls to Employee Accessor to grab an employee record by id
            Employee fake = EmployeeAccessor.GetEmployee(ID);

            Assert.AreEqual("Test", fake.FirstName);
        }
 public List <Employee> FindLeadReports(string supFirstName, string supLastName)
 {
     try
     {
         return(EmployeeAccessor.SelectDirectReports(supFirstName, supLastName));
     }
     finally
     {
     }
 }
Пример #20
0
 /// <summary>
 /// Ryan Blake
 /// Created: 2015/02/12
 ///
 /// Method makes a call to getEmployeeList method from the EmployeeAccessor to retrieve a list of all active employees
 /// </summary>
 /// <exception cref="Exception">Exception is thrown from Accessor that states that employee could not be found in the database</exception>
 /// <returns>The employee list is retrieved and returned up to the presentation layer (calling method)</returns>
 public List <Employee> FetchListEmployees()
 {
     try
     {
         return(EmployeeAccessor.GetEmployeeList().OrderBy(x => x.Active != true).ToList());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #21
0
 public List <Employee> GetFilteredEmployeeList(bool active = true)
 {
     try
     {
         return(EmployeeAccessor.RetrieveEmployeeList(active));
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Reply hazy. Try again later.", ex);
     }
 }
Пример #22
0
 /// <summary>
 /// Arik Chadima
 /// Created: 2015/03/03
 /// Attempts to fetch an employee with the given credentials from the access layer.
 /// Failure: ApplicationException if the login was bad, and SqlException of some kind if it's a connection issue.
 /// </summary>
 /// <param name="empId">The employee's ID matching an employee record</param>
 /// <param name="empPassword">the employee's Password that matches the same record as the employeeID</param>
 /// <returns>The employee object with the given credentials.</returns>
 public Employee GetEmployeeLogin(int empId, string empPassword)
 {
     try
     {
         return(EmployeeAccessor.GetEmployeeLogin(empId, empPassword));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List <Employee> FindSupAgents(string supFirstName, string supLastName)
 {
     try
     {
         return(EmployeeAccessor.SelectSupAgentReports(supFirstName, supLastName));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public List <Employee> FindEmployeesToList(string role, string department)
 {
     try
     {
         return(EmployeeAccessor.SelectEmployeesToList(role, department));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public List <Employee> SelectSupsByDept(string department)
 {
     try
     {
         return(EmployeeAccessor.SelectSupsByDept(department));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public void ResetEmployeePass(Employee oldE, Employee newE)
 {
     try
     {
         EmployeeAccessor.ResetEmployeePass(oldE, newE);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public void UpdateEmployee(Employee oldE, Employee newE)
 {
     try
     {
         EmployeeAccessor.UpdateEmployee(oldE, newE);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public List <Employee> FetchEmployeesbyRole(string roleName)
 {
     try
     {
         return(EmployeeAccessor.SelectEmployeesByRole(roleName));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public List <Department> FetchDepartmentList()
 {
     try
     {
         return(EmployeeAccessor.SelectDepartmentList());
     }
     catch (Exception)
     {
         throw;
     }
 }
 public List <Role> FetchRoleList()
 {
     try
     {
         return(EmployeeAccessor.SelectRoleList());
     }
     catch (Exception)
     {
         throw;
     }
 }