Exemplo n.º 1
0
 public ActionResult Add(Vehicle model)
 {
     if (ModelState.IsValid)
     {
         using (RentACarDBContext db = new RentACarDBContext())
         {
             db.Vehicle.Add(model);
             db.SaveChanges();
         }
     }
     return(RedirectToAction("List", "Vehicle"));
 }
Exemplo n.º 2
0
        public ActionResult Rent(Rent model)
        {
            using (RentACarDBContext db = new RentACarDBContext())
            {
                db.Rent.Add(model);
                db.Vehicle.
                FirstOrDefault(v => v.VehicleID == model.VehicleID).
                IsRented = true;

                db.SaveChanges();
            }
            return(RedirectToAction("List", "Vehicle"));
        }
Exemplo n.º 3
0
        // Araç Silme İşlemi
        public ActionResult Delete(int id)
        {
            using (RentACarDBContext db = new RentACarDBContext())
            {
                // Gelen id'ye ait aracı getirir ve IsDeleted özelliği true
                // yapıp listede görülmesini engeller
                var result = db.Vehicle.Find(id);
                result.IsDeleted = true;
                db.SaveChanges();

                return(RedirectToAction("List", "Vehicle"));
            }
        }