public async Task <bool> DeleteAsync(int id) { var entity = await _context.FindAsync <T>(id); _context.Remove(entity); await _context.SaveChangesAsync(); return(true); }
public async Task DeleteAsync(TEntity entity) { if (entity == null) { throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null"); } try { _context.Remove(entity); await _context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception($"{nameof(entity)} could not be saved: {ex.Message}"); } }