RestaurationController.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 RestaurationController : Controller
  9. {
  10. private Entities db = new Entities();
  11. // GET: Actions
  12. public ActionResult Index(int? annee_id)
  13. {
  14. if (annee_id == null)
  15. {
  16. return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  17. }
  18. AnneeFactory fact = new AnneeFactory(db);
  19. Annee annee = fact.getById(annee_id);
  20. AnneeViewModel model = new AnneeViewModel(annee, db, ModeAcces.Lecture);
  21. RestaurationParametreFactory paramFactory = new RestaurationParametreFactory(db);
  22. RestaurationParametre param = paramFactory.getBy(x => x.Annee_Id == annee_id.Value);
  23. if (param == null)
  24. ViewBag.Ouverture = false;
  25. else
  26. ViewBag.Ouverture = param.Campagne;
  27. return View(model);
  28. }
  29. protected override void Dispose(bool disposing)
  30. {
  31. if (disposing)
  32. {
  33. db.Dispose();
  34. }
  35. base.Dispose(disposing);
  36. }
  37. }
  38. }