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 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));
 }
        //Edit
        #region
        // GET: films/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Request.IsAjaxRequest())
            {
                try
                {
                    ManagerFilm manager = new ManagerFilm();
                    film        film    = manager.GetFilm(id);

                    ViewBag.id_type = new SelectList(new ManagerTypeFilm().GetType_film(), "id", "typage");
                    ViewBag.id_film = new SelectList(new ManagerFilm().GetAllFilms(), "id", "titre");

                    ManagerFilm m = new ManagerFilm();
                    film        f = m.GetFilm(id);
                    if (f != null)
                    {
                        return(PartialView("PartialEdit", f));
                    }
                }
                catch (Exception e)
                {
                    TempData.Add("Alert", e.Message);
                }
            }
            return(RedirectToAction("Index"));
        }
        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}");
            }
        }
Exemplo n.º 5
0
        // GET: seancesEJS
        public ActionResult Index()
        {
            ManagerCinema managerCinema = new ManagerCinema();
            ManagerSalle  managerSalle  = new ManagerSalle();
            ManagerFilm   managerFilm   = new ManagerFilm();
            ManagerSeance managerSeance = new ManagerSeance();

            List <seance> listeSeance = managerSeance.GetAllSeanceFrom(new DateTime(2020, 10, 30));

            listeSeance.ForEach(x => x.salle.cinema.salles.Clear());
            listeSeance.ForEach(x => x.salle.salle_status.salles.Clear());
            listeSeance.ForEach(x => x.programmations.Clear());

            listeSeance.ForEach(x => x.salle.seances.Clear());

            listeSeance.ForEach(x => x.salle.cinema.contact_info.cinemas.Clear());
            listeSeance.ForEach(x => x.salle.cinema.user.contact_info.users.Clear());
            listeSeance.ForEach(x => x.salle.cinema.user.cinemas.Clear());
            listeSeance.ForEach(x => x.salle.cinema.user.user_status.users.Clear());
            listeSeance.ForEach(x => x.salle.cinema.user.user_type.users.Clear());


            ViewBag.appointments = managerSeance.GetAllSeanceFrom(new DateTime(2020, 10, 30));
            //ViewBag.appointments = GetScheduleData();

            ViewBag.Film = managerFilm.GetAllFilms();

            List <cinema> listeCinema = managerCinema.GetAllCinema();

            listeCinema.ForEach(x => x.salles.Clear());
            listeCinema.ForEach(x => x.contact_info        = null);
            listeCinema.ForEach(x => x.contact_info_id     = 0);
            listeCinema.ForEach(x => x.user                = null);
            listeCinema.ForEach(x => x.responsable_user_id = 0);

            ViewBag.Cinema = listeCinema;
            //ViewBag.Cinema = managerCinema.GetAllCinema();

            List <salle> listeSalle = managerSalle.GetAllSalle();

            listeSalle.ForEach(x => x.salle_status.salles.Clear());
            listeSalle.ForEach(x => x.seances.Clear());
            listeSalle.ForEach(x => x.cinema.salles.Clear());
            listeSalle.ForEach(x => x.cinema.contact_info        = null);
            listeSalle.ForEach(x => x.cinema.contact_info_id     = 0);
            listeSalle.ForEach(x => x.cinema.user                = null);
            listeSalle.ForEach(x => x.cinema.responsable_user_id = 0);
            ViewBag.Salle = listeSalle;
            //ViewBag.Salle = managerSalle.GetAllSalle();


            ViewBag.Resources = new string[] { "Cinema", "Salle" };

            return(View(managerSeance.GetAllSeanceFrom(new DateTime(2020, 10, 30))));
        }
        public void GetFilmsFrom_Test()
        {
            //Arrange
            var managerFilm = new ManagerFilm(_context);
            int year        = 2005;

            //Act
            var listeTest = managerFilm.GetAllFilmsFrom(year);

            //Assert
            Assert.IsTrue(listeTest.Count == 2);
        }
 public ActionResult Index(string titre, int?yearMin, int?yearMax, int?id_type)
 {
     try
     {
         ManagerFilm manager = new ManagerFilm();
         ViewBag.id_type = new SelectList(new ManagerTypeFilm().GetAllType_film(), "id", "typage");
         return(View(manager.GetFilmFiltre(titre, yearMin, yearMax, id_type)));
     }
     catch (Exception e)
     {
         TempData.Add("Alert", e.Message);
         return(RedirectToAction("Index", "Home"));
     }
 }
        public void GetFilmsFromTo_Test()
        {
            //Arrage
            var managerFilm = new ManagerFilm(_context);
            int
                yearFrom = 2003,
                yearTo   = 2007;

            //Act
            var listTest = managerFilm.GetAllFilmsFromTo(yearFrom, yearTo);

            //Assert
            Assert.IsTrue(listTest.Count == 1);
        }
 //Delete
 #region
 // GET: films/Delete/5
 public ActionResult Delete(int?id)
 {
     try
     {
         ManagerFilm m = new ManagerFilm();
         film        f = m.GetFilm(id);
         if (f != null)
         {
             return(PartialView("PartialDelete", f));
         }
     }
     catch (Exception e)
     {
         TempData.Add("Alert", e.Message);
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 10
0
        public ActionResult Delete(int id)
        {
            try
            {
                ManagerFilm manager = new ManagerFilm();

                if (manager.DeleteFilm(id))
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                TempData.Add("Alert", e.Message);
            }
            Session[SessionKeys.openedTab] = "Delete";
            Session[SessionKeys.filmId]    = id;
            return(RedirectToAction("Index"));
        }
Exemplo n.º 11
0
        public void IsTitleExist_withNullCandidate()
        {
            ManagerFilm manager  = new ManagerFilm(_context);
            film        nullFIlm = null;

            try
            {
                ValidatorFilm.IsTitleExist(nullFIlm, manager.GetAllFilmsFrom(2010));
                Assert.Fail("an exception should have been thown");
            }
            catch (NullParametreException npe)
            {
                Assert.AreEqual(npe.Message, $"this exception was raised because candidate in IsFilmExist was null");
            }
            catch (Exception e)
            {
                Assert.Fail($"unexpected error of type: {e.GetType()}, with message: {e.Message}");
            }
        }
Exemplo n.º 12
0
 // GET: films/Details/5
 public ActionResult Details(int?id)
 {
     try
     {
         ManagerFilm m = new ManagerFilm();
         film        f = m.GetFilm(id);
         if (f != null)
         {
             return(PartialView("PartialDetails", f));
         }
         else
         {
             throw new NullIdExecption("film");
         }
     }
     catch (Exception e)
     {
         TempData.Add("Alert", e.Message);
         return(RedirectToAction("Index"));
     }
 }
Exemplo n.º 13
0
        public void IsTitleExist_withNullFilms()
        {
            ManagerFilm manager  = new ManagerFilm(_context);
            film        testFilm = new film()
            {
                id = 999, titre = "non conflicting title", description = "test", duree = 15, annee_parution = 2020
            };
            List <film> nullFilms = null;

            try
            {
                ValidatorFilm.IsTitleExist(testFilm, nullFilms);
                Assert.Fail("an exception should have been thown");
            }
            catch (NullParametreException npe)
            {
                Assert.AreEqual(npe.Message, $"this exception was raised because films in IsFilmExist was null");
            }
            catch (Exception e)
            {
                Assert.Fail($"unexpected error of type: {e.GetType()}, with message: {e.Message}");
            }
        }
Exemplo n.º 14
0
        public void IsTitleExist_correctTitle()
        {
            //Arrange
            ManagerFilm manager = new ManagerFilm(_context);
            film        nonConflitingTitlefilm = new film()
            {
                id = 999, titre = "non conflicting title", description = "test", duree = 15, annee_parution = 2020
            };
            bool testResult = false;

            //Act
            try
            {
                testResult = ValidatorFilm.IsTitleExist(nonConflitingTitlefilm, manager.GetAllFilmsFromTo(nonConflitingTitlefilm.annee_parution - 20, nonConflitingTitlefilm.annee_parution + 20));
            }
            catch (Exception e)
            {
                Assert.Fail($"unexpected error of type: {e.GetType()}, with message: {e.Message}");
            }

            //Assert
            Assert.IsFalse(testResult);
        }