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); }
public Task HandleAsync(ChangeProductDiscountCommand command) { return(_writeRepository.UpdateDiscountAsync(command.Discount, command.Id)); }
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()); }