public async Task HandleAsync(ChangeProductDiscountCommand 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.ChangeProductDiscount(command);
            await _repo.SaveAsync(aggregateProduct, cancellationToken);
        }
Beispiel #2
0
 public Task HandleAsync(ChangeProductDiscountCommand command)
 {
     return(_writeRepository.UpdateDiscountAsync(command.Discount, command.Id));
 }
Beispiel #3
0
 public void ChangeProductDiscount(ChangeProductDiscountCommand command)
 {
     ValidateDiscount(command.Discount);
     ApplyChange(new ChangedProductDiscountEvent(command.Discount, this, command));
 }
        public async Task <IActionResult> ChangeProductDiscount([FromBody] ChangeProductDiscountCommand command)
        {
            await _commandSender.SendAsync(command);

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

            return(Ok());
        }