public async Task <IActionResult> Add() { AddFlightViewModel model = new AddFlightViewModel(); List <Airline> airlines = await _airlines.GetAirlinesAsync(); model.SetAirlines(airlines); return(View(model)); }
public async Task <IActionResult> Add(AddFlightViewModel model) { if (ModelState.IsValid) { string number = model.FlightNumber; await _flights.AddFlightAsync(number, model.Embarkation, model.Destination, model.AirlineId); ModelState.Clear(); model.Clear(); model.Message = $"Flight '{number}' added successfully"; } List <Airline> airlines = await _airlines.GetAirlinesAsync(); model.SetAirlines(airlines); return(View(model)); }