//
 // GET: /DriverOffence/Details/5
 public ViewResult Details(int id)
 {
     //DriverOffence driveroffence = db.DriverOffences.Find(id);
     //return View(driveroffence);
     DriverOffenceDAL dal = new DriverOffenceDAL();
     DriverOffence driveroffence = dal.DriverOffenceFindById(id);
     return View(driveroffence);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            // DriverOffence driveroffence = db.DriverOffences.Find(id);
            // db.DriverOffences.Remove(driveroffence);
            // db.SaveChanges();
            // return RedirectToAction("Index");

            DriverOffenceDAL dal = new DriverOffenceDAL();
            DriverOffence driveroffence = dal.DeleteDriverOffenceById(id);
            return RedirectToAction("Index");
        }
 public ActionResult Create(DriverOffence driveroffence)
 {
     if (ModelState.IsValid)
     {
         // db.DriverOffences.Add(driveroffence);
         // db.SaveChanges();
         // return RedirectToAction("Index");
         DriverOffenceDAL dal = new DriverOffenceDAL();
         dal.CreateDriverOffence(driveroffence);
         return RedirectToAction("Index");
     }
     return View(driveroffence);
 }
        //
        // GET: /DriverOffence/Edit/5
        public ActionResult Edit(int id)
        {
            //DriverOffence driveroffence = db.DriverOffences.Find(id);
            //return View(driveroffence);

            DriverOffenceDAL dal = new DriverOffenceDAL();
            DriverOffence driveroffence = dal.DriverOffenceFindById(id);
            return View(driveroffence);
        }
        //
        // GET: /DriverOffence/
        public ViewResult Index()
        {
            //return View(db.DriverOffences.ToList());

            DriverOffenceDAL dal = new DriverOffenceDAL();
            List<DriverOffence> driveroffence = dal.ListOfDriverOffences();
            return View(driveroffence);
        }
        public ActionResult Edit(DriverOffence driveroffence)
        {
            if (ModelState.IsValid)
            {
                db.Entry(driveroffence).State = EntityState.Modified;
                //db.SaveChanges();
                //return RedirectToAction("Index");

                DriverOffenceDAL dal = new DriverOffenceDAL();
                dal.EditDriverOffence(driveroffence);
                return RedirectToAction("Index");
            }
            return View(driveroffence);
        }