Example #1
0
        protected async Task ChangeProduct(ChangeProductCommand command)
        {
            if (command.LocalProfit != command.OriginalProduct.LocalProfit)
            {
                ExecuteSync(posState => posState.ChangeProductLocalProfit(command.OriginalProduct.Id, command.LocalProfit));
            }

            if (command.Name != command.OriginalProduct.Name)
            {
                await ExecuteAsync(posState => posState.ChangeProductName(command.OriginalProduct.Id, command.Name, HubConnection));
            }

            if (command.MinPriceProcentage != command.OriginalProduct.MinPriceProcentage)
            {
                await ExecuteAsync(posState => posState.ChangeProductMinPriceProcentage(command.OriginalProduct.Id, command.MinPriceProcentage, HubConnection));
            }

            if (command.MaxPriceProcentage != command.OriginalProduct.MaxPriceProcentage)
            {
                await ExecuteAsync(posState => posState.ChangeProductMaxPriceProcentage(command.OriginalProduct.Id, command.MaxPriceProcentage, HubConnection));
            }

            if (command.Quantity != command.OriginalProduct.Quantity)
            {
                await ExecuteAsync(posState => posState.ChangeProductQuantity(command.OriginalProduct.Id, command.Quantity - command.OriginalProduct.Quantity, HubConnection));
            }

            if (command.Color != command.OriginalProduct.Color)
            {
                await ExecuteAsync(posState => posState.ChangeProductColor(command.OriginalProduct.Id, command.Color, HubConnection));
            }
        }
        public async Task <IActionResult> Update(int id, ChangeProductCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            await _mediator.Send(command);

            return(NoContent());
        }
Example #3
0
 public async Task ChangeAsync(ChangeProductCommand product, CancellationToken cancellationToken)
 {
     await _productRepository.ChangeAsync(product, cancellationToken);
 }
Example #4
0
        public async Task <IActionResult> ChangeAsync([FromBody] ChangeProductCommand product, CancellationToken cancellationToken)
        {
            await _productApplication.ChangeAsync(product, cancellationToken);

            return(Ok());
        }