Exemple #1
0
        public ActionResult Edit([Bind(Include = "id,date_debut,date_fin,titre_seance,salle_id,film_id")] seance seance,
                                 string command, string titre, int?yearMin, int?yearMax, int?id_type,
                                 string datePickerStart, string timePickerStart, string datePickerFin, string timePickerfin)
        {
            string
                startString = datePickerStart + " " + timePickerStart,
                endString   = datePickerFin + " " + timePickerfin;


            if (command == "Filtre")
            {
                return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type }));
            }
            else if (command == "addFilm")
            {
                return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type }));
            }

            seance.date_debut = DateTime.Parse(startString);
            seance.date_fin   = DateTime.Parse(endString);


            try
            {
                ManagerSeance managerSeance = new ManagerSeance();

                if (ModelState.IsValid)
                {
                    if (managerSeance.PutSeance(seance))
                    {
                        return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type }));
                    }
                }
                ViewBag.salle_id = new SelectList(new ManagerSalle().GetAllSalle().Where(s => s.cinema_id == int.Parse(Session[SessionKeys.cinemaId].ToString())), "id", "numero_salle", seance.salle_id);
                return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type }));
            }
            catch (Exception e)
            {
                TempData.Add("Alert", e.Message);
                return(RedirectToAction("Edit", seance));
            }
        }
Exemple #2
0
        public ActionResult Edit([Bind(Include = "id,date_debut,date_fin,titre_seance,salle_id,film_id")] seance seance)
        {
            try
            {
                ManagerSeance managerSeance = new ManagerSeance();

                if (ModelState.IsValid)
                {
                    if (managerSeance.PutSeance(seance))
                    {
                        return(RedirectToAction("Index", new { id = seance.salle.cinema_id }));
                    }
                }
                ViewBag.film_id  = new SelectList(new ManagerFilm().GetAllFilms(), "id", "titre");
                ViewBag.salle_id = new SelectList(new ManagerSalle().GetAllSalle(), "id", "commentaire", seance.salle_id);
                return(View(seance));
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message);
                return(RedirectToAction("Index", new { id = seance.salle.cinema_id }));
            }
        }