Пример #1
0
        public async Task <T> AddAsync(T entity, CancellationToken cancellationToken = default)
        {
            await _dbContext.Set <T>().AddAsync(entity, cancellationToken);

            await _dbContext.SaveChangesAsync(cancellationToken);

            return(entity);
        }
Пример #2
0
        public async Task <Inventory> AddAsync(Inventory entity, CancellationToken cancellationToken = default)
        {
            var itemId = new object[] { entity.Item.Id };
            var item   = await _dbContext.Items.FindAsync(itemId, cancellationToken);

            entity.Item = item;
            await _dbContext.Inventory.AddAsync(entity, cancellationToken);

            await _dbContext.SaveChangesAsync(cancellationToken);

            return(entity);
        }