/// <summary>
        /// Update Sales Order Detail
        /// </summary>
        /// <param name="salesOrderDetailDataTransformation"></param>
        /// <returns></returns>
        public async Task <ResponseModel <SalesOrderDetailDataTransformation> > UpdateSalesOrderDetail(SalesOrderDetailDataTransformation salesOrderDetailDataTransformation)
        {
            ResponseModel <SalesOrderDetailDataTransformation> returnResponse = new ResponseModel <SalesOrderDetailDataTransformation>();

            SalesOrderDetail salesOrderDetail = new SalesOrderDetail();

            try
            {
                int accountId          = salesOrderDetailDataTransformation.AccountId;
                int salesOrderId       = salesOrderDetailDataTransformation.SalesOrderId;
                int salesOrderDetailId = salesOrderDetailDataTransformation.SalesOrderDetailId;
                //
                //	Validate Shipped Quantity
                //
                if (salesOrderDetailDataTransformation.CurrentShippedQuantity == 0)
                {
                    returnResponse.ReturnMessage.Add("Invalid Shipped Quantity");
                    returnResponse.ReturnStatus = false;

                    return(returnResponse);
                }
                //
                //	Begin a Serializable Transaction
                //
                _inventoryManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString);
                _inventoryManagementDataService.BeginTransaction((int)IsolationLevel.Serializable);
                //
                //	Get Sales Order Header
                //
                SalesOrder salesOrder = await _inventoryManagementDataService.GetSalesOrderHeader(accountId, salesOrderId);

                if (salesOrder == null)
                {
                    _inventoryManagementDataService.RollbackTransaction();

                    returnResponse.ReturnMessage.Add("Sales Order not found");
                    returnResponse.ReturnStatus = false;

                    return(returnResponse);
                }
                //
                //	Get Sales Order Detail
                //
                salesOrderDetail = await _inventoryManagementDataService.GetSalesOrderDetailForUpdate(salesOrderDetailId);

                if (salesOrderDetail == null)
                {
                    _inventoryManagementDataService.RollbackTransaction();

                    returnResponse.ReturnMessage.Add("Sales Order Detail not found");
                    returnResponse.ReturnStatus = false;

                    return(returnResponse);
                }
                //
                //	Update Sales Order Shipped Quantity
                //
                salesOrderDetail.ShippedQuantity = salesOrderDetail.ShippedQuantity + salesOrderDetailDataTransformation.CurrentShippedQuantity;

                await _inventoryManagementDataService.UpdateSalesOrderDetail(salesOrderDetail);

                //
                //	Get Product Record with an exclusive update lock
                //
                Product product = await _inventoryManagementDataService.GetProductInformationForUpdate(salesOrderDetail.ProductId);

                if (product == null)
                {
                    _inventoryManagementDataService.RollbackTransaction();

                    returnResponse.ReturnMessage.Add("Product not found");
                    returnResponse.ReturnStatus = false;

                    return(returnResponse);
                }
                //
                //	Reduce Product OnHand Quantity by the quantity shipped
                //
                product.OnHandQuantity = product.OnHandQuantity - salesOrderDetailDataTransformation.CurrentShippedQuantity;

                await _inventoryManagementDataService.UpdateProduct(product);

                //
                //	Create Inventory Transaction Record
                //
                InventoryTransaction inventoryTransaction = new InventoryTransaction();
                inventoryTransaction.EntityId        = salesOrderDetail.SalesOrderDetailId;
                inventoryTransaction.MasterEntityId  = salesOrderDetail.MasterSalesOrderDetailId;
                inventoryTransaction.ProductId       = salesOrderDetail.ProductId;
                inventoryTransaction.UnitCost        = product.AverageCost;
                inventoryTransaction.Quantity        = salesOrderDetailDataTransformation.CurrentShippedQuantity;
                inventoryTransaction.TransactionDate = DateTime.UtcNow;

                await _inventoryManagementDataService.CreateInventoryTransaction(inventoryTransaction);

                //
                //	Create Transaction Queue record and create inventory transaction payload
                //
                TransactionQueueOutbound transactionQueue = new TransactionQueueOutbound();
                transactionQueue.Payload         = GenerateInventoryTransactionPayload(inventoryTransaction);
                transactionQueue.TransactionCode = TransactionQueueTypes.InventoryShipped;
                transactionQueue.ExchangeName    = MessageQueueExchanges.InventoryManagement;

                await _inventoryManagementDataService.CreateOutboundTransactionQueue(transactionQueue);

                //await _inventoryManagementDataService.UpdateDatabase();

                //
                //	Commit Transaction
                //
                _inventoryManagementDataService.CommitTransaction();

                returnResponse.ReturnStatus = true;
            }
            catch (Exception ex)
            {
                _inventoryManagementDataService.RollbackTransaction();
                returnResponse.ReturnStatus = false;
                returnResponse.ReturnMessage.Add(ex.Message);
            }
            finally
            {
                _inventoryManagementDataService.CloseConnection();
            }

            returnResponse.Entity = salesOrderDetailDataTransformation;

            return(returnResponse);
        }