public ActionResult FiltrarNoticia(NOTICIA item)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            try
            {
                // Executa a operação
                Int32          idAss    = (Int32)Session["IdAssinante"];
                List <NOTICIA> listaObj = new List <NOTICIA>();
                Int32          volta    = baseApp.ExecuteFilter(item.NOTC_NM_TITULO, item.NOTC_NM_AUTOR, item.NOTC_DT_DATA_AUTOR, item.NOTC_TX_TEXTO, item.NOTC_LK_LINK, idAss, out listaObj);

                // Verifica retorno
                if (volta == 1)
                {
                    Session["MensNoticia"] = 1;
                    ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
                }

                // Sucesso
                Session["MensNoticia"]  = 0;
                listaMaster             = listaObj;
                Session["ListaNoticia"] = listaObj;
                return(RedirectToAction("MontarTelaUsuario"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(RedirectToAction("MontarTelaUsuario"));
            }
        }
        public ActionResult MontarTelaUsuario()
        {
            // Carrega listas
            Int32   idAss   = (Int32)Session["IdAssinante"];
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            usuario = (USUARIO)Session["UserCredentials"];

            if ((List <NOTICIA>)Session["ListaNoticia"] == null)
            {
                listaMaster             = baseApp.GetAllItensValidos(idAss);
                Session["ListaNoticia"] = listaMaster;
            }
            ViewBag.Listas = (List <NOTICIA>)Session["ListaNoticia"];
            ViewBag.Perfil = usuario.PERFIL.PERF_SG_SIGLA;
            ViewBag.Title  = "Notícias";

            // Indicadores
            ViewBag.Noticias = ((List <NOTICIA>)Session["ListaNoticia"]).Count;

            // Mensagem
            if ((Int32)Session["MensNoticia"] == 1)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
            }

            // Abre view
            Session["MensNoticia"] = 0;
            objeto = new NOTICIA();
            return(View(objeto));
        }
        public ActionResult IncluirNoticia()
        {
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if ((USUARIO)Session["UserCredentials"] != null)
            {
                usuario = (USUARIO)Session["UserCredentials"];

                // Verfifica permissão
                if (usuario.PERFIL.PERF_SG_SIGLA != "ADM" || usuario.PERFIL.PERF_SG_SIGLA != "SIN" || usuario.PERFIL.PERF_SG_SIGLA != "CON")
                {
                    Session["MensNoticia"] = 2;
                    return(RedirectToAction("CarregarBase", "BaseAdmin"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }

            // Prepara view
            NOTICIA          item = new NOTICIA();
            NoticiaViewModel vm   = Mapper.Map <NOTICIA, NoticiaViewModel>(item);

            vm.ASSI_CD_ID       = (Int32)Session["IdAssinante"];
            vm.NOTC_DT_EMISSAO  = DateTime.Today.Date;
            vm.NOTC_IN_ATIVO    = 1;
            vm.NOTC_DT_VALIDADE = DateTime.Today.Date.AddDays(30);
            vm.NOTC_NR_ACESSO   = 0;
            return(View(vm));
        }
        public ActionResult EditarNoticia(Int32 id)
        {
            // Prepara view
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if ((USUARIO)Session["UserCredentials"] != null)
            {
                usuario = (USUARIO)Session["UserCredentials"];

                // Verfifica permissão
                if (usuario.PERFIL.PERF_SG_SIGLA != "ADM" || usuario.PERFIL.PERF_SG_SIGLA != "SIN" || usuario.PERFIL.PERF_SG_SIGLA != "CON")
                {
                    Session["MensAcesso"] = 2;
                    return(RedirectToAction("CarregarBase", "BaseAdmin"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }

            NOTICIA item = baseApp.GetItemById(id);

            objetoAntes        = item;
            Session["Noticia"] = item;
            Session["IdVolta"] = id;
            NoticiaViewModel vm = Mapper.Map <NOTICIA, NoticiaViewModel>(item);

            return(View(vm));
        }
        public ActionResult ExcluirNoticia(NoticiaViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            try
            {
                // Executa a operação
                USUARIO usuarioLogado = (USUARIO)Session["UserCredentials"];
                NOTICIA item          = Mapper.Map <NoticiaViewModel, NOTICIA>(vm);
                Int32   volta         = baseApp.ValidateDelete(item, usuarioLogado);

                // Verifica retorno

                // Sucesso
                listaMaster             = new List <NOTICIA>();
                Session["ListaNoticia"] = null;
                Session["MensNoticia"]  = 0;
                return(RedirectToAction("MontarTelaNoticia"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(View(objeto));
            }
        }
        public ActionResult ReativarNoticia(Int32 id)
        {
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if ((USUARIO)Session["UserCredentials"] != null)
            {
                usuario = (USUARIO)Session["UserCredentials"];

                // Verfifica permissão
                if (usuario.PERFIL.PERF_SG_SIGLA != "ADM")
                {
                    Session["MensNoticia"] = 2;
                    return(RedirectToAction("MontarTelaNoticia", "Noticia"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }

            // Prepara view
            NOTICIA          item = baseApp.GetItemById(id);
            NoticiaViewModel vm   = Mapper.Map <NOTICIA, NoticiaViewModel>(item);

            return(View(vm));
        }
예제 #7
0
        private void Guardar()
        {
            try
            {
                NOTICIA noti = new NOTICIA();
                noti.noticia1 = this.txtNoticia.Text;

                if (this.idNoticia == 0)
                {
                    this.objNoticia.Crear(noti, CGlobal.IdUsuario);
                    MessageBox.Show("La noticia ha sido creada", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    noti.id = this.idNoticia;
                    this.objNoticia.Actualizar(noti, CGlobal.IdUsuario);
                    MessageBox.Show("La noticia ha sido actualizada", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                this.GetNoticias();
                this.Limpiar();
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo guardar la noticia: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #8
0
        public ActionResult DeleteConfirmed(long id)
        {
            NOTICIA nOTICIA = db.NOTICIAs.Find(id);

            db.NOTICIAs.Remove(nOTICIA);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult MontarTelaNoticia()
        {
            // Verifica se tem usuario logado
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if ((USUARIO)Session["UserCredentials"] != null)
            {
                usuario = (USUARIO)Session["UserCredentials"];

                // Verfifica permissão
                if (usuario.PERFIL.PERF_SG_SIGLA != "ADM" || usuario.PERFIL.PERF_SG_SIGLA != "SIN" || usuario.PERFIL.PERF_SG_SIGLA != "CON")
                {
                    Session["MensNoticia"] = 2;
                    return(RedirectToAction("CarregarBase", "BaseAdmin"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }

            // Carrega listas
            Int32 idAss = (Int32)Session["IdAssinante"];

            if ((List <NOTICIA>)Session["ListaNoticia"] == null)
            {
                listaMaster             = baseApp.GetAllItens(idAss);
                Session["ListaNoticia"] = listaMaster;
            }
            ViewBag.Listas = (List <NOTICIA>)Session["ListaNoticia"];
            ViewBag.Title  = "Notícias";

            // Indicadores
            ViewBag.Noticias = ((List <NOTICIA>)Session["ListaNoticia"]).Count;
            ViewBag.Perfil   = usuario.PERFIL.PERF_SG_SIGLA;

            // Mensagem
            if ((Int32)Session["MensNoticia"] == 1)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensNoticia"] == 2)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0010", CultureInfo.CurrentCulture));
            }

            // Abre view
            objeto = new NOTICIA();
            Session["VoltaNoticia"] = 1;
            Session["MensNoticia"]  = 0;
            return(View(objeto));
        }
예제 #10
0
        /// <summary>
        /// Inactiva la noticia en la base de datos
        /// </summary>
        /// <param name="idRegistro">Id del registro a eliminar</param>
        /// <param name="idUsuario">Id del usuario logueado que realiza la operación</param>
        public void Eliminar(int idRegistro, int idUsuario)
        {
            NOTICIA noticia = (NOTICIA)this.objDAO.GetEntidadById(Enumeraciones.Entidad.NOTICIA, idRegistro);

            noticia.activo            = false;
            noticia.fechaModificacion = DateTime.Now;
            noticia.idModifcador      = idUsuario;

            this.objDAO.Actualizar(Enumeraciones.Entidad.NOTICIA, noticia, noticia.id, idUsuario);
        }
예제 #11
0
 public ActionResult Edit([Bind(Include = "ID,FECHAI,FECHAF,PATH,USUARIOC_ID,FECHAC,ACTIVO")] NOTICIA nOTICIA)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nOTICIA).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.USUARIOC_ID = new SelectList(db.USUARIOs, "ID", "PASS", nOTICIA.USUARIOC_ID);
     return(View(nOTICIA));
 }
        public ActionResult Index()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            NOTICIA          item = new NOTICIA();
            NoticiaViewModel vm   = Mapper.Map <NOTICIA, NoticiaViewModel>(item);

            return(View(vm));
        }
예제 #13
0
    private void cargarNoticias()
    {
        NOTICIA        noticia  = new NOTICIA();
        List <NOTICIA> noticias = noticia.obtainAllNoticias();

        if (noticias != null && noticias.Count() > 0)
        {
            gridNoticias.DataSource = noticias;
            gridNoticias.DataBind();
        }
        limpiar();
    }
예제 #14
0
        /// <summary>
        /// Actualiza una noticia
        /// </summary>
        /// <param name="noticia">Objeto noticia a actualizar</param>
        /// <param name="idUsuario">Id del usuario que realiza la operacion</param>
        public void Actualizar(NOTICIA noticia, int idUsuario)
        {
            if (noticia == null)
            {
                throw new Exception("La noticia no puede ser null");
            }

            noticia.idModifcador      = idUsuario;
            noticia.fechaModificacion = DateTime.Now;
            noticia.activo            = true;
            this.objDAO.Actualizar(Enumeraciones.Entidad.NOTICIA, noticia, noticia.id, idUsuario);
        }
예제 #15
0
    public int deleteNoticia(int noticiaId)
    {
        int     result        = 0;
        NOTICIA noticiaDelete = obtainNoticiaById(noticiaId);

        if (noticiaDelete != null)
        {
            Datos.NOTICIAs.Remove(noticiaDelete);
            result = Datos.SaveChanges();
        }
        return(result);
    }
예제 #16
0
        public ActionResult Create([Bind(Include = "ID,FECHAI,FECHAF,PATH,USUARIOC_ID,FECHAC,ACTIVO")] NOTICIA nOTICIA)
        {
            if (ModelState.IsValid)
            {
                string u    = User.Identity.Name;
                var    user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                var    _p   = db.NOTICIAs.Where(x => x.PATH == "/images/" + nOTICIA.PATH).FirstOrDefault();
                //si p es null, significa que podemos hacer incersiones
                if (_p == null)
                {
                    nOTICIA.FECHAC      = DateTime.Now;
                    nOTICIA.PATH        = "/images/" + nOTICIA.PATH;
                    nOTICIA.USUARIOC_ID = user.ID;
                    nOTICIA.ACTIVO      = true;
                    db.NOTICIAs.Add(nOTICIA);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.error = "Ya existe un registro con esos datos";
            int pagina = 912; //ID EN BASE DE DATOS

            using (TAT001Entities db = new TAT001Entities())
            {
                string u = User.Identity.Name;
                //string u = "admin";
                var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList();
                ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList();
                ViewBag.usuario  = user; ViewBag.returnUrl = Request.Url.PathAndQuery;;
                ViewBag.rol      = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.Title    = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.textos   = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();

                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".svg";
                }
                catch
                {
                    //ViewBag.pais = "mx.svg";
                    //return RedirectToAction("Pais", "Home");
                }
                Session["spras"] = user.SPRAS_ID;
                ViewBag.lan      = user.SPRAS_ID;
            }
            ViewBag.imgnoticia  = db.NOTICIAs.Where(x => x.FECHAI <= DateTime.Now && x.FECHAF >= DateTime.Now && x.ACTIVO == true).Select(x => x.PATH).FirstOrDefault();
            ViewBag.USUARIOC_ID = new SelectList(db.USUARIOs, "ID", "PASS", nOTICIA.USUARIOC_ID);
            return(View(nOTICIA));
        }
예제 #17
0
        private void Editar()
        {
            //Se obtienen los datos actuales
            NOTICIA obj = this.objNoticia.GetById(this.idNoticia);

            if (obj == null)
            {
                MessageBox.Show("No se encontró la información de la noticia seleccionada", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            this.txtNoticia.Text = obj.noticia1;
        }
        public ActionResult IncluirNoticia(NoticiaViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    Int32   idAss         = (Int32)Session["IdAssinante"];
                    NOTICIA item          = Mapper.Map <NoticiaViewModel, NOTICIA>(vm);
                    USUARIO usuarioLogado = (USUARIO)Session["UserCredentials"];
                    Int32   volta         = baseApp.ValidateCreate(item, usuarioLogado);

                    // Verifica retorno

                    // Carrega foto e processa alteracao
                    item.NOTC_AQ_FOTO = "~/Imagens/p_big2.jpg";
                    volta             = baseApp.ValidateEdit(item, item, usuarioLogado);

                    // Cria pastas
                    String caminho = "/Imagens/" + idAss.ToString() + "/Noticias/" + item.NOTC_CD_ID.ToString() + "/Fotos/";
                    Directory.CreateDirectory(Server.MapPath(caminho));

                    // Sucesso
                    listaMaster               = new List <NOTICIA>();
                    Session["ListaNoticia"]   = null;
                    Session["VoltaNoticia"]   = 1;
                    Session["IdNoticiaVolta"] = item.NOTC_CD_ID;
                    Session["Noticia"]        = item;
                    Session["MensNoticia"]    = 0;
                    if ((Int32)Session["VoltaNoticia"] == 2)
                    {
                        return(RedirectToAction("VerCardsNoticias"));
                    }
                    return(RedirectToAction("MontarTelaNoticia"));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View(vm));
                }
            }
            else
            {
                return(View(vm));
            }
        }
예제 #19
0
        // GET: NOTICIAs/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NOTICIA nOTICIA = db.NOTICIAs.Find(id);

            if (nOTICIA == null)
            {
                return(HttpNotFound());
            }
            return(View(nOTICIA));
        }
예제 #20
0
        // GET: NOTICIAs/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NOTICIA nOTICIA = db.NOTICIAs.Find(id);

            if (nOTICIA == null)
            {
                return(HttpNotFound());
            }
            ViewBag.USUARIOC_ID = new SelectList(db.USUARIOs, "ID", "PASS", nOTICIA.USUARIOC_ID);
            return(View(nOTICIA));
        }
        public ActionResult VerNoticia(Int32 id)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Session["IdVolta"] = id;
            NOTICIA item = baseApp.GetItemById(id);

            item.NOTC_NR_ACESSO = ++item.NOTC_NR_ACESSO;
            objetoAntes         = item;
            Int32 volta = baseApp.ValidateEdit(item, objetoAntes);

            NoticiaViewModel vm = Mapper.Map <NOTICIA, NoticiaViewModel>(item);

            return(View(vm));
        }
        public ActionResult IncluirComentario()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32                      id            = (Int32)Session["IdVolta"];
            NOTICIA                    item          = baseApp.GetItemById(id);
            USUARIO                    usuarioLogado = (USUARIO)Session["UserCredentials"];
            NOTICIA_COMENTARIO         coment        = new NOTICIA_COMENTARIO();
            NoticiaComentarioViewModel vm            = Mapper.Map <NOTICIA_COMENTARIO, NoticiaComentarioViewModel>(coment);

            vm.NOCO_DT_COMENTARIO = DateTime.Today;
            vm.NOCO_IN_ATIVO      = 1;
            vm.NOTC_CD_ID         = item.NOTC_CD_ID;
            vm.USUARIO            = usuarioLogado;
            vm.USUA_CD_ID         = usuarioLogado.USUA_CD_ID;
            return(View(vm));
        }
예제 #23
0
    protected void btnGuardarNoticia_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarNoticia(false);
        if (textoValidacion.Equals(""))
        {
            NOTICIA noticia = new NOTICIA();
            noticia.addNoticia(txtNombreNoticia.Text, txtDescripcionNoticia.Text, Convert.ToInt32(lblInstitucionId.Text));
            cargarNoticias();

            lblSucess.Text = "Se creo Correctamente la Noticia";
            pnlSucess.Visible = true;

        }
        else
        {
            lblError.Text = textoValidacion;
            pnlError.Visible = true;
        }
    }
예제 #24
0
    protected void btnEditarNoticia_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarNoticia(true);

        if (textoValidacion.Equals(""))
        {
            NOTICIA noticia = new NOTICIA();
            noticia.refreshNoticia(Convert.ToInt32(lblNoticiaId.Text), txtNombreNoticia.Text, txtDescripcionNoticia.Text, Convert.ToInt32(lblInstitucionId.Text));
            cargarNoticias();

            lblSucess.Text    = "Se edito Correctamente la Noticia";
            pnlSucess.Visible = true;
        }
        else
        {
            lblError.Text    = textoValidacion;
            pnlError.Visible = true;
        }
    }
예제 #25
0
    protected void btnEliminarNoticia_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarNoticia(true);

        if (textoValidacion.Equals(""))
        {
            NOTICIA noticia = new NOTICIA();
            noticia.deleteNoticia(Convert.ToInt32(lblNoticiaId.Text));
            cargarNoticias();

            lblSucess.Text    = "Se elimino Correctamente la Noticia";
            pnlSucess.Visible = true;
        }
        else
        {
            lblError.Text    = textoValidacion;
            pnlError.Visible = true;
        }
    }
예제 #26
0
    protected void btnEliminarNoticia_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarNoticia(true);
        if (textoValidacion.Equals(""))
        {
            NOTICIA noticia = new NOTICIA();
            noticia.deleteNoticia(Convert.ToInt32(lblNoticiaId.Text));
            cargarNoticias();

            lblSucess.Text = "Se elimino Correctamente la Noticia";
            pnlSucess.Visible = true;

        }
        else
        {
            lblError.Text = textoValidacion;
            pnlError.Visible = true;
        }
    }
예제 #27
0
        // GET: NOTICIAs/Delete/5
        public ActionResult Delete(long?id)
        {
            int pagina = 721; //ID EN BASE DE DATOS

            using (TAT001Entities db = new TAT001Entities())
            {
                string u = User.Identity.Name;
                //string u = "admin";
                var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList();
                ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList();
                ViewBag.usuario  = user; ViewBag.returnUrl = Request.Url.PathAndQuery;;
                ViewBag.rol      = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.Title    = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.textos   = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();

                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".svg";
                }
                catch
                {
                    //ViewBag.pais = "mx.svg";
                    //return RedirectToAction("Pais", "Home");
                }
                Session["spras"] = user.SPRAS_ID;
                ViewBag.lan      = user.SPRAS_ID;
            }
            ViewBag.imgnoticia = db.NOTICIAs.Where(x => x.FECHAI <= DateTime.Now && x.FECHAF >= DateTime.Now && x.ACTIVO == true).Select(x => x.PATH).FirstOrDefault();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NOTICIA nOTICIA = db.NOTICIAs.Find(id);

            if (nOTICIA == null)
            {
                return(HttpNotFound());
            }
            return(View(nOTICIA));
        }
예제 #28
0
    public NOTICIA addNoticia(String nombre, String descripcion, int institucionId)
    {
        NOTICIA noticia = new NOTICIA();

        try
        {
            noticia.NOTICIAID     = 0;
            noticia.NOMBRE        = nombre;
            noticia.DESCRIPCION   = descripcion;
            noticia.INSTITUCIONID = institucionId;

            Datos.NOTICIAs.Add(noticia);
            Datos.SaveChanges();
        }
        catch (Exception ex)
        {
            string x = ex.Message;
        }

        return(noticia);
    }
예제 #29
0
    public NOTICIA addNoticia(String nombre, String descripcion, int institucionId)
    {
        NOTICIA noticia = new NOTICIA();

        try
        {
            noticia.NOTICIAID = 0;
            noticia.NOMBRE = nombre;
            noticia.DESCRIPCION = descripcion;
            noticia.INSTITUCIONID = institucionId;

            Datos.NOTICIAs.Add(noticia);
            Datos.SaveChanges();
        }
        catch (Exception ex)
        {
            string x = ex.Message;
        }

        return noticia;
    }
        public ActionResult UploadFotoNoticia(HttpPostedFileBase file)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if (file == null)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0019", CultureInfo.CurrentCulture));
                return(RedirectToAction("VoltarAnexoNoticia"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];
            Int32 idNot = (Int32)Session["IdVolta"];

            NOTICIA item     = baseApp.GetById(idNot);
            USUARIO usu      = (USUARIO)Session["UserCredentials"];
            var     fileName = Path.GetFileName(file.FileName);

            if (fileName.Length > 100)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0024", CultureInfo.CurrentCulture));
                return(RedirectToAction("VoltarAnexoNoticia"));
            }
            String caminho = "/Imagens/" + idAss.ToString() + "/Noticias/" + item.NOTC_CD_ID.ToString() + "/Fotos/";
            String path    = Path.Combine(Server.MapPath(caminho), fileName);

            file.SaveAs(path);

            //Recupera tipo de arquivo
            extensao = Path.GetExtension(fileName);
            String a = extensao;

            // Gravar registro
            item.NOTC_AQ_FOTO = "~" + caminho + fileName;
            objetoAntes       = item;
            Int32 volta = baseApp.ValidateEdit(item, objetoAntes);

            return(RedirectToAction("VoltarAnexoNoticia"));
        }
        public ActionResult EditarNoticia(NoticiaViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    Int32   idAss         = (Int32)Session["IdAssinante"];
                    USUARIO usuarioLogado = (USUARIO)Session["UserCredentials"];
                    NOTICIA item          = Mapper.Map <NoticiaViewModel, NOTICIA>(vm);
                    Int32   volta         = baseApp.ValidateEdit(item, objetoAntes, usuarioLogado, idAss);

                    // Verifica retorno

                    // Sucesso
                    listaMaster             = new List <NOTICIA>();
                    Session["ListaNoticia"] = null;
                    Session["MensNoticia"]  = 0;
                    if ((Int32)Session["VoltaNoticia"] == 2)
                    {
                        return(RedirectToAction("VerCardsNoticias"));
                    }
                    return(RedirectToAction("MontarTelaNoticia"));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View(vm));
                }
            }
            else
            {
                return(View(vm));
            }
        }
        public ActionResult IncluirComentario(NoticiaComentarioViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idNot = (Int32)Session["IdVolta"];

            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    NOTICIA_COMENTARIO item          = Mapper.Map <NoticiaComentarioViewModel, NOTICIA_COMENTARIO>(vm);
                    USUARIO            usuarioLogado = (USUARIO)Session["UserCredentials"];
                    NOTICIA            not           = baseApp.GetItemById(idNot);

                    item.USUARIO = null;
                    not.NOTICIA_COMENTARIO.Add(item);
                    objetoAntes = not;
                    Int32 volta = baseApp.ValidateEdit(not, objetoAntes);

                    // Verifica retorno

                    // Sucesso
                    return(RedirectToAction("VerNoticia", new { id = idNot }));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View(vm));
                }
            }
            else
            {
                return(View(vm));
            }
        }
        public ActionResult ReativarNoticia(NoticiaViewModel vm)
        {
            try
            {
                // Executa a operação
                Int32   idAss         = (Int32)Session["IdAssinante"];
                USUARIO usuarioLogado = (USUARIO)Session["UserCredentials"];
                NOTICIA item          = Mapper.Map <NoticiaViewModel, NOTICIA>(vm);
                Int32   volta         = baseApp.ValidateReativar(item, usuarioLogado, idAss);

                // Verifica retorno

                // Sucesso
                listaMaster             = new List <NOTICIA>();
                Session["ListaNoticia"] = null;
                Session["MensNoticia"]  = 0;
                return(RedirectToAction("MontarTelaNoticia"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(View(objeto));
            }
        }
예제 #34
0
 private void cargarNoticias()
 {
     NOTICIA noticia = new NOTICIA();
     List<NOTICIA> noticias = noticia.obtainAllNoticias();
     if (noticias != null && noticias.Count() > 0)
     {
         gridNoticias.DataSource = noticias;
         gridNoticias.DataBind();
     }
     limpiar();
 }