HomeController.cs 808 B

1234567891011121314151617181920212223242526272829
  1. using CD67.FicheCollege.Entity;
  2. using System;
  3. using System.Linq;
  4. using System.Web.Mvc;
  5. namespace CD67.FicheCollege.MVC.Controllers
  6. {
  7. public class HomeController : Controller
  8. {
  9. private Entities db = new Entities();
  10. // GET: Home
  11. public ActionResult Index()
  12. {
  13. string annee_lib;
  14. if (DateTime.Now.Month <= 6) {
  15. annee_lib = String.Format("{0}-{1}", DateTime.Now.Year - 1, DateTime.Now.Year);
  16. }
  17. else {
  18. annee_lib = String.Format("{0}-{1}", DateTime.Now.Year, DateTime.Now.Year + 1);
  19. }
  20. int annee_id = db.Annees.Where(a => a.Libelle == annee_lib).First().Id;
  21. return RedirectToActionPermanent("Details", "Annees", new { id = annee_id });
  22. }
  23. }
  24. }