public IEmployee createEmployee(int employeeID) { UserMgr userMgr = new UserMgr(MainFactory.getUserSvc()); IUser user; if (!userMgr.getAllUsers().Any(x => x.EmployeeID == employeeID)) throw new ArgumentException(employeeID + " is not a valid employeeID."); user = userMgr.getUser(employeeID); int? groupManagerID = groupManagerList.Data .Where(x => x.ID == user.ManagerID).FirstOrDefault().ID; if (groupManagerID == null) { // Create Group in repository GroupManager groupManager = createGroupManager((int)user.ManagerID); this.groupManagerList.Data.Add(groupManager); HttpContext.Current.Application["GroupManager"] = this.groupManagerList; groupManagerID = groupManager.ID; } Employee employee = new Employee(user, DateTime.Today, null, (int)groupManagerID); this.employeeList.Data.Add(this.repository.saveEmployee(employee)); HttpContext.Current.Application["Employee"] = this.employeeList; return employee; }
public Employee saveEmployee(Employee employee) { MainFactory.getLogSvc().logAction("Save new Employee - " + employee.ID + " into console."); EMPLOYEE e = new EMPLOYEE { EMPLOYEE_ID = employee.ID, START_DATE = employee.StartDate, GROUP_MANAGER_START = employee.GroupManagerID }; try { using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Consxole", false)) { db.EMPLOYEEs.InsertOnSubmit(e); db.SubmitChanges(); return employee; } } catch (SqlException se) { MainFactory.getLogSvc().logError(this.GetType().Name, MainFactory.getCurrentMethod(), "rs-se-01", se.Message + "\n" + se.StackTrace); throw new Exception("Unable to create Employee. Please see error log for further details."); } }
public bool isAdmin(Employee employee) { return employee.User.UserType == UserType.ADMIN || employee.User.UserType == UserType.ADMIN_MANAGER; }
public string getUserGroupName(Employee employee) { if (this.groupManagerList == null || !this.groupManagerList.isValid()) refresh(); return this.groupManagerList.Data.Where(x => x.GroupManagerID == employee.GroupManagerID).FirstOrDefault().Text; }