TYPE_VIKINGController.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. using CD67.ModeleMVC.Factory;
  11. namespace CD67.ModeleMVC.MVC.Controllers
  12. {
  13. public class TYPE_VIKINGController : Controller
  14. {
  15. private Entities db = new Entities();
  16. // GET: TYPE_VIKING
  17. public ActionResult Index()
  18. {
  19. TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
  20. return View(typeVikingFactory.getAll());
  21. }
  22. // GET: TYPE_VIKING/Details/5
  23. public ActionResult Details(int? id)
  24. {
  25. if (id == null)
  26. {
  27. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  28. }
  29. TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
  30. EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value);
  31. if (typeViking == null)
  32. {
  33. return HttpNotFound();
  34. }
  35. return View(typeViking);
  36. }
  37. // GET: TYPE_VIKING/Create
  38. public ActionResult Create()
  39. {
  40. EXEMPLE_TYPE_VIKING typeViking = new EXEMPLE_TYPE_VIKING();
  41. return View(typeViking);
  42. }
  43. // POST: TYPE_VIKING/Create
  44. // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour
  45. // plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
  46. [HttpPost]
  47. [ValidateAntiForgeryToken]
  48. public ActionResult Create([Bind(Include = "ID,TYPE")] EXEMPLE_TYPE_VIKING typeViking)
  49. {
  50. if (ModelState.IsValid)
  51. {
  52. TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
  53. typeVikingFactory.add(ref typeViking);
  54. return RedirectToAction("Index");
  55. }
  56. return View(typeViking);
  57. }
  58. // GET: TYPE_VIKING/Edit/5
  59. public ActionResult Edit(int? id)
  60. {
  61. if (id == null)
  62. {
  63. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  64. }
  65. TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
  66. EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value);
  67. if (typeViking == null)
  68. {
  69. return HttpNotFound();
  70. }
  71. return View(typeViking);
  72. }
  73. // POST: TYPE_VIKING/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([Bind(Include = "ID,TYPE")] EXEMPLE_TYPE_VIKING typeViking)
  79. {
  80. if (ModelState.IsValid)
  81. {
  82. TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
  83. typeVikingFactory.update(ref typeViking);
  84. return RedirectToAction("Index");
  85. }
  86. return View(typeViking);
  87. }
  88. // GET: TYPE_VIKING/Delete/5
  89. public ActionResult Delete(int? id)
  90. {
  91. if (id == null)
  92. {
  93. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  94. }
  95. TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
  96. EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value);
  97. if (typeViking == null)
  98. {
  99. return HttpNotFound();
  100. }
  101. return View(typeViking);
  102. }
  103. // POST: TYPE_VIKING/Delete/5
  104. [HttpPost, ActionName("Delete")]
  105. [ValidateAntiForgeryToken]
  106. public ActionResult DeleteConfirmed(int id)
  107. {
  108. TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
  109. EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id);
  110. typeVikingFactory.delete(ref typeViking);
  111. return RedirectToAction("Index");
  112. }
  113. protected override void Dispose(bool disposing)
  114. {
  115. if (disposing)
  116. {
  117. db.Dispose();
  118. }
  119. base.Dispose(disposing);
  120. }
  121. }
  122. }