public async Task <IHttpActionResult> PatchDraft(int pageId, Delta <UpdatePageDraftVersionCommand> delta)
        {
            // Custom patching because we may need to create a draft version first
            var command = await _queryExecutor.GetByIdAsync <UpdatePageDraftVersionCommand>(pageId);

            if (command == null)
            {
                var createDraftCommand = new AddPageDraftVersionCommand();
                createDraftCommand.PageId = pageId;
                await _commandExecutor.ExecuteAsync(createDraftCommand);

                command = await _queryExecutor.GetByIdAsync <UpdatePageDraftVersionCommand>(pageId);
            }

            delta.Patch(command);

            return(await _apiResponseHelper.RunCommandAsync(this, command));
        }
예제 #2
0
        /// <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&lt;GetByIdQuery&lt;TCommand&gt;&gt; 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, int id, Delta <TCommand> delta) where TCommand : class, ICommand
        {
            var command = await _queryExecutor.GetByIdAsync <TCommand>(id);

            if (delta != null)
            {
                delta.Patch(command);
            }

            return(await RunCommandAsync(controller, command));
        }
        public Task <UserMicroSummary> ExecuteAsync(GetCurrentUserMicroSummaryQuery query, IExecutionContext executionContext)
        {
            if (!executionContext.UserContext.UserId.HasValue)
            {
                return(null);
            }

            var user = _queryExecutor.GetByIdAsync <UserMicroSummary>(executionContext.UserContext.UserId.Value);

            return(user);
        }
예제 #4
0
        public async Task <CustomEntityDataModelSchema> ExecuteAsync(GetByStringQuery <CustomEntityDataModelSchema> query, IExecutionContext executionContext)
        {
            var definition = await _queryExecutor.GetByIdAsync <CustomEntityDefinitionSummary>(query.Id);

            if (definition == null)
            {
                return(null);
            }

            var result = new CustomEntityDataModelSchema();

            _dynamicDataModelTypeMapper.Map(result, definition.DataModelType);

            return(result);
        }
예제 #5
0
        public async Task <CustomEntityRenderSummary> MapSummaryAsync(
            CustomEntityVersion dbResult,
            IExecutionContext executionContext
            )
        {
            var routingQuery = GetPageRoutingQuery(dbResult);
            var routing      = await _queryExecutor.ExecuteAsync(routingQuery, executionContext);

            ActiveLocale locale = null;

            if (dbResult.CustomEntity.LocaleId.HasValue)
            {
                locale = await _queryExecutor.GetByIdAsync <ActiveLocale>(dbResult.CustomEntity.LocaleId.Value, executionContext);
            }

            return(MapSingle(dbResult, routing, locale));
        }
        public async Task <PageRenderDetails> ExecuteAsync(GetPageRenderDetailsByIdQuery query, IExecutionContext executionContext)
        {
            var dbPage = await QueryPage(query).FirstOrDefaultAsync();

            if (dbPage == null)
            {
                return(null);
            }
            var page = Mapper.Map <PageRenderDetails>(dbPage);

            page.PageRoute = await _queryExecutor.GetByIdAsync <PageRoute>(page.PageId, executionContext);

            var dbModules = await QueryModules(page).ToListAsync();

            var allModuleTypes = await _queryExecutor.GetAllAsync <PageModuleTypeSummary>(executionContext);

            _entityVersionPageModuleMapper.MapSections(dbModules, page.Sections, allModuleTypes, query.WorkFlowStatus);

            return(page);
        }
 public Task <PageModuleTypeDetails> GetPageModuleTypeDetailsByIdAsync(int id, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.GetByIdAsync <PageModuleTypeDetails>(id, executionContext));
 }
        public async Task <IHttpActionResult> Get(int webDirectoryId)
        {
            var result = await _queryExecutor.GetByIdAsync <WebDirectoryNode>(webDirectoryId);

            return(_apiResponseHelper.SimpleQueryResponse(this, result));
        }
예제 #9
0
 public Task <CustomEntityDefinitionMicroSummary> GetCustomEntityDefinitionMicroSummaryByIdAsync(string customEntityDefinitionCode, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.GetByIdAsync <CustomEntityDefinitionMicroSummary>(customEntityDefinitionCode, executionContext));
 }
예제 #10
0
 /// <summary>
 /// Returns a web directory with the specified id as a WebDirectoryRoute instance.
 /// </summary>
 /// <param name="webDirectoryId">WebDirectoryId of the directory to get.</param>
 /// <param name="executionContext">Optional execution context to use when executing the query. Useful if you need to temporarily elevate your permission level.</param>
 public Task <WebDirectoryRoute> GetWebDirectoryRouteByIdAsync(int webDirectoryId, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.GetByIdAsync <WebDirectoryRoute>(webDirectoryId, executionContext));
 }
예제 #11
0
 public Task <ImageAssetDetails> GetImageAssetDetailsByIdAsync(int imageAssetId, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.GetByIdAsync <ImageAssetDetails>(imageAssetId, executionContext));
 }
        public async Task <IHttpActionResult> Get(string customEntityDefinitionCode)
        {
            var result = await _queryExecutor.GetByIdAsync <CustomEntityDefinitionSummary>(customEntityDefinitionCode);

            return(_apiResponseHelper.SimpleQueryResponse(this, result));
        }
예제 #13
0
 /// <summary>
 /// Finds a user by a database id returning a UserDetails object if it
 /// is found, otherwise null.
 /// </summary>
 /// <param name="userId">The database id of the user to find.</param>
 /// <param name="executionContext">Optional execution context to use when executing the query. Useful if you need to temporarily elevate your permission level.</param>
 public Task <UserDetails> GetUserDetailsByIdAsync(int userId, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.GetByIdAsync <UserDetails>(userId, executionContext));
 }
예제 #14
0
 public Task <DocumentAssetDetails> GetDocumentAssetDetailsByIdAsync(int documentAssetId, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.GetByIdAsync <DocumentAssetDetails>(documentAssetId, executionContext));
 }
예제 #15
0
        private async Task <IHttpActionResult> GetById <T>(int pageVersionModuleId)
        {
            var results = await _queryExecutor.GetByIdAsync <T>(pageVersionModuleId);

            return(_apiResponseHelper.SimpleQueryResponse(this, results));
        }
예제 #16
0
        public async Task <IHttpActionResult> Get(int userId)
        {
            var result = await _queryExecutor.GetByIdAsync <UserDetails>(userId);

            return(_apiResponseHelper.SimpleQueryResponse(this, result));
        }
예제 #17
0
        public async Task <IHttpActionResult> Get(int documentAssetId)
        {
            var result = await _queryExecutor.GetByIdAsync <DocumentAssetDetails>(documentAssetId);

            return(_apiResponseHelper.SimpleQueryResponse(this, result));
        }
        public async Task <IHttpActionResult> Get(int pageModuleTypeId)
        {
            var results = await _queryExecutor.GetByIdAsync <PageModuleTypeDetails>(pageModuleTypeId);

            return(_apiResponseHelper.SimpleQueryResponse(this, results));
        }
예제 #19
0
 public Task <PageRoute> GetPageRouteByIdAsync(int pageId, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.GetByIdAsync <PageRoute>(pageId, executionContext));
 }