public async Task HandleAsync(ChangeProductColorCommand command, CancellationToken cancellationToken = default)
        {
            var aggregateProduct = await _repo.GetAsync(command.Id, cancellationToken : cancellationToken);

            if (aggregateProduct == null)
            {
                throw new CannotFindException("No data on this Id");
            }

            aggregateProduct.ChangeProductColor(command);
            await _repo.SaveAsync(aggregateProduct, cancellationToken);
        }
Esempio n. 2
0
 public Task HandleAsync(ChangeProductColorCommand command)
 {
     return(_writeRepository.UpdateColorAsync(command.Color, command.Id));
 }
Esempio n. 3
0
 public void ChangeProductColor(ChangeProductColorCommand command)
 {
     ApplyChange(new ChangedProductColorEvent(command.Color, this, command));
 }
        public async Task <IActionResult> ChangeProductColor([FromBody] ChangeProductColorCommand command)
        {
            await _commandSender.SendAsync(command);

            return(Ok());
        }
        public async Task <IActionResult> ChangeProductColorAsync([FromBody] ChangeProductColorCommand command)
        {
            await Mediator.SendAsync(command).ConfigureAwait(false);

            return(Ok());
        }