public async Task <IActionResult> SearchCustomers(string filterBy) { if (!string.IsNullOrEmpty(filterBy)) { var customer = _repo.FindCustomerByName(filterBy); if (customer.Result == null) { _logger.LogError($"Customer with First Name or Last Name: {filterBy}, Not Found."); return(NotFound($"Customer with First Name or Last Name: {filterBy}, Not Found.")); } _logger.LogInformation($"All Customers with First Name or Last Name Like {filterBy}, Returned"); return(Ok(await customer)); } try { _logger.LogInformation($"Returned all Customers from database."); return(Ok(await _repo.GetCustomers())); } catch (Exception ex) { _logger.LogError($"Something went wrong {nameof(SearchCustomers)} action: {ex.Message}"); return(StatusCode(500, "Internal server error")); } }