public async Task <IActionResult> Put([FromRoute] int id, [FromBody] UpdateFlightRequest request) { var flight = new Flight { Id = id, Departure = DateTime.ParseExact(request.Departure, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture), FromId = request.FromId, ToId = request.ToId }; if (await _flightService.UpdateFlightAsync(flight)) { return(Ok(new FlightResponse { Id = flight.Id, Departure = flight.Departure, From = new CountryResponse { Id = flight.From.Id, Name = flight.From.Name }, To = new CountryResponse { Id = flight.To.Id, Name = flight.To.Name } })); } return(NotFound()); }
public async Task <IActionResult> UpdateFlightById(int id, [FromBody] UpdateFlightRequest updateFlightRequest) { var flight = await _flService.UpdateFlightByIdAsync(id, updateFlightRequest); return(Ok(new { status = 200, data = flight, message = "Flight successfully updated" })); }
public async Task <IActionResult> CreateFlight([FromBody] UpdateFlightRequest updateFlightRequest) { var flight = await _flService.CreateFlightAsync(updateFlightRequest); return(Ok(new { status = 200, data = flight, message = "Flight successfully created" })); }