public IHttpActionResult GetDepartmentList() { int id = FindCurrentRetrievalList().RetrievalListID - 1; List <CustomDepartment> departments = db.RetrievalListDetails.Where(r => r.RetrievalListID == id) .Select(r => new CustomDepartment { DepartmentID = r.DepartmentID, DepartmentName = r.Department.DepartmentName, CollectionPoint = r.Department.CollectionPoint }).Distinct().ToList(); for (int i = 0; i < departments.Count(); i++) { int depID = departments[i].DepartmentID; DeptUser rep = db.DeptUsers.SingleOrDefault(d => d.Role == DepartmentRole.REPRESENTATIVE && d.DeptEmployee.DepartmentID == depID); departments[i].Representative = new CustomDeptEmployee { DeptEmployeeName = rep.DeptEmployee.ToString(), Email = rep.DeptEmployee.Email, Phone = rep.DeptEmployee.Phone }; } return(Ok(departments)); }
/// <summary> /// 更新用户基本信息 /// </summary> /// <param name="user"></param> public void UpdateDeptUser(DeptUser user) { if (user == null) { throw new ArgumentNullException("Deptuser"); } _dataAccess.UpdateEntity(user); }
public void CancelActingHead(int actingHeadID) { DeptUser depUser = FindDepUser(actingHeadID); depUser.Role = DepartmentRole.EMPLOYEE; depUser.StartDate = null; depUser.EndDate = null; db.SaveChanges(); }
public CustomMembershipUser(DeptUser user) : base("CustomMembership", user.Username, user.DeptEmployeeID, user.DeptEmployee.Email, string.Empty, string.Empty, true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now) { Username = user.Username; Password = user.Password; FirstName = user.DeptEmployee.FirstName; LastName = user.DeptEmployee.LastName; Role = user.Role.ToString(); UserID = user.DeptEmployeeID; }
public IHttpActionResult AssignRepresentative(CustomDeptEmployee customDeptEmployee) { DeptUser newRep = db.DeptUsers.SingleOrDefault(d => d.DeptEmployeeID == customDeptEmployee.DeptEmployeeID); DeptUser currentRep = db.DeptUsers.SingleOrDefault(d => d.Role == DepartmentRole.REPRESENTATIVE && d.DeptEmployee.DepartmentID == customDeptEmployee.DepartmentID); currentRep.Role = DepartmentRole.EMPLOYEE; newRep.Role = DepartmentRole.REPRESENTATIVE; db.SaveChanges(); return(Ok()); }
public IHttpActionResult GetCurrentRep(int id) { DeptUser rep = db.DeptUsers.SingleOrDefault(d => d.DeptEmployee.DepartmentID == id && d.Role == DepartmentRole.REPRESENTATIVE); CustomDeptEmployee employee = new CustomDeptEmployee { DepartmentID = id, DeptEmployeeName = rep.DeptEmployee.ToString(), Email = rep.DeptEmployee.Email, Phone = rep.DeptEmployee.Phone }; return(Ok(employee)); }
public void AssignActingHead(int DeptEmployeeID, DateTime start, DateTime end) { DeptUser depUser = db.DeptUsers.SingleOrDefault(d => d.DeptEmployeeID == DeptEmployeeID); depUser.StartDate = start; depUser.EndDate = end; DateTime today = DateTime.Today; if (start == today) { depUser.Role = DepartmentRole.ACTINGHEAD; } db.SaveChanges(); }
public void AssignRep(int DeptEmployeeID) { int depID = FindDepID(); //change current rep to emp int repID = FindRepID(depID); DeptUser currentRep = FindDepUser(repID); currentRep.Role = DepartmentRole.EMPLOYEE; //assign selected emp as rep DeptUser newRep = FindDepUser(DeptEmployeeID); newRep.Role = DepartmentRole.REPRESENTATIVE; db.SaveChanges(); }
public ActionResult Index() { int headID = headService.FindUserID(); int depID = headService.FindDepID(); int actingHeadID = headService.FindActingHeadID(depID); if (actingHeadID != 0) { DeptUser depUser = db.DeptUsers.Where(x => x.DeptEmployeeID == actingHeadID).First(); DateTime?endDate = db.DeptUsers.Where(x => x.DeptEmployeeID == actingHeadID).Select(x => x.EndDate).FirstOrDefault(); DateTime today = DateTime.Today; if (today > endDate) { depUser.Role = DepartmentRole.EMPLOYEE; depUser.StartDate = null; depUser.EndDate = null; db.SaveChanges(); } } return(RedirectToAction("RequisitionsToApprove", "Head")); }
/// <summary> /// 添加人员 /// </summary> /// <param name="user"></param> /// <returns></returns> public int AddDeptUser(DeptUser user) { int userId = _dataAccess.AddEntity(user); return(userId); }