Ejemplo n.º 1
0
        public ActionResult Create(CarViewModel car)
        {
            if (ModelState.IsValid)
            {
                _carHandler.Add(car.CreateCarDomain());
                _carHandler.Commit();
                return(RedirectToAction("Index"));
            }

            return(View(car));
        }
Ejemplo n.º 2
0
 public ActionResult Edit(CarViewModel car)
 {
     if (ModelState.IsValid)
     {
         //db.Entry(car).State = EntityState.Modified;
         //db.SaveChanges();
         _carHandler.Update(car.CreateCarDomain());
         _carHandler.Commit();
         return(RedirectToAction("Index"));
     }
     return(View(car));
 }
Ejemplo n.º 3
0
 public string Create(CarViewModel car)
 {
     if (ModelState.IsValid)
     {
         if (!String.IsNullOrEmpty(car.Make) && !String.IsNullOrEmpty(car.Model))
         {
             _carHandler.Add(car.CreateCarDomain());
             _carHandler.Commit();
             //return RedirectToAction("Index");
             return("Thank you " + car.Make + "  " + car.Model + ". Record Saved.");
         }
     }
     return("Please complete the form.");
 }
Ejemplo n.º 4
0
        public ActionResult Borrow(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //CarViewModel car = db.Cars.Find(id);
            CarViewModel car = _carHandler.GetById(id.Value).CreateCarViewModel();

            if (car == null)
            {
                return(HttpNotFound());
            }
            car.Available = false;
            car.CreateCarDomain().UserId = User.Identity.GetUserId();
            //db.SaveChanges();
            _carHandler.Commit();

            return(RedirectToAction("Index"));
        }