public async Task <UpdateGeneralSiteSettingsCommand> ExecuteAsync(GetUpdateCommandQuery <UpdateGeneralSiteSettingsCommand> query, IExecutionContext executionContext) { var settings = await _queryExecutor.ExecuteAsync(new GetSettingsQuery <GeneralSiteSettings>(), executionContext); return(new UpdateGeneralSiteSettingsCommand() { AllowAutomaticUpdates = settings.AllowAutomaticUpdates, ApplicationName = settings.ApplicationName }); }
public async Task <UpdateSeoSettingsCommand> ExecuteAsync(GetUpdateCommandQuery <UpdateSeoSettingsCommand> query, IExecutionContext executionContext) { var settings = await _queryExecutor.ExecuteAsync(new GetSettingsQuery <SeoSettings>(), executionContext); return(new UpdateSeoSettingsCommand() { HumansTxt = settings.HumansTxt, RobotsTxt = settings.RobotsTxt }); }
/// <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 Controller instance using the helper</param> /// <param name="delta">The delta of the command to patch and execute</param> public async Task <IActionResult> RunCommandAsync <TCommand>(ControllerBase controller, IDelta <TCommand> delta) where TCommand : class, ICommand { var query = new GetUpdateCommandQuery <TCommand>(); var command = await _queryExecutor.ExecuteAsync(query); if (delta != null) { delta.Patch(command); } return(await RunCommandAsync(controller, command)); }