public async Task <T> CreateItemAsync(T item)
        {
            var entityEntry = await dataContext.AddAsync(item);

            await dataContext.SaveChangesAsync();

            return(entityEntry.Entity);
        }
Beispiel #2
0
        public async Task <TModel> AddAsync(TModel model)
        {
            if (model == null)
            {
                throw new UnknownModelException(typeof(TModel));
            }
            TModel existingModel = await FindByIdAsync(model.Id);

            if (existingModel != null)
            {
                throw new DuplicateModelException(model.Id, typeof(TModel));
            }
            return(await _dataContext.AddAsync(model));
        }
Beispiel #3
0
 public async Task <TEntity> AddAsync <TEntity>(TEntity entity) where TEntity : class =>
 await _dataContext.AddAsync(entity);