private async Task <FlightDto> CompleteFlight(FlightDto flight) { var destination = await _airportService.GetAsync(flight.DestinationAirportId); var departure = await _airportService.GetAsync(flight.DepartureAirportId); var aircraft = await _aircraftService.GetAsync(flight.AircraftId); if (destination == null || departure == null || aircraft == null) { throw new ArgumentNullException(nameof(CompleteFlight)); } flight.Distance = DistanceBetweenPlaces(departure, destination); flight.FuelConsumption = FuelConsumption(aircraft, flight.Distance); return(flight); }
public async Task <ActionResult <IEnumerable <Airports> > > Get(string key) { try { return(Ok(new Notification { Success = true, Data = await _airportService.GetAsync(key) })); } catch (Exception ex) { return(BadRequest(new Notification { Success = false, Errors = ex.Message })); } }