public ActionResult CreatePromo([Bind(Include = "id,titre,description,annee_parution,duree,id_film")] film film)
 {
     try
     {
         if (film.id_type == 0)
         {
             film.id_type = new ManagerTypeFilm().GetAllType_film().Where(t => t.typage.ToUpper() == "PROMOTIONNEL").ToList()[0].id;
         }
         ManagerFilm manager = new ManagerFilm();
         if (ModelState.IsValid)
         {
             if (manager.PostFilm(film))
             {
                 Session[SessionKeys.openedTab] = "Details";
                 Session[SessionKeys.filmId]    = film.id;
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             throw new InvalidItemException("film");
         }
     }
     catch (Exception e)
     {
         TempData.Add("Alert", e.Message);
     }
     ViewBag.id_film = new SelectList(new ManagerFilm().GetAllFilms(), "id", "titre");
     return(View(film));
 }
 public ActionResult Create([Bind(Include = "id,titre,description,annee_parution,duree,rating,revenu,ranking,votes,metascore,id_type,id_film")] film film)
 {
     try
     {
         ManagerFilm manager = new ManagerFilm();
         if (ModelState.IsValid)
         {
             if (manager.PostFilm(film))
             {
                 Session[SessionKeys.openedTab] = "Details";
                 Session[SessionKeys.filmId]    = film.id;
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             throw new InvalidItemException("film");
         }
     }
     catch (Exception e)
     {
         TempData.Add("Alert", e.Message);
     }
     ViewBag.id_type = new SelectList(new ManagerTypeFilm().GetType_film(), "id", "typage");
     ViewBag.id_film = new SelectList(new ManagerFilm().GetAllFilms(), "id", "titre");
     return(View(film));
 }
        public void PostConflictingTitre()
        {
            //Arrange
            var managerFilm     = new ManagerFilm(_context);
            var conflictingFilm = new film()
            {
                id = 10, titre = "film test 1", description = "", annee_parution = 2000, duree = 15, id_type = 2
            };

            //Act
            try
            {
                managerFilm.PostFilm(conflictingFilm);
                Assert.Fail("an exception should have been thrown");
            }
            //Assert
            catch (ExistingItemException eie)
            {
                Assert.AreEqual("cet 'film' existe deja", eie.Message);
            }
            catch (Exception e)
            {
                Assert.Fail($"unexpected error of type {e.GetType()} occure with a message : {e.Message}");
            }
        }