public async Task <CommandResult> Handle(SalesCommand command)
        {
            CommandResult commandResult = await ValidateCommand(command);

            if (!commandResult.Succeed)
            {
                return(commandResult);
            }

            Sales sales = Map(command);
            await salesRepository.Save(sales);

            ProductSoldEvent productSoldEvent = MapEvent(command);
            await eventBus.Publish(Constants.MessageQueue.SalesQueue, productSoldEvent);

            return(commandResult);
        }
        private Sales Map(SalesCommand command)
        {
            var sales = new Sales
            {
                Id        = command.SalesId,
                SalesDate = command.SalesDate
            };

            foreach (SalesProduct product in command.SalesProducts)
            {
                var salesLineItem = new SalesLineItem
                {
                    ProductId     = product.ProductId,
                    ProductName   = product.ProductName,
                    SalesQuantity = product.SalesQuantity,
                    UnitName      = product.UnitName,
                    UnitSalePrice = product.SalesUnitPrice
                };
                sales.SalesLineItems.Add(salesLineItem);
            }

            return(sales);
        }