private tbBanner CastBanner(BannerEntity banner) { tbBanner tb = new tbBanner(); tb.Ativo = banner.Ativo; tb.dataAte = banner.dataAte; tb.dataDe = banner.dataDe; tb.estado = banner.estado; tb.idCliente = banner.idCliente; tb.idTipoBanner = banner.idTipoBanner; tb.responsavelUltimaAlteracao = banner.responsavelUltimaAlteracao; tb.DataUltimaAlteracao = banner.DataUltimaAlteracao; return(tb); }
public void AtualizaFilePathImagemBanner(int idBanner, string filePath) { try { using (var context = new CirculoNegocioEntities()) { tbBanner banner = (from p in context.tbBanners where p.id == idBanner select p).First(); banner.imagemFilePath = filePath; context.SaveChanges(); } } catch (Exception) { throw; } }
public bool DeletaBanner(int id) { try { using (var context = new CirculoNegocioEntities()) { tbBanner delete = (from p in context.tbBanners where p.id == id select p).First(); context.tbBanners.DeleteObject(delete); context.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public int InsereBanner(BannerEntity banner) { int idBanner = 0; try { using (var context = new CirculoNegocioEntities()) { tbBanner tb = CastBanner(banner); context.tbBanners.AddObject(tb); context.SaveChanges(); idBanner = tb.id; } return(idBanner); } catch (Exception) { return(0); } }