Skip to content

Instantly share code, notes, and snippets.

@ralhamami
Created April 24, 2017 02:55
Show Gist options
  • Select an option

  • Save ralhamami/b7c27a86fb93c67a7df5ea426842d2dd to your computer and use it in GitHub Desktop.

Select an option

Save ralhamami/b7c27a86fb93c67a7df5ea426842d2dd to your computer and use it in GitHub Desktop.
public static List<string> GetEmployeePaths()
{
List<string> employeePaths = new List<string>();
allEmployees = GetAllEmployees();
foreach (Employee employee in allEmployees)
{
employeePaths.Add(RecursivePathFinder(employee));
}
employeePaths.Sort();
return employeePaths;
}
private static string RecursivePathFinder(Employee employee)
{
if (employee.ParentEmployeeId == 0)
{
return employee.Name;
}
else
{
return RecursivePathFinder(allEmployees.Where(x => x.EmployeeId == employee.ParentEmployeeId).First()) + "/" + employee.Name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment