|
@@ -0,0 +1,157 @@
|
|
|
|
|
+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.FicheCollege.Entity;
|
|
|
|
|
+using CD67.FicheCollege.Factory;
|
|
|
|
|
+
|
|
|
|
|
+namespace CD67.FicheCollege.MVC.Controllers
|
|
|
|
|
+{
|
|
|
|
|
+ public class TypeCollegeController : Controller
|
|
|
|
|
+ {
|
|
|
|
|
+ private Entities db = new Entities();
|
|
|
|
|
+
|
|
|
|
|
+ // GET: TypeCollege
|
|
|
|
|
+ public ActionResult Index()
|
|
|
|
|
+ {
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ return View(typeCollegeFactory.getAll());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // GET: TypeCollege/Details/5
|
|
|
|
|
+ public ActionResult Details(int? id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (id == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
|
|
+ }
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ Entity.TypeCollege typeCollege = typeCollegeFactory.getById(id.Value);
|
|
|
|
|
+ if (typeCollege == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return HttpNotFound();
|
|
|
|
|
+ }
|
|
|
|
|
+ return View(typeCollege);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // GET: TypeCollege/Create
|
|
|
|
|
+ public ActionResult Create()
|
|
|
|
|
+ {
|
|
|
|
|
+ Entity.TypeCollege typeCollege = new Entity.TypeCollege();
|
|
|
|
|
+ return View(typeCollege);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // POST: TypeCollege/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(TypeCollege typeCollege)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (ModelState.IsValid)
|
|
|
|
|
+ {
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ typeCollegeFactory.add(ref typeCollege);
|
|
|
|
|
+ return RedirectToAction("Index");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return View(typeCollege);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // GET: TypeCollege/Edit/5
|
|
|
|
|
+ public ActionResult Edit(int? id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (id == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
|
|
+ }
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ Entity.TypeCollege typeCollege = typeCollegeFactory.getById(id.Value);
|
|
|
|
|
+ if (typeCollege == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return HttpNotFound();
|
|
|
|
|
+ }
|
|
|
|
|
+ return View(typeCollege);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // POST: TypeCollege/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(TypeCollege typeCollege)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (ModelState.IsValid)
|
|
|
|
|
+ {
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ typeCollegeFactory.update(ref typeCollege);
|
|
|
|
|
+ return RedirectToAction("Index");
|
|
|
|
|
+ }
|
|
|
|
|
+ return View(typeCollege);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // GET: TypeCollege/Delete/5
|
|
|
|
|
+ public ActionResult Delete(int? id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (id == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
|
|
+ }
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ Entity.TypeCollege typeCollege = typeCollegeFactory.getById(id.Value);
|
|
|
|
|
+ if (typeCollege == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return HttpNotFound();
|
|
|
|
|
+ }
|
|
|
|
|
+ return View(typeCollege);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // POST: TypeCollege/Delete/5
|
|
|
|
|
+ [HttpPost, ActionName("Delete")]
|
|
|
|
|
+ [ValidateAntiForgeryToken]
|
|
|
|
|
+ public ActionResult DeleteConfirmed(int id)
|
|
|
|
|
+ {
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ Entity.TypeCollege typeCollege = typeCollegeFactory.getById(id);
|
|
|
|
|
+ typeCollegeFactory.delete(ref typeCollege);
|
|
|
|
|
+ return RedirectToAction("Index");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ActionResult Up(int? id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (id == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
|
|
+ }
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ Entity.TypeCollege typeCollege = typeCollegeFactory.getById(id.Value);
|
|
|
|
|
+ typeCollegeFactory.Up(ref typeCollege);
|
|
|
|
|
+ return RedirectToAction("Index");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ActionResult Down(int? id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (id == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
|
|
+ }
|
|
|
|
|
+ TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
|
|
|
|
|
+ Entity.TypeCollege typeCollege = typeCollegeFactory.getById(id.Value);
|
|
|
|
|
+ typeCollegeFactory.Down(ref typeCollege);
|
|
|
|
|
+ return RedirectToAction("Index");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ protected override void Dispose(bool disposing)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (disposing)
|
|
|
|
|
+ {
|
|
|
|
|
+ db.Dispose();
|
|
|
|
|
+ }
|
|
|
|
|
+ base.Dispose(disposing);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|