private async void ExecuteEditSelectedCoverPositionCommand()
        {
            CoverPositionWindow          cpw        = new CoverPositionWindow();
            CoverPositionWindowViewModel cpwContext = cpw.DataContext as CoverPositionWindowViewModel;

            cpwContext.View             = cpw;
            cpwContext.OnTradeExecuted += CpwContext_OnTradeExecuted;

            lock (lockQuotes)
            {
                cpwContext._commodities.AddRange(Quotes.Select(x => x.Name).ToList());
            }
            if (cpwContext._commodities.Count > 0)
            {
                cpwContext.SelectedCommodity = cpwContext._commodities[0];
                cpwContext.CommoditiesCollection.Refresh();
            }

            var position = OpenCoverTradesCollectionView.CurrentItem as CoverPosition;

            if (null == position)
            {
                return;
            }
            cpwContext.CoverPosition = position;

            cpwContext.SelectedCommodity       = position.Commodity;
            cpwContext.SelectedCoveringAccount = position.Coveraccount_id;
            cpwContext.SelectedOrderType       = position.OrderType;
            cpwContext.LotSize   = position.Amount;
            cpwContext.OpenPrice = position.OpenPrice;
            cpwContext.Orderid   = position.Remoteid;

            await ChildWindowManager.ShowChildWindowAsync(_mainWindow, cpw, ChildWindowManager.OverlayFillBehavior.WindowContent);
        }
        private void CpwContext_OnTradeExecuted(CoverPositionWindowViewModel context)
        {
            context.View.Close();


            if (context.IsCancel)
            {
                return;
            }

            var position = context.CoverPosition;

            if (null == position)
            {
                position = new CoverPosition();
            }

            position.Amount          = context.LotSize;
            position.Coveraccount_id = context.SelectedCoveringAccount;
            position.OrderType       = context.SelectedOrderType;
            position.OpenPrice       = context.OpenPrice;
            //position.Opentime = DateTime.Now; //do not set
            position.OpenedBy  = username;
            position.Commodity = context.SelectedCommodity;
            //position.Internalid = Guid.NewGuid(); //will be regenerated at server end..
            position.Remoteid = context.Orderid;

            DealerService.GetInstance().saveUpdateCloseCoverPosition(position, "createUpdateCoverPosition");
        }
        private async void ExecuteNewCoverPositionCommand()
        {
            CoverPositionWindow          cpw        = new CoverPositionWindow();
            CoverPositionWindowViewModel cpwContext = cpw.DataContext as CoverPositionWindowViewModel;

            cpwContext.View             = cpw;
            cpwContext.OnTradeExecuted += CpwContext_OnTradeExecuted;

            lock (lockQuotes)
            {
                cpwContext._commodities.AddRange(Quotes.Select(x => x.Name).ToList());
            }
            if (cpwContext._commodities.Count > 0)
            {
                cpwContext.SelectedCommodity = cpwContext._commodities[0];
                cpwContext.CommoditiesCollection.Refresh();
            }

            await ChildWindowManager.ShowChildWindowAsync(_mainWindow, cpw, ChildWindowManager.OverlayFillBehavior.WindowContent);
        }