public TEntity Get(int id) { if (id < 1) { throw new ArgumentOutOfRangeException(NameOf.nameof(() => id)); } return(_entities.FirstOrDefault(e => e.Id == id)); }
public bool Has(int id) { if (id < 1) { throw new ArgumentOutOfRangeException(NameOf.nameof(() => id)); } return(_entities.Any(e => e.Id == id)); }
public int Add(TEntity entity) { if (entity == null) { throw new ArgumentNullException(NameOf.nameof(() => entity)); } _entities.Add(entity); _context.SaveChanges(); return(entity.Id); }
public void Remove(int id) { if (id < 1) { throw new ArgumentOutOfRangeException(NameOf.nameof(() => id)); } var entity = this.Get(id); if (entity == null) { return; } _entities.Remove(entity); _context.SaveChanges(); }