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); }
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); } }
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; } }
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); } }