Esempio n. 1
0
 //mapper to convert from viewmodel to domain model 
 public static Models.Car MapCarAddEditToCar(CarAddEdit caraddedit)
 {
     var car = new Models.Car();
     car.CarId = caraddedit.CarId;
     car.Make = caraddedit.Make;
     car.Model = caraddedit.Model;
     return car;
 }
Esempio n. 2
0
 //mapper to convert from domain model to viewmodel - would be easier with Automapper 
 public static CarAddEdit MapCarToCarAddEdit(Models.Car car)
 {
     var caraddedit = new CarAddEdit();
     caraddedit.CarId = car.CarId;
     caraddedit.Make = car.Make;
     caraddedit.Model = car.Model;
     return caraddedit;
 }
Esempio n. 3
0
        //mapper to convert from viewmodel to domain model
        public static Models.Car MapCarAddEditToCar(CarAddEdit caraddedit)
        {
            var car = new Models.Car();

            car.CarId = caraddedit.CarId;
            car.Make  = caraddedit.Make;
            car.Model = caraddedit.Model;
            return(car);
        }
Esempio n. 4
0
        //mapper to convert from domain model to viewmodel
        public static CarAddEdit MapCarToCarAddEdit(Models.Car car)
        {
            var caraddedit = new CarAddEdit();

            caraddedit.CarId = car.CarId;
            caraddedit.Make  = car.Make;
            caraddedit.Model = car.Model;
            return(caraddedit);
        }
        public ActionResult Edit(CarAddEdit viewmodel)
        {
            if (ModelState.IsValid)
            {
                using (_connection = Utilities.GetOpenConnection())
                {
                    _connection.Update(CarAddEdit.MapCarAddEditToCar(viewmodel));
                }
                return RedirectToAction("index");
            }

            return View(viewmodel);
        }
 public ActionResult Create(CarAddEdit viewmodel)
 {
     if (ModelState.IsValid)
     {
         //manual mapping - this would be easier with automapper
         var car = CarAddEdit.MapCarAddEditToCar(viewmodel);
         using (_connection = Utilities.GetOpenConnection())
         {
             _connection.Insert(car);
         }
         return RedirectToAction("index");
     }
     return View(viewmodel);
 }