Example #1
0
        public ActionResult Edit(Flight flight)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _flightService.UpdateFlight(flight);

                    return(RedirectToAction("Index"));
                }
                return(View(flight));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <IActionResult> UpdateFlightPost(FlightDto flight)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var flightArgs = new UpdateFlightArgs
            {
                Id                   = flight.Id,
                FlightNumber         = flight.FlightNumber,
                DepartureAirportId   = flight.DepartureAirportId,
                DestinationAirportId = flight.DestinationAirportId,
                FlightDate           = flight.FlightDate,
                FlightTime           = flight.FlightTime,
                AircraftId           = flight.AircraftId
            };

            var updatedFlight = await _flightServices.UpdateFlight(flightArgs);

            return(RedirectToAction("index"));
        }