public override ISet <Item> CreateValue(Guid key, bool populate) { var set = new Set <Item>(); if (populate) { set.AddAsync(Fixture.Create <Item>()).Wait(); set.AddAsync(Fixture.Create <Item>()).Wait(); set.AddAsync(Fixture.Create <Item>()).Wait(); } return(set); }
public override ISet <string> CreateValue(int key, bool populate) { var set = new Set <string>(); if (populate) { set.AddAsync(Fixture.Create <string>()).Wait(); set.AddAsync(Fixture.Create <string>()).Wait(); set.AddAsync(Fixture.Create <string>()).Wait(); } return(set); }
public virtual async Task <T> CreateAsync(T item, CancellationToken cancellationToken = default) { var entry = await Set.AddAsync(item, cancellationToken); await _context.SaveChangesAsync(cancellationToken); return(entry.Entity); }
/// <summary> /// Add entity async /// </summary> /// <param name="entity"></param> /// <param name="cancellationToken"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> public virtual async Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) { if (entity is null) { throw new ArgumentNullException(nameof(entity)); } await Set.AddAsync(entity, cancellationToken); }
/// <summary> /// Adds an entity /// </summary> /// <param name="entity"></param> /// <returns></returns> public async Task <T> AddAsync(T entity) { await Set.AddAsync(entity); await context.CommitAsync(); return(entity); }
public async Task <bool> AddSingleAsync(TEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } await Set.AddAsync(entity); return(true); }
public async Task <ServiceResult <TimeEntry> > Create(NewTimeEntryModel model, string userId) { var member = await IsMember(model.ProjectId, userId); if (!member) { return(ServiceResult <TimeEntry> .Error("Вы не являетесь членом этого проекта")); } var entry = new TimeEntry(userId); entry.InjectFrom(model); await Set.AddAsync(entry); return(ServiceResult <TimeEntry> .Ok(entry)); }
public async Task <Order> CreateOrderAsync(Order order) { var entry = DbContext.Entry(order); if (entry.State == EntityState.Detached) { await Set.AddAsync(order); } var writes = await DbContext.SaveChangesAsync(); if (writes == 0) { throw new InsertUpdateException($"Expected order {order.OrderId} to be persisted"); } return(entry.Entity); }
public async Task <IActionResult> Add([FromBody] T item) { await Set.AddAsync(item); return(Ok(await Context.SaveChangesAsync())); }
public void AddAsync(TEntity entity) { Set.AddAsync(entity); }
public async Task AddAsync(T item) { await Set.AddAsync(item).ConfigureAwait(false); }
public async Task <TEntity> AddAsync(TEntity entity) { var entityEntry = await Set.AddAsync(entity); return(entityEntry.Entity); }
public async Task AddAsync(TEntity entity) { await Set.AddAsync(entity); }
public async Task AddAsync(TEntity entity) { await Set.AddAsync(entity).ConfigureAwait(false); }
public async Task <TEntity> AddAsync(TEntity entity) { TEntity e = (await Set.AddAsync(entity)).Entity; return(Ctx.SaveChanges() > 0 ? e : null); }
public virtual async Task <long> CreateAsync(T entity) { await Set.AddAsync(entity); return(entity.Id); }
public Task AddAsync(T item) { return(Set.AddAsync(item)); }
public async Task AddAsync(T item) { await Set.AddAsync(item).ConfigureAwait(false); await Context.SaveChangesAsync(); }