public async Task <IActionResult> Get() { try { var result = await _airportService.GetAllAsync(); return(new OkObjectResult(result)); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest()); } }
public async Task <ActionResult> GetAllAsync(string nameFilter) { IReadOnlyCollection <BlAirport> airportsBl; if (!string.IsNullOrEmpty(nameFilter)) { airportsBl = await _airportService.SearchByNameAsync(nameFilter); } else { airportsBl = await _airportService.GetAllAsync(); } IEnumerable <Airport> airports = airportsBl.Select(_mapper.Map <Airport>); return(Ok(airports)); }