Пример #1
0
 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();
     }
 }
Пример #2
0
 public ActionResult Edit(int id, Car car)
 {
     try
     {
         _cars.RemoveAll(x => x.Id == id);
         _cars.Add(car);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }