예제 #1
0
 public ActionResult agregarCartelera(CarteleraModelAndView model)
 {
     if (model.IdCartelera == 0)
     {
         return(View(new CarteleraModelAndView()));
     }
     else
     {
         try
         {
             Carteleras carteleraModificable = carteleraService.obtenerCarteleraPorId(model.IdCartelera);
             model.idSedeCarteleraModel     = carteleraModificable.IdSede.ToString();
             model.idPeliculaCarteleraModel = carteleraModificable.IdPelicula.ToString();
             model.horaInicioModel          = carteleraModificable.HoraInicio.ToString();
             model.fechaInicioModel         = carteleraModificable.FechaInicio.ToString();
             model.fechaFinModel            = carteleraModificable.FechaFin.ToString();
             model.numeroSalaModel          = carteleraModificable.NumeroSala.ToString();
             model.idVersionModel           = carteleraModificable.IdVersion.ToString();
             model.lunesModel      = carteleraModificable.Lunes.ToString();
             model.martesModel     = carteleraModificable.Martes.ToString();
             model.miercolesModel  = carteleraModificable.Miercoles.ToString();
             model.juevesModel     = carteleraModificable.Jueves.ToString();
             model.viernesModel    = carteleraModificable.Viernes.ToString();
             model.sabadoModel     = carteleraModificable.Sabado.ToString();
             model.domingoModel    = carteleraModificable.Domingo.ToString();
             model.fechaCargaModel = carteleraModificable.FechaCarga.ToString();
         }
         catch (Exception e)
         {
             ViewBag.errorCartelera = ""; //REVISAR ERRORES!
             RedirectToAction("carteleras");
         }
         return(View(model));
     }
 }
예제 #2
0
 //CARTELERAS
 public ActionResult carteleras()
 {
     ViewData["sessionString"] = System.Web.HttpContext.Current.Session["sessionString"] as String;
     if (ViewData["sessionString"] != null)
     {
         if (!ModelState.IsValid)
         {
             return(View("agregarCartelera"));
         }
         else
         {
             CarteleraModelAndView model = new CarteleraModelAndView();
             try
             {
                 model.listadoDeCarteleras = carteleraService.getListadoDeCarteleras();
                 return(View(model));
             }
             catch (Exception e)
             {
                 ViewBag.ListaCartelerasVacia = e.Message; //Lanza la excepción en la vista.
                 model.listadoDeCarteleras    = new List <Carteleras>();
                 return(View(model));
             }
         }
     }
     else
     {
         TempData["controlador"] = Request.RequestContext.RouteData.Values["controller"].ToString();
         TempData["accion"]      = Request.RequestContext.RouteData.Values["action"].ToString();
         return(RedirectToAction("login", "Home"));
     }
 }
예제 #3
0
        public ActionResult agregarCarteleraPost(CarteleraModelAndView model) //A esta vista se tiene acceso por post, no es necesario validar acceso por url.
        {
            model.IdCartelera = Convert.ToInt32(model.idCarteleraModel);
            if (!ModelState.IsValid)
            {
                return(View("AgregarCartelera", model));
            }
            else
            {
                if (model.idCarteleraModel == null || model.idCarteleraModel == "0")
                {
                    Carteleras carteleraAAgregar = new Carteleras();

                    carteleraAAgregar.IdSede     = Convert.ToInt32(model.idSedeCarteleraModel);
                    carteleraAAgregar.IdPelicula = Convert.ToInt32(model.idPeliculaCarteleraModel);
                    carteleraAAgregar.HoraInicio = Convert.ToInt32(model.horaInicioModel);

                    carteleraAAgregar.FechaInicio = Convert.ToDateTime(model.fechaInicioModel);
                    carteleraAAgregar.FechaFin    = Convert.ToDateTime(model.fechaFinModel);

                    carteleraAAgregar.NumeroSala = Convert.ToInt32(model.numeroSalaModel);
                    carteleraAAgregar.IdVersion  = Convert.ToInt32(model.idVersionModel);
                    carteleraAAgregar.Lunes      = Convert.ToBoolean(model.lunesModel);
                    carteleraAAgregar.Martes     = Convert.ToBoolean(model.martesModel);
                    carteleraAAgregar.Miercoles  = Convert.ToBoolean(model.miercolesModel);
                    carteleraAAgregar.Jueves     = Convert.ToBoolean(model.juevesModel);
                    carteleraAAgregar.Viernes    = Convert.ToBoolean(model.viernesModel);
                    carteleraAAgregar.Sabado     = Convert.ToBoolean(model.sabadoModel);
                    carteleraAAgregar.Domingo    = Convert.ToBoolean(model.domingoModel);
                    carteleraAAgregar.FechaCarga = DateTime.Now;
                    try
                    {
                        carteleraService.crearCartelera(carteleraAAgregar);
                    }
                    catch (Exception e)
                    {
                        ViewBag.ErrorAlAgregarCartelera = e.Message;
                        return(View("agregarCartelera", model));
                    }
                    TempData["CarteleraOK"] = "¡La cartelera se agregó correctamente!";
                    return(RedirectToAction("carteleras"));
                }
                else
                {
                    try
                    {
                        carteleraService.modificarCarteleraPorId(Convert.ToInt32(model.idCarteleraModel), model.idSedeCarteleraModel, model.idPeliculaCarteleraModel, model.horaInicioModel, model.fechaInicioModel, model.fechaFinModel, model.numeroSalaModel, model.idVersionModel, model.lunesModel, model.martesModel, model.miercolesModel, model.juevesModel, model.viernesModel, model.sabadoModel, model.domingoModel);
                    }
                    catch (Exception e)
                    {
                        ViewBag.errorCartelera = e.Message;
                        return(View("agregarCartelera", model));
                    }
                    TempData["CarteleraOK"] = "¡La cartelera se modificó correctamente!";
                    return(RedirectToAction("carteleras"));
                }
            }
        }
