public GetAllCategoriesResponse GetAllCategories() { GetAllCategoriesResponse response = new GetAllCategoriesResponse(); response.Categories = _categoryRepository.FindAll().Select(c => _mapper.Map <Category, CategoryView>(c)); return(response); }
private void DumpPeople(IReadOnlyRepository <Person> employeeRepository) { var employees = employeeRepository.FindAll(); foreach (var employee in employees) { Console.WriteLine(employee.Name); } }
private static void FindEmployee(IReadOnlyRepository <Person> emp) { var employee = emp.FindAll(); foreach (var e in employee) { Console.WriteLine(e.Name); } }
// Should be able to pass in Person OR Employee - this only works when GETTING/IEnumerating // but NOT adding, it doesn't make sense to Add() Person as Employee or do some other processing // that Employee should not be doing // However enumerating is OK // 'out' keyword // Covariance => treat Employee as Person public static void DumpPeople(IReadOnlyRepository <Employee> empRepository) { var emps = empRepository.FindAll(); foreach (var employee in emps) { Console.WriteLine(employee); } }
private static void DumpPeople(IReadOnlyRepository <Person> employeeRepository) { Console.WriteLine("Give me all the employee and write out all employees - Dump People Method"); var employees = employeeRepository.FindAll(); foreach (var employee in employees) { Console.WriteLine(employee.Name); } }
private static void DumpPeople(IReadOnlyRepository <Person> employeeRepository) { //Covariance: //Take a type that uses Employee and treat it as if it is using Person. var employees = employeeRepository.FindAll(); foreach (var employee in employees) { Console.WriteLine(employee.Name); } }
public static void DumpItems <T>(IReadOnlyRepository <T> repository, Action <T> print = null) where T : class { if (print == null) { print = Console.WriteLine; } var result = repository.FindAll(); foreach (var item in result) { print(item); } }
/// <summary> /// Finds all. /// </summary> /// <param name="active">if set to <c>true</c> [active].</param> /// <returns>List<T>.</returns> protected List <T> FindAll(bool active) { return(ReadOnlyRepository.FindAll().Where <T>(t => t.IsActive == active).ToList()); }