private IEnumerable <ValidationResult> Validate(ModuleSourceUpdateLocationCommand command)
        {
            var validationResultsBuilder = new ValidationResultsBuilder();

            validationResultsBuilder.Validate(FileSystemModuleSourceLocation.IsValid, command.Location, nameof(command.Location));

            return(validationResultsBuilder.GetValidationResults());
        }
Exemple #2
0
        public async Task <IActionResult> UpdateLocation(ModuleSourceUpdateLocationModel model)
        {
            var command       = new ModuleSourceUpdateLocationCommand(model.Id, model.ConcurrencyToken, model.Location);
            var commandResult = await _messageDispatcher.DispatchAsync(command);

            if (commandResult.IsSuccess)
            {
                return(RedirectToAction(nameof(Details), new { id = model.Id }));
            }

            return(GetActionResult(commandResult, model));
        }
        public IDispatchResult Handle(ModuleSourceUpdateLocationCommand command)
        {
            var validationResults = Validate(command);

            if (validationResults.Any())
            {
                return(ValidationFailure(validationResults));
            }

            if (Entity is FileSystemModuleSource fileSystemModuleSource)
            {
                fileSystemModuleSource.Location = (FileSystemModuleSourceLocation)command.Location;
                return(Success());
            }

            return(Failure());
        }