Пример #1
0
        public async Task Create(ItemsGroupPlanningPnDbContext 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();
            }
        }
Пример #2
0
        private async Task UpdateInternal(ItemsGroupPlanningPnDbContext 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();
                }
            }
        }