Exemplo n.º 1
0
        protected void CarregarNoticia()
        {
            if (Request.QueryString["ID"] != null)
            {
                int id = int.Parse(Request.QueryString["ID"]);

                Noticia_Model m  = new Noticia_Model();
                noticia       nt = new noticia();

                nt = m.Obter(id);

                txtTituloNoticia.Text      = nt.titulo_postagem;
                edtNoticia.Value           = nt.corpo_noticia;
                ddPrioridade.SelectedValue = nt.prioridade.ToString();

                String url = nt.imagem_caminho + nt.imagem_nome;

                imgImagemCarregada.ImageUrl = url;

                btnSalvarNoticia.Text = "Salvar Notícia";
            }
            else
            {
                btnSalvarNoticia.Text = "Publicar Notícia";
            }
        }
Exemplo n.º 2
0
 public string update_noticia(noticia obj)
 {
     if (obj_noticia.update_noticia(obj))
     {
         return("U200");
     }
     else
     {
         return("U500");
     }
 }
Exemplo n.º 3
0
 public string insert_noticia(noticia obj)
 {
     if (obj_noticia.insert_noticia(obj))
     {
         return("I200");
     }
     else
     {
         return("I500");
     }
 }
        protected bool CarregarDados(int id)
        {
            try
            {
                Noticia_Model model = new Noticia_Model();

                ntc = model.Obter(id);

                return(true);
            }
            catch (Exception e)
            {
                Master.Alerta(e.Message);
                return(false);
            }
        }
Exemplo n.º 5
0
        public noticia[] data()
        {
            DataTable dt = obj_noticia.get_noticia();
            DataRow   row;

            noticia[] noticias = null;
            if (dt.Rows.Count > 0)
            {
                noticias = new noticia[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    row         = dt.Rows[i];
                    noticias[i] = new noticia(Convert.ToInt64(row["ncia_idnoticia"].ToString()), row["ncia_titulo"].ToString(), row["ncia_rutaimagen"].ToString(), row["ncia_descripcion"].ToString(), row["ncia_fechapublicacion"].ToString(), row["ncia_mostrardesde"].ToString(), row["ncia_mostrarhasta"].ToString(), row["ncia_estado"].ToString(), Convert.ToInt32(row["smlr_idsemillero"].ToString()), Convert.ToInt64(row["user_idusuario"].ToString()), row["ncia_linkvideo"].ToString(), Convert.ToInt32(row["tntc_idtipo_noticia"].ToString()), row["ncia_rutaadjunto"].ToString());
                }
            }
            return(noticias);
        }
Exemplo n.º 6
0
 public ActionResult Alterar(int id, noticia collection)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
              _noticiaService.UpdateNoticia(collection);
             return RedirectToAction("Index");
         }
         return View(collection);
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 7
0
        public bool Inserir(noticia a)
        {
            // função para cadastrar
            try
            {
                Table <noticia> tb = getTable();

                tb.InsertOnSubmit(a);
                tb.Context.SubmitChanges();

                return(true);
            }
            catch (Exception e)
            {
                message = e.Message;
                return(false);
            }
        }
Exemplo n.º 8
0
        public bool Inserir(noticia a)
        {
            // função para cadastrar
            try
            {
                Table<noticia> tb = getTable();

                tb.InsertOnSubmit(a);
                tb.Context.SubmitChanges();

                return true;
            }
            catch(Exception e)
            {
                message = e.Message;
                return false;
            }
        }
        public ActionResult Create(noticia insertnoticia)
        {
            HttpClient hc = new HttpClient();

            hc.BaseAddress = new Uri("https://localhost:44316/api/NoticiaCrud");

            var insertrecord = hc.PostAsJsonAsync <noticia>("NoticiaCrud", insertnoticia);

            insertrecord.Wait();

            var guardardata = insertrecord.Result;

            if (guardardata.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }

            return(View("Create"));
        }
Exemplo n.º 10
0
        public bool Alterar(noticia a)
        {
            try
            {
                dbDataContext   context = getDataContext();
                Table <noticia> tb      = getTable();

                context.alteraNoticia(a.id, a.imagem_nome, a.imagem_caminho, a.titulo_postagem,
                                      a.corpo_noticia, a.id_mediador_edicao, a.id_local_edicao, a.data_edicao, a.prioridade);

                tb.Context.SubmitChanges();

                return(true);
            }
            catch (Exception e)
            {
                message = e.Message;
                return(false);
            }
        }
