Esempio n. 1
0
        public ActionResult Create(car car)
        {
            if (!LoginController.IsAdmin())
                return View("~/Views/Login/Index.cshtml");

            using (_db) {
                _db.cars.Add(car);
                _db.SaveChanges();
            }

            return RedirectToAction("Index");
        }
Esempio n. 2
0
        public ActionResult Edit(car formCar)
        {
            if (!LoginController.IsAdmin())
                return View("~/Views/Login/Index.cshtml");

            using (_db)
            {
                car car = _db.cars.FirstOrDefault(c => c.Id == formCar.Id);

                car.Hauler = formCar.Hauler;
                car.Licenseplate = formCar.Licenseplate;
                car.RouteNo = formCar.RouteNo;
                car.Position = formCar.Position;

                _db.SaveChanges();

                return RedirectToAction("Index", new { succes = 1 });
            }
        }