public async Task <IActionResult> ChangeProductPrice(string productId, string price) { var command = new ChangeProductPriceCommand { Id = productId, Amount = double.Parse(price) }; return(await GenerateResponseAsync(async() => await MediatorService.Send(command))); }
public async Task HandleAsync(ChangeProductPriceCommand 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.ChangeProductPrice(command); await _repo.SaveAsync(aggregateProduct, cancellationToken); }
public Task HandleAsync(ChangeProductPriceCommand command) { return(_writeRepository.UpdatePriceAsync(command.Price, command.Id)); }
public void ChangeProductPrice(ChangeProductPriceCommand command) { ValidatePrice(command.Price); ApplyChange(new ChangedProductPriceEvent(command.Price, this, command)); }
public async Task <IActionResult> ChangeProductPrice([FromBody] ChangeProductPriceCommand command) { await _commandSender.SendAsync(command); return(Ok()); }
public async Task <IActionResult> ChangeProductPriceAsync([FromBody] ChangeProductPriceCommand command) { await Mediator.SendAsync(command).ConfigureAwait(false); return(Ok()); }