예제 #1
0
        public async Task <CompanySearchDTO> SearchCompany(SearchCompanyQuery query)
        {
            var result = await _companiesRepository.Search(query);

            var companies = new CompanySearchDTO()
            {
                Results = result.Select(c =>
                {
                    var company = new CompanyDTO()
                    {
                        EstablishmentYear = c.EstablishmentYear,
                        Name      = c.Name,
                        Employees = c.Employees.Select(e =>
                        {
                            var employee = new EmployeeDTO()
                            {
                                DateOfBirth = e.DateOfBirth,
                                FirstName   = e.FirstName,
                                LastName    = e.LastName,
                                JobTitle    = e.JobTitle.ToString("g")
                            };
                            return(employee);
                        }).ToList()
                    };
                    return(company);
                })
            };

            return(companies);
        }