AnneesController.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Web.Mvc;
  2. using System.Net;
  3. using CD67.FicheCollege.Factory;
  4. using CD67.FicheCollege.Entity;
  5. using CD67.FicheCollege.MVC.Models;
  6. using System.Collections.Generic;
  7. namespace CD67.FicheCollege.MVC.Controllers
  8. {
  9. public class AnneesController : Controller
  10. {
  11. private Entities db = new Entities();
  12. // GET: Annees
  13. public ActionResult Index()
  14. {
  15. AnneeFactory fact = new AnneeFactory(db);
  16. AnneeIndexViewModel model = new AnneeIndexViewModel(fact.getAll());
  17. return View(model);
  18. }
  19. // GET: Home
  20. public ActionResult Details(int? id)
  21. {
  22. if (id == null)
  23. {
  24. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  25. }
  26. AnneeFactory anneeFactory = new AnneeFactory(db);
  27. Entity.Annee annee = anneeFactory.getById(id);
  28. if (annee == null)
  29. {
  30. return HttpNotFound();
  31. }
  32. AnneeViewModel model = new AnneeViewModel(annee, db);
  33. return View(model);
  34. }
  35. public ActionResult Previous(int? id)
  36. {
  37. if (id == null)
  38. {
  39. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  40. }
  41. AnneeFactory anneeFactory = new AnneeFactory(db);
  42. Entity.Annee annee = anneeFactory.getById(id);
  43. if (annee == null)
  44. {
  45. return HttpNotFound();
  46. }
  47. AnneeViewModel model = new AnneeViewModel(annee, db);
  48. return View(model);
  49. }
  50. public ActionResult Next(int? id)
  51. {
  52. if (id == null)
  53. {
  54. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  55. }
  56. AnneeFactory anneeFactory = new AnneeFactory(db);
  57. Entity.Annee annee = anneeFactory.getById(id);
  58. if (annee == null)
  59. {
  60. return HttpNotFound();
  61. }
  62. AnneeViewModel model = new AnneeViewModel(annee, db);
  63. return View(model);
  64. }
  65. }
  66. }