public void InsertOrUpdate(AirportChart airportchart) { if (airportchart.ID == default(int)) { // New entity context.AirportChart.Add(airportchart); } else { // Existing entity context.AirportChart.Attach(airportchart); context.Entry(airportchart).State = EntityState.Modified; } }
public ActionResult Create(AirportChart airportchart) { if (ModelState.IsValid) { airportchartRepository.InsertOrUpdate(airportchart); airportchartRepository.Save(); return RedirectToAction("Index"); } else { ViewBag.PossibleAirport = airportRepository.All; return View(); } }