Esempio n. 1
0
        public GetAllEmployersDataQueryResponse Handle(GetAllEmployersDataQuery query)
        {
            using (var context = new EmploymentDataDbContext())
            {
                var employers = context.Employers.Include(e => e.Employees).ToList();

                var employersSummaryList = new GetAllEmployersDataQueryResponse();
                employersSummaryList.Data =
                    employers.Select(
                        e =>
                        new EmployerSummaryData()
                {
                    EmployerId   = e.Id,
                    EmployerName = e.Name,
                    TotalSalary  = e.Employees.Sum(ee => ee.Salary)
                }).ToList();

                return(employersSummaryList);
            }
        }
Esempio n. 2
0
 public GetAllEmployersDataQueryResponse Handle(GetAllEmployersDataQuery query)
 {
     return((new QueryHandler()).Handle(query));
 }