using CD67.FicheCollege.Entity;
using CD67.FicheCollege.Factory;
using System;
using System.Linq;
using System.Net;
using System.Web.Mvc;

namespace CD67.FicheCollege.MVC.Controllers
{
    public class HomeController : Controller
    {
        private Entities db = new Entities();

        // GET: Home
        public ActionResult Index()
        {
            int annee_id;

            if (Request.Cookies["last_selected_year"] != null)
            {
                annee_id = Int32.Parse(Request.Cookies["last_selected_year"].Value);
            } else
            {
                AnneeFactory fact = new AnneeFactory(db);
                annee_id = fact.get_current_year_id();
            }
            
            return RedirectToAction("Details", "Annees", new { id = annee_id });
        }
    }
}
