public async Task <int> DeleteAsync(UserCategory userCategory) { _context.Remove(userCategory); int removed = await _context.SaveChangesAsync(); return(removed); }
public async Task <bool> DeletePostAsync(int id) { var entity = await _context.Posts.FindAsync(id); if (entity == null) { throw new Exception("Could not find post"); } _context.Remove(entity); var success = await _context.SaveChangesAsync() > 0; if (success) { return(true); } throw new Exception("Problem saving changes"); }
public async Task RemoveAsync(TEntity entity) { _context.Remove(entity); await _context.SaveChangesAsync(); }
public async Task Delete(T entity) { using var context = new BlogAppContext(); context.Remove(entity); await context.SaveChangesAsync(); }