private void ExecuteRequoteSetPriceCommand(object price)
        {
            decimal requoteDiffernce = 0;

            try
            {
                requoteDiffernce  = Convert.ToDecimal(price);
                requoteDiffernce /= 10000;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }

            lock (lockTrades)
            {
                foreach (var row in PendingTrades)
                {
                    TradePosition position = row as TradePosition;
                    if (position.IsSelected)
                    {
                        if (position.RequotePriceSet)
                        {
                            position.RequotePrice += requoteDiffernce;
                        }
                        else
                        {
                            if (position.OrderState == TradePosition.ORDER_STATE_PENDING_OPEN)
                            {
                                position.RequotePrice = position.OpenPrice + requoteDiffernce;
                            }
                            else
                            {
                                position.RequotePrice = position.ClosePrice + requoteDiffernce;
                            }
                            position.RequotePriceSet = true;
                        }
                    }
                }
            }

            PendingTradesCollectionView.Refresh();
        }
        private void OnOfficePositionsUpdateReceived(object sender, BackofficeUpdateEventArgs e)
        {
            App.Current.Dispatcher.Invoke((Action) delegate
            {
                QuoteList quotes = e.OfficeUpdate.Quotes;
                Dictionary <string, List <TradePosition> > positions = e.OfficeUpdate.UserPositions;
                List <OfficeFloatingStatus> floatingStatus           = e.OfficeUpdate.FloatingStatus;

                lock (lockTrades)
                {
                    _floatingStatus.Clear();
                    if (floatingStatus.Count > 0)
                    {
                        _floatingStatus.AddRange(floatingStatus);
                        FloatingStatusCollectionView.Refresh();
                    }

                    if (e.OfficeUpdate.CoverPositions.Count > 0)
                    {
                        int selIndex = OpenCoverTradesCollectionView.CurrentPosition;
                        _coverPositions.Clear();

                        _coverPositions.AddRange(e.OfficeUpdate.CoverPositions);

                        if (_coverPositions.Count >= selIndex)
                        {
                            OpenCoverTradesCollectionView.MoveCurrentToPosition(selIndex);
                        }
                    }
                    else
                    {
                        _coverPositions.Clear();
                    }


                    if (positions.Count > 0)
                    {
                        int currentIndexPending = PendingTradesCollectionView.CurrentPosition;
                        int currentIndexOpen    = OpenTradesCollectionView.CurrentPosition;
                        List <TradePosition> pendingWithSelectionPreserved = new List <TradePosition>();

                        OpenTrades.Clear();

                        foreach (var row in positions)
                        {
                            foreach (var t in row.Value)
                            {
                                t.ClientName = row.Key;
                                t.CurrentPl *= -1.0M;

                                if (t.OrderState.Equals(TradePosition.ORDER_STATE_OPEN))
                                {
                                    OpenTrades.Add(t);
                                }
                                else if (t.OrderState.Equals(TradePosition.ORDER_STATE_REQUOTED))
                                {
                                    continue;
                                }
                                else
                                {
                                    if (!PendingTrades.Contains(t))
                                    {
                                        pendingWithSelectionPreserved.Add(t);
                                    }
                                    else
                                    {
                                        TradePosition trade = PendingTrades.First(x => x.Equals(t));
                                        t.IsSelected        = trade.IsSelected;
                                        t.RequotePrice      = trade.RequotePrice;
                                        t.RequotePriceSet   = trade.RequotePriceSet;
                                        pendingWithSelectionPreserved.Add(t);
                                    }
                                }
                            }
                        }

                        PendingTrades.Clear();
                        PendingTrades.AddRange(pendingWithSelectionPreserved);


                        if (PendingTradesCollectionView.Count >= currentIndexPending)
                        {
                            PendingTradesCollectionView.MoveCurrentToPosition(currentIndexPending);
                        }


                        if (OpenTradesCollectionView.Count >= currentIndexOpen)
                        {
                            OpenTradesCollectionView.MoveCurrentToPosition(currentIndexOpen);
                        }
                    }
                    else
                    {
                        OpenTrades.Clear();
                        PendingTrades.Clear();
                    }
                }
                PendingTradesCollectionView.Refresh();
                OpenTradesCollectionView.Refresh();
            });
        }