public async Task ExecuteAsync(RegisterPageTemplatesCommand command, IExecutionContext executionContext) { var dbPageTemplates = await _dbContext .PageTemplates .Include(t => t.PageTemplateSections) .ToDictionaryAsync(d => d.FileName); var fileTemplates = _pageTemplateViewFileLocator .GetPageTemplateFiles(); DetectDuplicateTemplates(fileTemplates); // Mark removed templates as deleted await DeleteTemplates(executionContext, dbPageTemplates, fileTemplates); await UpdateTemplates(executionContext, dbPageTemplates, fileTemplates); // Save changes await _dbContext.SaveChangesAsync(); _pageCache.Clear(); }
public async Task ExecuteAsync(RegisterPageTemplatesCommand command, IExecutionContext executionContext) { var dbPageTemplates = (await _dbContext .PageTemplates .Include(t => t.PageTemplateRegions) .ToListAsync()) .ToLookup(d => d.FileName); var fileTemplates = _pageTemplateViewFileLocator .GetPageTemplateFiles() .ToList(); DetectDuplicateTemplates(fileTemplates); // Mark removed templates as deleted await DeleteTemplates(executionContext, dbPageTemplates, fileTemplates); await UpdateTemplates(executionContext, dbPageTemplates, fileTemplates); // Save changes await _dbContext.SaveChangesAsync(); _transactionScopeFactory.QueueCompletionTask(_dbContext, _pageCache.Clear); }