public static EmployeeDirectoryModel ToEmployeeDirectoryModel(this EmployeeDirectory employee, DataSourceRequest request)
        {
            var filters = request.Filters;

            if (!filters.Any())
            {
                return(employee.ToEmployeeDirectoryModel());
            }

            var predicate = ExpressionBuilder.Expression <EmployeeDirectory>(filters, false).Compile();

            return(new EmployeeDirectoryModel
            {
                EmployeeId = employee.EmployeeID,
                ReportsTo = employee.ReportsTo,
                FirstName = employee.FirstName,
                LastName = employee.LastName,
                Address = employee.Address,
                City = employee.City,
                Country = employee.Country,
                BirthDate = employee.BirthDate,
                HireDate = employee.HireDate,
                Phone = employee.Phone,
                Position = employee.Position,
                Extension = employee.Extension,
                hasChildren = employee.EmployeeDirectory1.Any(predicate)
            });
        }
        private void Delete(EmployeeDirectory employee)
        {
            var children = db.EmployeeDirectories.Where(e => e.ReportsTo == employee.EmployeeID);

            foreach (var subordinate in children)
            {
                Delete(subordinate);
            }

            db.EmployeeDirectories.Remove(employee);
        }
 public static EmployeeDirectoryModel ToEmployeeDirectoryModel(this EmployeeDirectory employee)
 {
     return(new EmployeeDirectoryModel
     {
         EmployeeId = employee.EmployeeID,
         ReportsTo = employee.ReportsTo,
         FirstName = employee.FirstName,
         LastName = employee.LastName,
         Address = employee.Address,
         City = employee.City,
         Country = employee.Country,
         BirthDate = employee.BirthDate,
         HireDate = employee.HireDate,
         Phone = employee.Phone,
         Position = employee.Position,
         Extension = employee.Extension,
         hasChildren = employee.EmployeeDirectory1.Any()
     });
 }