Beispiel #1
0
        public ActionResult Create([Bind(Include = "id,date_debut,date_fin,titre_seance,salle_id,film_id,id_film")] seance seance,
                                   string datePickerStart, string timePickerStart, string datePickerFin, string timePickerfin)
        {
            string
                startString = datePickerStart + " " + timePickerStart,
                endString   = datePickerFin + " " + timePickerfin;

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

            try
            {
                ManagerSeance manager = new ManagerSeance();
                if (ModelState.IsValid)
                {
                    if (manager.PostSeance(seance))
                    {
                        return(RedirectToAction("DetailsSalle", "cinemas", new { id = int.Parse(Session[SessionKeys.salleId].ToString()), start = DateTime.Now }));
                    }
                }
                ViewBag.film_id = new SelectList(new ManagerFilm().GetAllFilmsFrom(null), "id", "titre");
                return(View(seance));
            }
            catch (Exception e)
            {
                TempData.Add("Alert", e.Message);
                return(RedirectToAction("DetailsSalle", "cinemas", new { id = int.Parse(Session[SessionKeys.salleId].ToString()), start = DateTime.Now }));
            }
        }
Beispiel #2
0
 public ActionResult Create([Bind(Include = "id,date_debut,date_fin,titre_seance,salle_id,film_id")] seance seance)
 {
     try
     {
         ManagerSeance manager = new ManagerSeance();
         if (ModelState.IsValid)
         {
             if (manager.PostSeance(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");
         return(View(seance));
     }
     catch (Exception e)
     {
         //MessageBox.Show(e.Message);
         return(RedirectToAction("Index", "seance", new { id = seance.salle.cinema_id }));
     }
 }