Пример #1
0
        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);
        }
Пример #3
0
 public Task HandleAsync(ChangeProductPriceCommand command)
 {
     return(_writeRepository.UpdatePriceAsync(command.Price, command.Id));
 }
Пример #4
0
 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());
        }
Пример #6
0
        public async Task <IActionResult> ChangeProductPriceAsync([FromBody] ChangeProductPriceCommand command)
        {
            await Mediator.SendAsync(command).ConfigureAwait(false);

            return(Ok());
        }