public async Task <ObjectId> HandleAsync(CancelOrderCommand request, CancellationToken cancellationToken)
        {
            var order = await _orderRepository.GetAsync(request.OrderId);

            order.SetCancelledStatus();
            return(ObjectId.NewId());
        }
        public async Task <Unit> Handle(CancelOrderCommand request, CancellationToken cancellationToken)
        {
            var order = await _orderRepository.GetAsync(request.OrderId);

            order.SetCancelledStatus();
            await _unitOfWorkManager.CommitAsync();

            return(Unit.Value);
        }
        /// <summary>
        /// Handler which processes the command when
        /// customer executes cancel order from app
        /// </summary>
        /// <param name="command"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task HandleAsync(DeleteOrderCommand command, CancellationToken cancellationToken)
        {
            var order = await _orderRepository.GetAsync(command.OrderId);

            if (order == null)
            {
                return;
            }

            await _orderRepository.DeleteAsync(order);
        }
        /// <summary>
        /// Handler which processes the command when
        /// customer executes cancel order from app
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public async Task <Unit> Handle(ChangeOrderAddressCommand command, CancellationToken cancellationToken)
        {
            var order = await _orderRepository.GetAsync(command.OrderId);

            if (order == null)
            {
                return(Unit.Value);
            }

            order.ChangeAddress(command.NewAddress);
            await _unitOfWorkManager.CommitAsync();

            return(Unit.Value);
        }
        /// <summary>
        /// Handler which processes the command when
        /// customer executes cancel order from app
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public async Task <Unit> Handle(DeleteOrderCommand command, CancellationToken cancellationToken)
        {
            var order = await _orderRepository.GetAsync(command.OrderId);

            if (order == null)
            {
                return(Unit.Value);
            }

            await _orderRepository.DeleteAsync(order);

            await _unitOfWorkManager.CommitAsync();

            return(Unit.Value);
        }
Beispiel #6
0
        /// <summary>
        /// Handler which processes the command when
        /// customer executes cancel order from app
        /// </summary>
        /// <param name="command"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task HandleAsync(ChangeOrderAddressCommand command, CancellationToken cancellationToken)
        {
            var order = await _orderRepository.GetAsync(command.OrderId);

            order?.ChangeAddress(command.NewAddress);
        }