| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 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;
- using CD67.FicheCollege.MVC.Models;
- 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);
- ActionCLAS actionClas = actionClasFactory.getById(id);
- if (actionClas == null)
- {
- return HttpNotFound();
- }
- ActionClasViewModel model = new ActionClasViewModel(actionClas);
- return View(model);
- }
- // 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();
- }
- ActionClasViewModel model = new ActionClasViewModel(actionClas, ModeAcces.Modification);
- return View(model);
- }
- // 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 actionClas)
- {
- if (ModelState.IsValid)
- {
- ActionCLASFactory actionClasFactory = new ActionCLASFactory(db);
- actionClasFactory.update(ref actionClas);
- return RedirectToAction("Details", new { id = actionClas.College_Id });
- }
- db.Entry(actionClas).Reference(i => i.College).Load();
- ActionClasViewModel model = new ActionClasViewModel(actionClas, ModeAcces.Modification);
- return View(model);
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- db.Dispose();
- }
- base.Dispose(disposing);
- }
- }
- }
|