PARAMsController.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.Entity;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using CD67.ModeleMVC.Entity;
  10. namespace CD67.ModeleMVC.MVC.Controllers
  11. {
  12. public class PARAMsController : Controller
  13. {
  14. private Entities db = new Entities();
  15. // GET: PARAMs
  16. public ActionResult Index()
  17. {
  18. return View(db.PARAM.ToList());
  19. }
  20. // GET: PARAMs/Details/5
  21. public ActionResult Details(string id)
  22. {
  23. if (id == null)
  24. {
  25. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  26. }
  27. PARAM pARAM = db.PARAM.Find(id);
  28. if (pARAM == null)
  29. {
  30. return HttpNotFound();
  31. }
  32. return View(pARAM);
  33. }
  34. // GET: PARAMs/Create
  35. public ActionResult Create()
  36. {
  37. return View();
  38. }
  39. // POST: PARAMs/Create
  40. // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour
  41. // plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
  42. [HttpPost]
  43. [ValidateAntiForgeryToken]
  44. public ActionResult Create([Bind(Include = "PRM_CLE,PRM_LIB1,PRM_LIB2")] PARAM pARAM)
  45. {
  46. if (ModelState.IsValid)
  47. {
  48. db.PARAM.Add(pARAM);
  49. db.SaveChanges();
  50. return RedirectToAction("Index");
  51. }
  52. return View(pARAM);
  53. }
  54. // GET: PARAMs/Edit/5
  55. public ActionResult Edit(string id)
  56. {
  57. if (id == null)
  58. {
  59. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  60. }
  61. PARAM pARAM = db.PARAM.Find(id);
  62. if (pARAM == null)
  63. {
  64. return HttpNotFound();
  65. }
  66. return View(pARAM);
  67. }
  68. // POST: PARAMs/Edit/5
  69. // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour
  70. // plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
  71. [HttpPost]
  72. [ValidateAntiForgeryToken]
  73. public ActionResult Edit([Bind(Include = "PRM_CLE,PRM_LIB1,PRM_LIB2")] PARAM pARAM)
  74. {
  75. if (ModelState.IsValid)
  76. {
  77. db.Entry(pARAM).State = EntityState.Modified;
  78. db.SaveChanges();
  79. return RedirectToAction("Index");
  80. }
  81. return View(pARAM);
  82. }
  83. // GET: PARAMs/Delete/5
  84. public ActionResult Delete(string id)
  85. {
  86. if (id == null)
  87. {
  88. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  89. }
  90. PARAM pARAM = db.PARAM.Find(id);
  91. if (pARAM == null)
  92. {
  93. return HttpNotFound();
  94. }
  95. return View(pARAM);
  96. }
  97. // POST: PARAMs/Delete/5
  98. [HttpPost, ActionName("Delete")]
  99. [ValidateAntiForgeryToken]
  100. public ActionResult DeleteConfirmed(string id)
  101. {
  102. PARAM pARAM = db.PARAM.Find(id);
  103. db.PARAM.Remove(pARAM);
  104. db.SaveChanges();
  105. return RedirectToAction("Index");
  106. }
  107. protected override void Dispose(bool disposing)
  108. {
  109. if (disposing)
  110. {
  111. db.Dispose();
  112. }
  113. base.Dispose(disposing);
  114. }
  115. }
  116. }