Skip to content

Commit

Permalink
R: Move the method to the EmployeeCollection class
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgu committed Mar 19, 2016
1 parent 4ece63e commit 3a769df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
15 changes: 15 additions & 0 deletions EmployeeCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,20 @@ public List<Employee> Items
{
get { return _employeeCollection; }
}

public static void AddEmployeeIfMatch(EmployeeFilter employeeFilter, string name, int age, bool isSalaried,
EmployeeCollection employeeCollection, int id)
{
if (employeeFilter.Matches(name, age, isSalaried))
{
employeeCollection.Items.Add(new Employee
{
Name = name,
Id = id,
Age = age,
IsSalaried = isSalaried
});
}
}
}
}
17 changes: 1 addition & 16 deletions Yucky.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,11 @@ public static EmployeeCollection GetEmployees(EmployeeFilter employeeFilter, Fak
int age = reader.GetInt32(EmployeeAgeColumnIndex);
bool isSalaried = reader.GetBoolean(EmployeeIsSalariedColumnIndex);

AddEmployeeIfMatch(employeeFilter, name, age, isSalaried, employeeCollection, id);
EmployeeCollection.AddEmployeeIfMatch(employeeFilter, name, age, isSalaried, employeeCollection, id);
}
}

return employeeCollection;
}

private static void AddEmployeeIfMatch(EmployeeFilter employeeFilter, string name, int age, bool isSalaried,
EmployeeCollection employeeCollection, int id)
{
if (employeeFilter.Matches(name, age, isSalaried))
{
employeeCollection.Items.Add(new Employee
{
Name = name,
Id = id,
Age = age,
IsSalaried = isSalaried
});
}
}
}
}

0 comments on commit 3a769df

Please sign in to comment.