コード例 #1
0
        public async Task <IActionResult> Add()
        {
            AddFlightViewModel model    = new AddFlightViewModel();
            List <Airline>     airlines = await _airlines.GetAirlinesAsync();

            model.SetAirlines(airlines);
            return(View(model));
        }
コード例 #2
0
        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));
        }