コード例 #1
0
        private tbNoticia CastNoticia(NoticiaEntity noticia)
        {
            tbNoticia tb = new tbNoticia();

            tb.Ativo       = noticia.Ativo;
            tb.idCategoria = noticia.idCategoria;
            tb.Descricao   = noticia.Descricao;
            tb.titulo      = noticia.titulo;
            tb.dataHoraAte = noticia.dataHoraAte;
            tb.dataHoraDe  = noticia.dataHoraDe;
            tb.Sinopse     = noticia.Sinopse;
            tb.estado      = noticia.estado;
            //tb.filePathImagens = noticia.filePathImagens;

            return(tb);
        }
コード例 #2
0
        public bool DeletaNoticia(int id)
        {
            try
            {
                using (var context = new CirculoNegocioEntities())
                {
                    tbNoticia delete = (from p in context.tbNoticias where p.id == id select p).First();
                    context.tbNoticias.DeleteObject(delete);
                    context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #3
0
        public void AtualizaImagensNoticia(int idNoticia, string imgHome, string img1, string img2, string img3)
        {
            try
            {
                using (var context = new CirculoNegocioEntities())
                {
                    tbNoticia noticia = (from p in context.tbNoticias where p.id == idNoticia select p).First();

                    noticia.imagemHome = imgHome;
                    noticia.imagem1    = img1;
                    noticia.imagem2    = img2;
                    noticia.imagem3    = img3;

                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
        public int InsereNoticia(NoticiaEntity Noticia)
        {
            int idNoticia = 0;

            try
            {
                using (var context = new CirculoNegocioEntities())
                {
                    tbNoticia tb = CastNoticia(Noticia);
                    context.tbNoticias.AddObject(tb);
                    context.SaveChanges();

                    idNoticia = tb.id;
                }

                return(idNoticia);
            }
            catch (Exception)
            {
                return(0);
            }
        }