コード例 #1
0
        public async Task Create(InsightDashboardPnDbContext dbContext)
        {
            CreatedAt     = DateTime.UtcNow;
            UpdatedAt     = DateTime.UtcNow;
            Version       = 1;
            WorkflowState = eForm.Infrastructure.Constants.Constants.WorkflowStates.Created;

            await dbContext.AddAsync(this).ConfigureAwait(false);

            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            var res = MapVersion(this);

            if (res != null)
            {
                await dbContext.AddAsync(res).ConfigureAwait(false);

                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
コード例 #2
0
        private async Task UpdateInternal(InsightDashboardPnDbContext dbContext, string state = null)
        {
            if (state != null)
            {
                WorkflowState = state;
            }

            if (dbContext.ChangeTracker.HasChanges())
            {
                Version  += 1;
                UpdatedAt = DateTime.UtcNow;

                await dbContext.SaveChangesAsync();

                var res = MapVersion(this);
                if (res != null)
                {
                    await dbContext.AddAsync(res).ConfigureAwait(false);

                    await dbContext.SaveChangesAsync().ConfigureAwait(false);
                }
            }
        }