public IActionResult Delete(ShowFlightModel model, string returnUrtl = null) { var flight = new FlightModel { Id = model.Id, }; _flights.Delete(flight); return(RedirectToAction("Index")); }
public IActionResult Delete(int id, string returnUrtl = null) { var flight = _dbContext.Flights.Find(id); var model = new ShowFlightModel { Id = flight.Id, Plane = _dbContext.Airplanes.Find(flight.AirplaneId).Model, Company = _dbContext.AviaCompanies.Find(flight.AviaCompanyId).CompanyName, HomeAirport = _dbContext.Airports.Find(flight.HomeAirportId).Name, DestinationAirport = _dbContext.Airports.Find(flight.DestinationAirportId).Name, Departure = flight.Departure, Arrival = flight.Arrival }; return(View(model)); }
public IActionResult Delete(int id, string returnUrtl = null) { var flight = _flights.Get(id); var homeAirport = _airports.Get(flight.HomeAirportId); var destAirport = _airports.Get(flight.DestinationAirportId); var company = _companies.Get(flight.AviaCompanyId); var airplane = _airplanes.Get(flight.AirplaneId); var model = new ShowFlightModel { Id = flight.Id, Plane = airplane.Model, Company = company.CompanyName, HomeAirport = homeAirport.Name, DestinationAirport = destAirport.Name, Departure = flight.Departure, Arrival = flight.Arrival }; return(View(model)); }
public IActionResult Delete(ShowFlightModel model, string returnUrtl = null) { _dbContext.Flights.Remove(_dbContext.Flights.Find(model.Id)); _dbContext.SaveChanges(); return(RedirectToAction("Index")); }