public bool AddNewEmployeeToDb(string title, string firstName, string middleName, string lastName, string phoneNumber, string email, Address personalAddress, int employeeNumber, DateTime dateOfBirth, string ppsn, double wage, int employeeCategory, int employeeCardNumber, DateTime hireDate, string photo) { try { int maxId = 0; // need some code to avoid dulicate usernames // maybe add some logic (busiess rules) about password policy // IUser user = new User(name, password, userType); // Construct a User Object foreach (Employee employee in EmployeeList) { if (employee.employeeNumber > maxId) { maxId = employee.employeeNumber; } } IEmployee theEmployee = EmployeeFactory.GetEmployee(title, firstName, middleName, lastName, phoneNumber, email, personalAddress, employeeNumber, dateOfBirth, ppsn, wage, employeeCategory, employeeCardNumber, hireDate, photo); // Using a Factory to create the user entity object. ie seperating object creation from business logic EmployeeList.Add(theEmployee); // Add a reference to the newly created object to the Models UserList DataLayer.AddNewEmployeeToDb(theEmployee); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } }
public Boolean addNewEmployee(string firstName, string lastName, string address, string phone, string email, string nextOfKinName, string nextOfKinPhone, decimal salery, string usertype) { try { int maxId = 0; int maxUserID = 0; //need some code to avoid dulicate usernames //maybe add some logic (busiess rules) about password policy //IUser user = new User(name, password, userType); // Construct a User Object foreach (Employee employee in EmployeeList) { if (employee.EmployeeID > maxId && employee.UserID > maxUserID) { maxId = employee.EmployeeID; } maxUserID = employee.UserID; } IEmployee theEmployee = EmployeeFactory.GetEmployee(maxId + 1, maxUserID + 1, firstName, lastName, address, phone, email, nextOfKinName, nextOfKinPhone, salery, usertype); // Using a Factory to create the user entity object. ie seperating object creation from business logic EmployeeList.Add(theEmployee); // Add a reference to the newly created object to the Models UserList DataLayer.addNewEmployeeToDB(theEmployee); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } }
public List <Employee> GetEmployees(int id) { List <Employee> employees = new EmployeesDAL().GetEmployees(id); employees.All(x => { x.AnnualSalary = EmployeeFactory.getEmployeeType(x.contractTypeName).getAnnualSalary(x.hourlySalary, x.monthlySalary); return(true); }); return(employees); }
public void FillEmployeeList() { employeeList = new List <IEmployee>(); List <string[]> employeeData = DataLayer.GetTableData("employee"); foreach (String[] row in employeeData) { EmployeeList.Add(EmployeeFactory.GetEmployee(new string[] { row[0], row[1], row[2], row[3], row[4], row[5] })); } }