Exemplo n.º 1
0
        public GetAllCategoriesResponse GetAllCategories()
        {
            GetAllCategoriesResponse response = new GetAllCategoriesResponse();

            response.Categories = _categoryRepository.FindAll().Select(c => _mapper.Map <Category, CategoryView>(c));

            return(response);
        }
Exemplo n.º 2
0
        private void DumpPeople(IReadOnlyRepository <Person> employeeRepository)
        {
            var employees = employeeRepository.FindAll();

            foreach (var employee in employees)
            {
                Console.WriteLine(employee.Name);
            }
        }
Exemplo n.º 3
0
        private static void FindEmployee(IReadOnlyRepository <Person> emp)
        {
            var employee = emp.FindAll();

            foreach (var e in employee)
            {
                Console.WriteLine(e.Name);
            }
        }
Exemplo n.º 4
0
        // 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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Finds all.
 /// </summary>
 /// <param name="active">if set to <c>true</c> [active].</param>
 /// <returns>List&lt;T&gt;.</returns>
 protected List <T> FindAll(bool active)
 {
     return(ReadOnlyRepository.FindAll().Where <T>(t => t.IsActive == active).ToList());
 }