public async Task ExecuteAsync(SetupCofoundryCommand command, IExecutionContext executionContext) { var settings = _queryExecutor.Get <InternalSettings>(); if (settings.IsSetup) { throw new ApplicationException("Site is already set up."); } using (var scope = _transactionScopeFactory.Create()) { var userId = await CreateAdminUser(command); var impersonatedUserContext = await GetImpersonatedUserContext(executionContext, userId); var settingsCommand = await _queryExecutor.GetAsync <UpdateGeneralSiteSettingsCommand>(); settingsCommand.ApplicationName = command.ApplicationName; await _commandExecutor.ExecuteAsync(settingsCommand, impersonatedUserContext); // Take the opportunity to break the cache in case any additional install scripts have been run since initialization _objectCacheFactory.Clear(); // Setup Complete await _commandExecutor.ExecuteAsync(new MarkAsSetUpCommand(), impersonatedUserContext); scope.Complete(); } }
/// <summary> /// Executes a command in a "Patch" style, allowing for a partial update of a resource. In /// order to support this method, there must be a query handler defined that implements /// IQueryHandler<GetQuery<TCommand>> so the full command object can be fecthed /// prior to patching. Once patched and executed, a formatted IHttpActionResult is returned, /// handling any validation errors and permission errors. /// </summary> /// <typeparam name="TCommand">Type of the command to execute</typeparam> /// <param name="controller">The ApiController instance using the helper</param> /// <param name="delta">The delta of the command to patch and execute</param> public async Task <IHttpActionResult> RunCommandAsync <TCommand>(ApiController controller, Delta <TCommand> delta) where TCommand : class, ICommand { var command = await _queryExecutor.GetAsync <TCommand>(); if (delta != null) { delta.Patch(command); } return(await RunCommandAsync(controller, command)); }
public async Task <UpdateSeoSettingsCommand> ExecuteAsync(GetQuery <UpdateSeoSettingsCommand> query, IExecutionContext executionContext) { var settings = await _queryExecutor.GetAsync <SeoSettings>(); return(Mapper.Map <UpdateSeoSettingsCommand>(settings)); }
public async Task <IHttpActionResult> GetGeneralSiteSettings() { var results = await _queryExecutor.GetAsync <GeneralSiteSettings>(); return(_apiResponseHelper.SimpleQueryResponse(this, results)); }