Exemplo n.º 11
0
        public bool Alterar(noticia a)
        {
            try
            {
                dbDataContext context = getDataContext();
                Table<noticia> tb = getTable();

                context.alteraNoticia(a.id, a.imagem_nome, a.imagem_caminho, a.titulo_postagem,
                    a.corpo_noticia, a.id_mediador_edicao, a.id_local_edicao, a.data_edicao, a.prioridade);

                tb.Context.SubmitChanges();

                return true;
            }
            catch (Exception e)
            {
                message = e.Message;
                return false;
            }
        }
Exemplo n.º 12
0
        protected void SalvarNoticia()
        {
            // Validar se esta editando ou postando nova
            // se estiver editando, alterar somente titulo, texto e imagem, mantendo a data
            try
            {
                if (Validar())
                {
                    configuracao       c  = new configuracao();
                    Configuracao_Model mc = new Configuracao_Model();

                    c = mc.Obter("medPortal");

                    // salva o caminho das imagens no servidor ftp
                    String caminho = c.caminho_images;
                    // pega o nome da imagem carregada na tela
                    String nome = Path.GetFileName(imgImagemCarregada.ImageUrl);

                    // declara objeto noticia
                    noticia n = new noticia();
                    // declara objeto noticia_model
                    Noticia_Model model = new Noticia_Model();
                    // pega o mediador logado
                    mediador med = Session["med"] as mediador;

                    n.titulo_postagem = txtTituloNoticia.Text;
                    n.corpo_noticia   = edtNoticia.Value;
                    n.imagem_caminho  = caminho;
                    n.imagem_nome     = nome;
                    n.prioridade      = int.Parse(ddPrioridade.SelectedValue);

                    if (Request.QueryString["ID"] != null)
                    {
                        // se tem ID, altera
                        int id = int.Parse(Request.QueryString["ID"]);

                        n.id                 = id;
                        n.data_edicao        = DateTime.Now;
                        n.id_local_edicao    = med.id_local;
                        n.id_mediador_edicao = med.id;

                        if (model.Alterar(n))
                        {
                            Master.Sucesso("Notícia alterada!");
                            Response.Redirect("noticias.aspx");
                        }
                        else
                        {
                            Master.Alerta("Erro: " + model.message);
                        }
                    }
                    else
                    {
                        // se não tem ID, insere
                        n.data_postagem = DateTime.Now;
                        n.id_local      = med.id_local;
                        n.id_mediador   = med.id;

                        if (model.Inserir(n))
                        {
                            Master.Sucesso("Notícia postada!");
                            Response.Redirect("noticias.aspx");
                        }
                        else
                        {
                            Master.Alerta("Erro: " + model.message);
                        }
                    }
                }
            }
            catch (Exception Exc)
            {
                Master.Alerta("Erro: " + Exc.Message);
            }
        }
Exemplo n.º 13
0
        //
        // GET: /Conteudo/album/Create
        //[Authorize(Roles="admin")]
        public ActionResult Incluir()
        {
            var obj = new noticia();

            return View(obj);
        }
Exemplo n.º 14
0
 public IHttpActionResult Insertnoticia(noticia insertnoticia)
 {
     uniwebsite.noticias.Add(insertnoticia);
     uniwebsite.SaveChanges();
     return(Ok());
 }
Exemplo n.º 15
0
 public ActionResult Incluir(noticia collection)
 {
     try
     {
         // TODO: Add insert logic here
         var obj = collection;
         if (ModelState.IsValid)
         {
             obj.usuario = new usuario { Id = 1 };
             obj.DtCadastro = DateTime.Now;
             _noticiaService.CreateNoticia(obj);
             return RedirectToAction("Index");
         }
         else return View(collection);
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 16
0
 public noticia CreateNoticia(noticia noticia)
 {
     /* Not used UnitOfWork attribute, because this method only calls one repository method and repoository can manage it's connection/transaction. */
     _noticiaRepository.Insert(noticia);
     return _noticiaRepository.Get(noticia.Id);
 }
Exemplo n.º 17
0
 public void UpdateNoticia(noticia noticia)
 {
     /* Not used UnitOfWork attribute, because this method only calls one repository method and repoository can manage it's connection/transaction. */
     _noticiaRepository.Update(noticia);
 }