using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; using CD67.ModeleMVC.Entity; using CD67.ModeleMVC.Factory; namespace CD67.ModeleMVC.MVC.Controllers { public class PARAMsController : Controller { private Entities db = new Entities(); // GET: PARAMs public ActionResult Index() { PARAMFactory paramFactory = new PARAMFactory(db); return View(paramFactory.getAll()); } // GET: PARAMs/Details/5 public ActionResult Details(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } PARAMFactory paramFactory = new PARAMFactory(db); PARAM param = paramFactory.getById(id); if (param == null) { return HttpNotFound(); } return View(param); } // GET: PARAMs/Create public ActionResult Create() { PARAM param = new PARAM(); return View(param); } // POST: PARAMs/Create // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour // plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "PRM_CLE,PRM_LIB1,PRM_LIB2")] PARAM param) { if (ModelState.IsValid) { PARAMFactory paramFactory = new PARAMFactory(db); paramFactory.add(ref param); return RedirectToAction("Index"); } return View(param); } // GET: PARAMs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } PARAMFactory paramFactory = new PARAMFactory(db); PARAM param = paramFactory.getById(id); if (param == null) { return HttpNotFound(); } return View(param); } // POST: PARAMs/Edit/5 // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour // plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "PRM_CLE,PRM_LIB1,PRM_LIB2")] PARAM param) { if (ModelState.IsValid) { PARAMFactory paramFactory = new PARAMFactory(db); paramFactory.update(ref param); return RedirectToAction("Index"); } return View(param); } // GET: PARAMs/Delete/5 public ActionResult Delete(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } PARAMFactory paramFactory = new PARAMFactory(db); PARAM param = paramFactory.getById(id); if (param == null) { return HttpNotFound(); } return View(param); } // POST: PARAMs/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(string id) { PARAMFactory paramFactory = new PARAMFactory(db); PARAM param = paramFactory.getById(id); paramFactory.delete(ref param); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); } } }