public ActionResult Create(Car car) { try { int id = _cars.Count > 0 ? _cars.Max(c => c.Id) + 1 : 1; car.Id = id; _cars.Add(car); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, Car car) { try { _cars.RemoveAll(x => x.Id == id); _cars.Add(car); return RedirectToAction("Index"); } catch { return View(); } }