public async Task Create(ItemsPlanningPnDbContext dbContext) { CreatedAt = DateTime.UtcNow; UpdatedAt = DateTime.UtcNow; Version = 1; WorkflowState = Constants.WorkflowStates.Created; await dbContext.AddAsync(this); await dbContext.SaveChangesAsync(); var res = MapVersion(this); if (res != null) { await dbContext.AddAsync(res); await dbContext.SaveChangesAsync(); } }
private async Task UpdateInternal(ItemsPlanningPnDbContext 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); await dbContext.SaveChangesAsync(); } } }