public ActionResult Edit(int id) { Flights flights = flightRepository.GetFlightById(id); if (flights == null) { return(HttpNotFound()); } ViewBag.CompanyId = new SelectList(db.Companies, "Id", "Name", flights.CompanyId); ViewBag.StatusId = new SelectList(db.Statuses, "StatusId", "Name", flights.StatusId); return(View(flights)); }