예제 #4
0
        //CARTELERAS


        /* public ActionResult carteleras()
         * {
         *  CarteleraModelAndView model = new CarteleraModelAndView();
         *  try
         *  {
         *      ViewBag.ErrorPelicula = ""; //Revisar las validaciones!
         *
         *      model.listadoDeCarteleras = carteleraService.getListadoDeCarteleras();
         *
         *      return View(model);
         *  }
         *  catch (Exception e)
         *  {
         *      ViewBag.ErrorPelicula = e.Message;
         *      model.listadoDeCarteleras = new List<Carteleras>();
         *      return View(model);
         *  }
         * } */


        public ActionResult carteleras()
        {
            if (!ModelState.IsValid)
            {
                return(View("agregarCartelera"));
            }
            else
            {
                CarteleraModelAndView model = new CarteleraModelAndView();
                try
                {
                    model.listadoDeCarteleras = carteleraService.getListadoDeCarteleras();
                    return(View(model));
                }
                catch (Exception e)
                {
                    ViewBag.ListaCartelerasVacia = e.Message; //Lanza la excepción en la vista.
                    model.listadoDeCarteleras    = new List <Carteleras>();
                    return(View(model));
                }
            }
        }
예제 #5
0
        public ActionResult agregarCartelera(CarteleraModelAndView model) //A esta vista se tiene acceso por post, no es necesario validar acceso por url.
        {
            if (model.IdCartelera == 0)
            {
                return(View(new CarteleraModelAndView()));
            }
            else
            {
                try
                {
                    Carteleras carteleraModificable = carteleraService.obtenerCarteleraPorId(model.IdCartelera);

                    model.idSedeCarteleraModel     = carteleraModificable.IdSede.ToString();
                    model.idPeliculaCarteleraModel = carteleraModificable.IdPelicula.ToString();
                    model.horaInicioModel          = carteleraModificable.HoraInicio.ToString();
                    model.fechaInicioModel         = carteleraModificable.FechaInicio.ToString();
                    model.fechaFinModel            = carteleraModificable.FechaFin.ToString();
                    model.numeroSalaModel          = carteleraModificable.NumeroSala.ToString();
                    model.idVersionModel           = carteleraModificable.IdVersion.ToString();
                    model.lunesModel      = carteleraModificable.Lunes.ToString();
                    model.martesModel     = carteleraModificable.Martes.ToString();
                    model.miercolesModel  = carteleraModificable.Miercoles.ToString();
                    model.juevesModel     = carteleraModificable.Jueves.ToString();
                    model.viernesModel    = carteleraModificable.Viernes.ToString();
                    model.sabadoModel     = carteleraModificable.Sabado.ToString();
                    model.domingoModel    = carteleraModificable.Domingo.ToString();
                    model.fechaCargaModel = carteleraModificable.FechaCarga.ToString();
                }
                catch (Exception e)
                {
                    ViewBag.errorCartelera = e.Message;
                    RedirectToAction("carteleras");
                }
                return(View(model));
            }
        }