コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 /// <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);
 }
コード例 #5
0
ファイル: SyncService.cs プロジェクト: sebcam/CrossSync
        /// <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);
        }
コード例 #6
0
        public async Task <bool> AddSingleAsync(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            await Set.AddAsync(entity);

            return(true);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: BaseEntityController.cs プロジェクト: lulzzz/Dockka
        public async Task <IActionResult> Add([FromBody] T item)
        {
            await Set.AddAsync(item);

            return(Ok(await Context.SaveChangesAsync()));
        }
コード例 #10
0
 public void AddAsync(TEntity entity)
 {
     Set.AddAsync(entity);
 }
 public async Task AddAsync(T item)
 {
     await Set.AddAsync(item).ConfigureAwait(false);
 }
コード例 #12
0
        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);
 }
コード例 #14
0
 public async Task AddAsync(TEntity entity)
 {
     await Set.AddAsync(entity).ConfigureAwait(false);
 }
コード例 #15
0
ファイル: Repository.cs プロジェクト: Nenuu11/MiniFacebookApp
        public async Task <TEntity> AddAsync(TEntity entity)
        {
            TEntity e = (await Set.AddAsync(entity)).Entity;

            return(Ctx.SaveChanges() > 0 ? e : null);
        }
コード例 #16
0
        public virtual async Task <long> CreateAsync(T entity)
        {
            await Set.AddAsync(entity);

            return(entity.Id);
        }
コード例 #17
0
 public Task AddAsync(T item)
 {
     return(Set.AddAsync(item));
 }
コード例 #18
0
        public async Task AddAsync(T item)
        {
            await Set.AddAsync(item).ConfigureAwait(false);

            await Context.SaveChangesAsync();
        }