Esempio n. 1
0
        public async Task <CommandResult> Handle(CreateOrderCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var item  = _itemsRepository.Query().GetBySizeAndModel(request.Model, request.Size).FirstOrDefault();
                var order = Order.Create(item);
                await _ordersRepository.Add(order);

                await _warehouseDbContext.SaveChangesAsync();

                await _warrantyService.StartWarranty(order.OrderItemUid);

                return(new CommandResult
                {
                    IsCompleted = true
                });
            }
            catch (Exception ex)
            {
                return(new CommandResult
                {
                    IsCompleted = false,
                    Reason = ex.Message
                });
            }
        }