ActionEduAxesController.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using CD67.FicheCollege.Entity;
  2. using CD67.FicheCollege.Factory;
  3. using CD67.FicheCollege.MVC.Models;
  4. using System.Net;
  5. using System.Web.Mvc;
  6. namespace CD67.FicheCollege.MVC.Controllers
  7. {
  8. public class ActionEduAxesController : Controller
  9. {
  10. private Entities db = new Entities();
  11. // GET: ActionAxes
  12. public ActionResult Index()
  13. {
  14. ActionEduAxeFactory fact = new ActionEduAxeFactory(db);
  15. ActionEduAxeIndexViewModel model = new ActionEduAxeIndexViewModel(fact.getAll());
  16. return View(model);
  17. }
  18. // GET: ActionEduAxe/Details/5
  19. public ActionResult Details(int? id)
  20. {
  21. if (id == null)
  22. {
  23. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  24. }
  25. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  26. Entity.ActionEduAxe ActionEduAxe = ActionEduAxeFactory.getById(id.Value);
  27. if (ActionEduAxe == null)
  28. {
  29. return HttpNotFound();
  30. }
  31. ActionEduAxeViewModel model = new ActionEduAxeViewModel(ActionEduAxe);
  32. return View(model);
  33. }
  34. // GET: ActionEduAxe/Create
  35. public ActionResult Create()
  36. {
  37. ActionEduAxe ActionEduAxe = new ActionEduAxe();
  38. ActionEduAxeViewModel model = new ActionEduAxeViewModel(ActionEduAxe);
  39. return View(model);
  40. }
  41. // POST: ActionEduAxe/Create
  42. // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour
  43. // plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
  44. [HttpPost]
  45. [ValidateAntiForgeryToken]
  46. public ActionResult Create(ActionEduAxe ActionEduAxe)
  47. {
  48. if (ModelState.IsValid)
  49. {
  50. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  51. ActionEduAxeFactory.add(ref ActionEduAxe);
  52. return RedirectToAction("Index");
  53. }
  54. ActionEduAxeViewModel model = new ActionEduAxeViewModel(ActionEduAxe);
  55. return View(model);
  56. }
  57. // GET: ActionEduAxe/Edit/5
  58. public ActionResult Edit(int? id)
  59. {
  60. if (id == null)
  61. {
  62. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  63. }
  64. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  65. Entity.ActionEduAxe ActionEduAxe = ActionEduAxeFactory.getById(id.Value);
  66. if (ActionEduAxe == null)
  67. {
  68. return HttpNotFound();
  69. }
  70. ActionEduAxeViewModel model = new ActionEduAxeViewModel(ActionEduAxe);
  71. return View(model);
  72. }
  73. // POST: ActionEduAxe/Edit/5
  74. // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour
  75. // plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
  76. [HttpPost]
  77. [ValidateAntiForgeryToken]
  78. public ActionResult Edit(ActionEduAxe ActionEduAxe)
  79. {
  80. if (ModelState.IsValid)
  81. {
  82. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  83. ActionEduAxeFactory.update(ref ActionEduAxe);
  84. return RedirectToAction("Index");
  85. }
  86. ActionEduAxeViewModel model = new ActionEduAxeViewModel(ActionEduAxe);
  87. return View(model);
  88. }
  89. // GET: ActionEduAxe/Delete/5
  90. public ActionResult Delete(int? id)
  91. {
  92. if (id == null)
  93. {
  94. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  95. }
  96. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  97. Entity.ActionEduAxe ActionEduAxe = ActionEduAxeFactory.getById(id.Value);
  98. if (ActionEduAxe == null)
  99. {
  100. return HttpNotFound();
  101. }
  102. ActionEduAxeViewModel model = new ActionEduAxeViewModel(ActionEduAxe);
  103. return View(model);
  104. }
  105. // POST: ActionEduAxe/Delete/5
  106. [HttpPost, ActionName("Delete")]
  107. [ValidateAntiForgeryToken]
  108. public ActionResult DeleteConfirmed(int id)
  109. {
  110. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  111. Entity.ActionEduAxe ActionEduAxe = ActionEduAxeFactory.getById(id);
  112. ActionEduAxeFactory.delete(ref ActionEduAxe);
  113. return RedirectToAction("Index");
  114. }
  115. public ActionResult Up(int? id)
  116. {
  117. if (id == null)
  118. {
  119. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  120. }
  121. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  122. Entity.ActionEduAxe ActionEduAxe = ActionEduAxeFactory.getById(id.Value);
  123. ActionEduAxeFactory.Up(ref ActionEduAxe);
  124. return RedirectToAction("Index");
  125. }
  126. public ActionResult Down(int? id)
  127. {
  128. if (id == null)
  129. {
  130. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  131. }
  132. ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
  133. Entity.ActionEduAxe ActionEduAxe = ActionEduAxeFactory.getById(id.Value);
  134. ActionEduAxeFactory.Down(ref ActionEduAxe);
  135. return RedirectToAction("Index");
  136. }
  137. protected override void Dispose(bool disposing)
  138. {
  139. if (disposing)
  140. {
  141. db.Dispose();
  142. }
  143. base.Dispose(disposing);
  144. }
  145. }
  146. }