|
|
@@ -0,0 +1,87 @@
|
|
|
+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 ActionsCLASController : Controller
|
|
|
+ {
|
|
|
+ private Entities db = new Entities();
|
|
|
+
|
|
|
+ // GET: ActionCLAS/Details/5
|
|
|
+ public ActionResult Details(string id)
|
|
|
+ {
|
|
|
+ if (id == null)
|
|
|
+ {
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
+ }
|
|
|
+ ActionCLASFactory actionClasFactory = new ActionCLASFactory(db);
|
|
|
+ Entity.ActionCLAS actionClas = actionClasFactory.getById(id);
|
|
|
+ if (actionClas == null)
|
|
|
+ {
|
|
|
+ return HttpNotFound();
|
|
|
+ }
|
|
|
+ return View(GetViewModel(actionClas, Models.ModeAcces.Lecture));
|
|
|
+ }
|
|
|
+
|
|
|
+ // GET: ActionCLAS/Edit/5
|
|
|
+ public ActionResult Edit(string id)
|
|
|
+ {
|
|
|
+ if (id == null)
|
|
|
+ {
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
+ }
|
|
|
+ ActionCLASFactory actionClasFactory = new ActionCLASFactory(db);
|
|
|
+ Entity.ActionCLAS actionClas = actionClasFactory.getById(id);
|
|
|
+ if (actionClas == null)
|
|
|
+ {
|
|
|
+ return HttpNotFound();
|
|
|
+ }
|
|
|
+ return View(GetViewModel(actionClas, Models.ModeAcces.Modification));
|
|
|
+ }
|
|
|
+
|
|
|
+ // POST: ActionCLAS/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(ActionCLAS Contenu)
|
|
|
+ {
|
|
|
+ if (ModelState.IsValid)
|
|
|
+ {
|
|
|
+ ActionCLASFactory actionClasFactory = new ActionCLASFactory(db);
|
|
|
+ actionClasFactory.update(ref Contenu);
|
|
|
+ return RedirectToAction("Index");
|
|
|
+ }
|
|
|
+ return View(GetViewModel(Contenu, Models.ModeAcces.Modification));
|
|
|
+ }
|
|
|
+
|
|
|
+ private Models.CollegeViewModel GetViewModel(Entity.ActionCLAS entity, Models.ModeAcces Acces)
|
|
|
+ {
|
|
|
+ return new Models.CollegeViewModel()
|
|
|
+ {
|
|
|
+ College_Id = entity.College.Id,
|
|
|
+ College_Libelle = entity.College.Libelle,
|
|
|
+ Contenu = entity,
|
|
|
+ Acces = Acces,
|
|
|
+ Listes = null
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void Dispose(bool disposing)
|
|
|
+ {
|
|
|
+ if (disposing)
|
|
|
+ {
|
|
|
+ db.Dispose();
|
|
|
+ }
|
|
|
+ base.Dispose(disposing);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|