| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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 IdentitesController : Controller
- {
- private Entities db = new Entities();
- // GET: Identite/Details/5
- public ActionResult Details(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- IdentiteFactory identiteFactory = new IdentiteFactory(db);
- Entity.Identite identite = identiteFactory.getById(id);
- if (identite == null)
- {
- return HttpNotFound();
- }
- IdentiteViewModel model = new IdentiteViewModel(identite);
- return View(model);
- }
- // GET: Identite/Edit/5
- public ActionResult Edit(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- IdentiteFactory identiteFactory = new IdentiteFactory(db);
- Entity.Identite identite = identiteFactory.getById(id);
- if (identite == null)
- {
- return HttpNotFound();
- }
- IdentiteViewModel model = new IdentiteViewModel(identite, ModeAcces.Modification);
- return View(model);
- }
- // POST: Identite/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(Entity.Identite identite)
- {
- if (ModelState.IsValid)
- {
- IdentiteFactory identiteFactory = new IdentiteFactory(db);
- identiteFactory.update(ref identite);
- return RedirectToAction("Details", new { Id = identite.College_Id });
- }
- IdentiteViewModel model = new IdentiteViewModel(identite, ModeAcces.Modification);
- return View(model);
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- db.Dispose();
- }
- base.Dispose(disposing);
- }
- }
- }
|