using MALDFGASSURANCE.Models; using System; using System.Data.Entity; using System.Linq; using System.Net; using System.Web.Mvc; namespace MALDFGASSURANCE.Areas.ADHESION.Controllers { [Authorize(Roles = "Coordonnateur")] public class FONCTIONController : Controller { private MALDFGEntities db = new MALDFGEntities(); // GET: ADHESION/FONCTION public ActionResult Index() { return View(db.FONCTION.ToList()); } // GET: ADHESION/FONCTION/Details/5 public ActionResult Details(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } FONCTION fONCTION = db.FONCTION.Find(id); if (fONCTION == null) { return HttpNotFound(); } return View(fONCTION); } // GET: ADHESION/FONCTION/Create public ActionResult Create() { return View(); } // POST: ADHESION/FONCTION/Create // Afin de déjouer les attaques par survalidation, activez les propriétés spécifiques auxquelles vous voulez établir une liaison. Pour // plus de détails, consultez https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "CODE_FONCTION,LIBELLE_FONCTION,IDUTILISATEUR,ETAT,DATECREATION,DATEMODIFICATION,DATESUPPRESSION")] FONCTION fONCTION) { if (ModelState.IsValid) { fONCTION.CODE_FONCTION = "FONC" + DateTime.Now.ToString("dd-MM-yy-HH-mm-ss"); fONCTION.IDUTILISATEUR = User.Identity.Name; fONCTION.ETAT = 1; fONCTION.DATECREATION = DateTime.Now; db.FONCTION.Add(fONCTION); db.SaveChanges(); return RedirectToAction("Index"); } return View(fONCTION); } // GET: ADHESION/FONCTION/Edit/5 public ActionResult Edit(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } FONCTION fONCTION = db.FONCTION.Find(id); if (fONCTION == null) { return HttpNotFound(); } return View(fONCTION); } // POST: ADHESION/FONCTION/Edit/5 // Afin de déjouer les attaques par survalidation, activez les propriétés spécifiques auxquelles vous voulez établir une liaison. Pour // plus de détails, consultez https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "CODE_FONCTION,LIBELLE_FONCTION,IDUTILISATEUR,ETAT,DATECREATION,DATEMODIFICATION,DATESUPPRESSION")] FONCTION fONCTION) { if (ModelState.IsValid) { fONCTION.IDUTILISATEUR = User.Identity.Name; fONCTION.DATEMODIFICATION = DateTime.Now; db.Entry(fONCTION).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(fONCTION); } // GET: ADHESION/FONCTION/Delete/5 public ActionResult Delete(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } FONCTION fONCTION = db.FONCTION.Find(id); if (fONCTION == null) { return HttpNotFound(); } return View(fONCTION); } // POST: ADHESION/FONCTION/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(string id) { FONCTION fONCTION = db.FONCTION.Find(id); db.FONCTION.Remove(fONCTION); db.SaveChanges(); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); } } }