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