Exemple #1
0
        public async Task <IActionResult> GetContentValidity(string app, string schema, DomainId id)
        {
            var command = new ValidateContent {
                ContentId = id
            };

            await CommandBus.PublishAsync(command);

            return(NoContent());
        }
        public async Task <IActionResult> GetContentValidity(string app, string name, DomainId id)
        {
            var command = new ValidateContent {
                ContentId = id
            };

            var context = await CommandBus.PublishAsync(command);

            var result   = context.Result <ValidationResult>();
            var response = ValidationResultDto.FromResult(result);

            return(Ok(response));
        }
Exemple #3
0
        public async Task Validate_should_not_update_state()
        {
            await ExecuteCreateAsync();

            var command = new ValidateContent();

            var result = await PublishAsync(command);

            result.ShouldBeEquivalent(new ValidationResult {
                Errors = Array.Empty <ValidationError>()
            });

            Assert.Equal(0, sut.Snapshot.Version);
        }
 public virtual Response <ValidateResponse> Validate(ValidateContent content, CancellationToken cancellationToken = default)
 {
     using var scope = DefaultClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.Validate");
     scope.Start();
     try
     {
         var response = DefaultRestClient.Validate(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken);
         return(response);
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Exemple #5
0
        private async Task <ContentCommand> CreateCommandAsync(BulkTask task)
        {
            var job = task.CommandJob;

            switch (job.Type)
            {
            case BulkUpdateContentType.Create:
            {
                var command = new CreateContent();

                await EnrichAndCheckPermissionAsync(task, command, Permissions.AppContentsCreate);

                return(command);
            }

            case BulkUpdateContentType.Update:
            {
                var command = new UpdateContent();

                await EnrichAndCheckPermissionAsync(task, command, Permissions.AppContentsUpdateOwn);

                return(command);
            }

            case BulkUpdateContentType.Upsert:
            {
                var command = new UpsertContent();

                await EnrichAndCheckPermissionAsync(task, command, Permissions.AppContentsUpsert);

                return(command);
            }

            case BulkUpdateContentType.Patch:
            {
                var command = new PatchContent();

                await EnrichAndCheckPermissionAsync(task, command, Permissions.AppContentsUpdateOwn);

                return(command);
            }

            case BulkUpdateContentType.Validate:
            {
                var command = new ValidateContent();

                await EnrichAndCheckPermissionAsync(task, command, Permissions.AppContentsReadOwn);

                return(command);
            }

            case BulkUpdateContentType.ChangeStatus:
            {
                var command = new ChangeContentStatus {
                    Status = job.Status ?? Status.Draft
                };

                await EnrichAndCheckPermissionAsync(task, command, Permissions.AppContentsChangeStatusOwn);

                return(command);
            }

            case BulkUpdateContentType.Delete:
            {
                var command = new DeleteContent();

                await EnrichAndCheckPermissionAsync(task, command, Permissions.AppContentsDeleteOwn);

                return(command);
            }

            default:
                throw new NotSupportedException();
            }
        }
        public static void CanValidate(ValidateContent command, IContentEntity content)
        {
            Guard.NotNull(command, nameof(command));

            CheckPermission(content, command, Permissions.AppContentsRead);
        }
Exemple #7
0
        private async Task <ICommand> CreateCommandAsync(DomainId id, BulkTask task)
        {
            var job = task.Job;

            switch (job.Type)
            {
            case BulkUpdateType.Create:
            {
                var command = new CreateContent {
                    Data = job.Data !
                };

                await EnrichAsync(id, task, command, Permissions.AppContentsCreate);

                return(command);
            }

            case BulkUpdateType.Update:
            {
                var command = new UpdateContent {
                    Data = job.Data !
                };

                await EnrichAsync(id, task, command, Permissions.AppContentsUpdateOwn);

                return(command);
            }

            case BulkUpdateType.Upsert:
            {
                var command = new UpsertContent {
                    Data = job.Data !
                };

                await EnrichAsync(id, task, command, Permissions.AppContentsUpsert);

                return(command);
            }

            case BulkUpdateType.Patch:
            {
                var command = new PatchContent {
                    Data = job.Data !
                };

                await EnrichAsync(id, task, command, Permissions.AppContentsUpdateOwn);

                return(command);
            }

            case BulkUpdateType.Validate:
            {
                var command = new ValidateContent();

                await EnrichAsync(id, task, command, Permissions.AppContentsReadOwn);

                return(command);
            }

            case BulkUpdateType.ChangeStatus:
            {
                var command = new ChangeContentStatus {
                    Status = job.Status, DueTime = job.DueTime
                };

                await EnrichAsync(id, task, command, Permissions.AppContentsUpdateOwn);

                return(command);
            }

            case BulkUpdateType.Delete:
            {
                var command = new DeleteContent();

                await EnrichAsync(id, task, command, Permissions.AppContentsDeleteOwn);

                return(command);
            }

            default:
                throw new NotSupportedException();
            }
        }