Exemple #1
0
        public ActionResult CreateEditCar(Car car)
        {
            if (ModelState.IsValid)
            {

                if (car.ID == 0)
                {

                    CarRepository.Insert(car);
                }
                else
                {
                    var editModel = CarRepository.GetById(car.ID);
                    editModel.Make = car.Make;
                    editModel.Model = car.Model;

                    CarRepository.Update(editModel);
                }

                if (car.ID > 0)
                {
                    return RedirectToAction("Index");
                }
            }
            return View(car);
        }
Exemple #2
0
 public ActionResult CreateEditCar(int? id)
 {
     Car model = new Car();
     if (id.HasValue)
     {
         model = CarRepository.GetById(id.Value);
     }
     return View(model);
 }