public async Task HandleAsync(ProcessTurnCommand command, CancellationToken cancellationToken = new CancellationToken())
        {
            var currentMatch = await _matchRepository.GetByIdAsync(command.MatchId);

            if (currentMatch == null)
            {
                throw new ArgumentException("The match could not be found");
            }
            currentMatch.Apply(command);
            await _matchRepository.SaveAsync(currentMatch, cancellationToken);
        }
        // [CommandHandler] // To allow this method to be registered through attribute registration.
        public async Task HandleAsync(ActivateProductCommand command, CancellationToken cancellationToken = default(CancellationToken))
        {
            Product product = await _productRepository.GetByIdAsync(command.ProductId);

            if (product == null)
            {
                throw new ProductNotFoundException("Product not found.");
            }

            product.Activate();

            await _productRepository.SaveAsync(product);
        }
        public async Task HandleAsync(SubmitMovesCommand command, CancellationToken cancellationToken = new CancellationToken())
        {
            if (!DeploymentCreditValidator.ValidDeployment(command.Deployments))
            {
                throw new ArgumentException("Exceeded deployment credit allotment for move");
            }

            var currentMatch = await _matchRepository.GetByIdAsync(command.Match);

            if (currentMatch == null)
            {
                throw new ArgumentException("The match could not be found");
            }
            currentMatch.Apply(command);
            await _matchRepository.SaveAsync(currentMatch, cancellationToken);
        }
 /// <summary>
 /// Get aggregate root by ID.
 /// </summary>
 /// <param name="aggregateRootId">Aggregate root ID.</param>
 /// <param name="cancellationToken">Cancellation token.</param>
 /// <returns>Instance of aggregate root.</returns>
 public Task <TAggregateRoot> GetByIdAsync(Guid aggregateRootId, CancellationToken cancellationToken = default(CancellationToken))
 => _decoratedRepository.GetByIdAsync(aggregateRootId, cancellationToken);
Ejemplo n.º 5
0
 public async Task <ApiResource> GetLoadAsync(Guid id)
 {
     return(await _apiResourceRepository.GetByIdAsync(id));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Get aggregate root by ID.
 /// </summary>
 /// <param name="aggregateRootId">Aggregate root ID.</param>
 /// <param name="cancellationToken">Cancellation token.</param>
 /// <returns>Instance of aggregate root.</returns>
 public Task <TAggregateRoot> GetByIdAsync(Guid aggregateRootId, CancellationToken cancellationToken = default(CancellationToken))
 => _inner.GetByIdAsync(aggregateRootId, cancellationToken);