public async Task <IEnumerable <EmployeeModel> > GetEmployeesByCompanyName(string companyName, CancellationToken token) { Logger.LogInformation("Requested employees for company: {Company}", companyName); var company = await CompanyRepository.GetCompanyByName(companyName, token).ConfigureAwait(false); if (company == null) { // throw some kind of 'NotFound' exception to controller Logger.LogInformation("Company not found: {Company}", companyName); throw new Exception(); } var employees = await EmployeeRepository.GetEmployees(company.Id, token).ConfigureAwait(false); Logger.LogDebug("Found {Count} employees for company: {Company}", employees.Count, companyName); return(employees.OrderBy(x => x.EmployeeId).Select(y => new EmployeeModel { EmployeeId = y.EmployeeId, LastName = y.LastName, FirstName = y.FirstName, SocialSecurity = y.SocialSecurity, HireDate = y.HireDate, ManagerEmployeeId = y.ManagerEmployeeId, })); }