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); } }
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); } } }