| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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(int? 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(int? 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_old GetViewModel(Entity.ActionCLAS action, Models.ModeAcces Acces)
- {
- return new Models.CollegeViewModel_old()
- {
- College_Id = action.College.Id,
- //CodeRne = action.College.CodeRne,
- //Annee_Id = action.College.Annee_Id,
- College_Libelle = action.College.Libelle,
- Contenu = action,
- Acces = Acces,
- Listes = null
- };
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- db.Dispose();
- }
- base.Dispose(disposing);
- }
- }
- }
|