public async Task <T> CreateItemAsync(T item) { var entityEntry = await dataContext.AddAsync(item); await dataContext.SaveChangesAsync(); return(entityEntry.Entity); }
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)); }
public async Task <TEntity> AddAsync <TEntity>(TEntity entity) where TEntity : class => await _dataContext.AddAsync(entity);