public void Ataulizar(TblAutor autor) { try { using (ContextBlog con = new ContextBlog()) { con.Entry(autor).State = EntityState.Modified; if (string.IsNullOrEmpty(autor.Foto)) { con.Entry(autor).Property(p => p.Foto).IsModified = false; } con.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Ataulizar(TblPost categoria) { try { using (ContextBlog con = new ContextBlog()) { con.Entry(categoria).State = EntityState.Modified; con.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Excluir(TblPost categoria) { try { using (ContextBlog con = new ContextBlog()) { con.Entry(categoria).State = categoria.Id == 0 ? EntityState.Added : EntityState.Deleted; con.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Excluir(TblAutor autor) { try { using (ContextBlog con = new ContextBlog()) { con.Entry(autor).State = autor.Id == 0 ? EntityState.Added : EntityState.Deleted; con.SaveChanges(); } } catch (Exception ex) { throw ex; } }