Esempio n. 1
0
        public async Task <IActionResult> PostContent(string app, string name, [FromBody] NamedContentData request, [FromQuery] bool publish = false)
        {
            await contentQuery.ThrowIfSchemaNotExistsAsync(Context().WithSchemaName(name));

            var command = new CreateContent {
                ContentId = Guid.NewGuid(), Data = request.ToCleaned(), Publish = publish
            };

            var context = await CommandBus.PublishAsync(command);

            var result   = context.Result <EntityCreatedResult <NamedContentData> >();
            var response = ContentDto.FromCommand(command, result);

            return(CreatedAtAction(nameof(GetContent), new { id = command.ContentId }, response));
        }
Esempio n. 2
0
        public async Task <IActionResult> PostContent(string app, string name, [FromBody] NamedContentData request, [FromQuery] bool publish = false)
        {
            await contentQuery.ThrowIfSchemaNotExistsAsync(Context(), name);

            var publishPermission = Permissions.ForApp(Permissions.AppContentsPublish, app, name);

            if (publish && !User.Permissions().Includes(publishPermission))
            {
                return(new StatusCodeResult(123));
            }

            var command = new CreateContent {
                ContentId = Guid.NewGuid(), Data = request.ToCleaned(), Publish = publish
            };

            var context = await CommandBus.PublishAsync(command);

            var result   = context.Result <EntityCreatedResult <NamedContentData> >();
            var response = ContentDto.FromCommand(command, result);

            return(CreatedAtAction(nameof(GetContent), new { id = command.ContentId }, response));
        }