public async Task <T> Get(Guid id) { using (InventoryManagerDbContext context = _contextFactory.CreateDbContext()) { T entity = await context.Set <T>().FirstOrDefaultAsync((e) => e.id == id); return(entity); } }
public async Task <T> Create(T entity) { using (InventoryManagerDbContext context = _contextFactory.CreateDbContext()) { EntityEntry <T> createdResult = await context.Set <T>().AddAsync(entity); await context.SaveChangesAsync(); return(createdResult.Entity); } }