/// <summary> /// 根据部门和人员ID,为部门添加关联人员 /// </summary> /// <param name="departmentRepository"></param> /// <param name="deptID"></param> /// <param name="personID"></param> /// <returns></returns> public static bool AddPerson(this IEntityRepository <Department> departmentRepository, Guid deptID, Guid personID) { var dept = departmentRepository.GetSingle(deptID); var person = departmentRepository.GetSingleRelevance <Person>(personID); var tempRelevance = departmentRepository.GetSingleRelevanceBy <PersonsInDepartment>(x => x.Person.ID == personID && x.Department.ID == deptID); if (tempRelevance != null) { return(false); } else { tempRelevance = new PersonsInDepartment() { Department = dept, Person = person }; departmentRepository.AddAndSaveRelevance <PersonsInDepartment>(tempRelevance); return(true); } }