public async Task <EmployeeModel> GetEmployeeByEmployeeId(string companyName, int employeeId, CancellationToken token) { Logger.LogInformation("Request for employee ID '{EmployeeID}' for company: {Company}", employeeId, 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 employee = await EmployeeRepository.GetEmployeeByEmployeeId(company.Id, employeeId, token).ConfigureAwait(false); if (employee == null) { // throw some kind of 'NotFound' exception to controller Logger.LogInformation("Company '{Company}' employee ID not found: {EmployeeID}", companyName, employeeId); throw new Exception(); } return(new EmployeeModel { EmployeeId = employee.EmployeeId, LastName = employee.LastName, FirstName = employee.FirstName, SocialSecurity = employee.SocialSecurity, HireDate = employee.HireDate, ManagerEmployeeId = employee.ManagerEmployeeId, }); }