Esempio n. 1
0
        /// <summary>
        /// Creates the page with the given name.
        /// </summary>
        /// <param name="spaceName">Name of the space that the page should be created in.</param>
        /// <param name="pageName">Name of the page to create.</param>
        /// <param name="sourceFile">The file to read the initial page content from.</param>
        /// <returns>Task.</returns>
        public async Task CreatePage(SpaceName spaceName, PageName pageName, FileInfo sourceFile)
        {
            string content = await File.ReadAllTextAsync(sourceFile.FullName);

            var input = new CreatePageInput(spaceName, pageName, content);
            await _mediator.PublishAsync(input);
        }
Esempio n. 2
0
        public async Task <IActionResult?> Create(
            [FromRoute, Required(AllowEmptyStrings = false)] string spaceName,
            [FromRoute, Required(AllowEmptyStrings = false)] string pageName,
            [FromBody, Required] CreatePageRequest request)
        {
            var input = new CreatePageInput(new SpaceName(spaceName), new PageName(pageName), request.Content);
            await _mediator.PublishAsync(input);

            return(_presenter.ViewModel);
        }
Esempio n. 3
0
        /// <inheritdoc/>
        public async Task Execute(CreatePageInput input)
        {
            try
            {
                ISpace space = await _spaceRepository.Get(input.SpaceName);

                IPage page = await _pageService.CreatePage(space, input.PageName, input.Content);

                _outputPort.Standard(new CreatePageOutput(page));
            }
            catch (SpaceNotFoundException e)
            {
                _outputPort.SpaceNotFound(e.Message);
            }
            catch (PageAlreadyExistsException e)
            {
                _outputPort.PageAlreadyExists(e.Message);
            }
            catch (UnableToCreatePageException e)
            {
                _outputPort.UnableToCreatePage(e.Message);
            }
        }