using System.Net; using System.Web.Mvc; using CD67.ModeleMVC.Entity; using CD67.ModeleMVC.Factory; using CD67.ModeleMVC.MVC.Internal; namespace CD67.ModeleMVC.MVC.Controllers { public class TYPE_VIKINGController : Controller { private Entities db = new Entities(); // GET: TYPE_VIKING public ActionResult Index() { TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db); return View(typeVikingFactory.getAll()); } // GET: TYPE_VIKING/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db); EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value); if (typeViking == null) { return HttpNotFound(); } return View(typeViking); } // GET: TYPE_VIKING/Create public ActionResult Create() { EXEMPLE_TYPE_VIKING typeViking = new EXEMPLE_TYPE_VIKING(); return View(typeViking); } // POST: TYPE_VIKING/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 = "ID,TYPE")] EXEMPLE_TYPE_VIKING typeViking) { if (ModelState.IsValid) { TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db); typeVikingFactory.add(ref typeViking); // Ajout d'un message flash this.Success("Type de viking créé avec succès."); return RedirectToAction("Index"); } return View(typeViking); } // GET: TYPE_VIKING/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db); EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value); if (typeViking == null) { return HttpNotFound(); } return View(typeViking); } // POST: TYPE_VIKING/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 = "ID,TYPE")] EXEMPLE_TYPE_VIKING typeViking) { if (ModelState.IsValid) { TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db); typeVikingFactory.update(ref typeViking); // Ajout d'un message flash this.Success("Type de viking edité avec succès."); return RedirectToAction("Index"); } return View(typeViking); } // GET: TYPE_VIKING/Delete/5 public ActionResult Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db); EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value); if (typeViking == null) { return HttpNotFound(); } return View(typeViking); } // POST: TYPE_VIKING/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db); EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id); typeVikingFactory.delete(ref typeViking); // Ajout d'un message flash this.Success("Type de viking supprimé avec succès."); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); } } }