// method to get departments in collection point assigned public List <Department> RetrieveDepartmentsInCollectionPointList(List <CollectionPoint> collectionPointList) { List <Department> assignedDepartmentList = new List <Department>(); foreach (CollectionPoint cp in collectionPointList) { List <Department> deptList = (List <Department>)departmentRepo.FindBy(x => x.CollectionPointId == cp.Id); foreach (Department dp in deptList) { Department dept = dp; assignedDepartmentList.Add(dept); } } return(assignedDepartmentList); }