public ActionResult Elemento(int?id = null)
        {
            if (!this.currentUser())
            {
                return(RedirectToAction("Ingresar"));
            }
            DynContentBL contextBL = new DynContentBL();
            IList <TipoDynamicContent> categorias = contextBL.getCategorias();

            categorias.Insert(0, new TipoDynamicContent()
            {
                IdTipoDynamicContent = 0, Nombre = "Seleccione el tipo de contenido"
            });
            ViewBag.Categorias = categorias.AsEnumerable();
            var objSent = TempData["objSent"];

            if (objSent != null)
            {
                TempData["objSent"] = null; return(View(objSent));
            }
            if (id != null)
            {
                return(View(contextBL.getElementById((int)id)));
            }
            return(View());
        }
        public ActionResult AddElement(DynamicContent entidad)
        {
            if (!this.currentUser())
            {
                return(RedirectToAction("Ingresar"));
            }

            DynContentBL contextBL = new DynContentBL();

            try
            {
                contextBL.add(entidad);
                createResponseMessage(CONSTANTES.SUCCESS);
                return(RedirectToAction("Home"));
            }
            catch
            {
                if (entidad.IdDynamicContent != 0)
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                }
            }

            TempData["objSent"] = entidad;
            return(RedirectToAction("Elemento", new { id = entidad.IdDynamicContent != 0 ? entidad.IdDynamicContent.ToString() : "" }));
        }
        public ActionResult Home(int?id = null)
        {
            if (!this.currentUser())
            {
                return(RedirectToAction("Ingresar"));
            }
            DynContentBL contextBL = new DynContentBL();

            ViewBag.Categorias       = contextBL.getCategorias();
            ViewBag.SelectedCategory = id != null ? (int)id : 1;
            return(View(contextBL.getElementsByCategoria(id != null ? (int)id : 1)));
        }