private void OnAgentSelected(int?agentId)
        {
            AgentWrapper selectedAgent = null;

            // Get the agent entity with the selected ID.
            if (agentId.HasValue)
            {
                selectedAgent = _dataService.GetAgents(a => a.ID == agentId.Value).SingleOrDefault();
            }

            // Get a reference to the main region.
            IRegion ribbonRegion = _regionManager.Regions[RegionNames.RibbonRegion];

            if (ribbonRegion == null)
            {
                return;
            }

            // Check to see if we need to create an instance of the view.
            var view = ribbonRegion.Views.SingleOrDefault() as IAgentsRibbonTabView;

            // Set the current agent property on the view model.
            if (view != null && view.ViewModel != null)
            {
                view.ViewModel.CurrentEntity = selectedAgent;
            }
        }
        private void OnAgentSelected(int?agentId)
        {
            AgentWrapper selectedAgent = null;

            // Get the agent entity with the selected ID.
            if (agentId.HasValue)
            {
                selectedAgent = _dataService.GetAgents(a => a.ID == agentId.Value).SingleOrDefault();
            }

            // Get a reference to the main region.
            IRegion mainRegion = _regionManager.Regions[RegionNames.RightContentRegion];

            if (mainRegion == null)
            {
                return;
            }

            // Check to see if we need to create an instance of the view.
            var view = mainRegion.GetView("AgentSummaryView") as IAgentSummaryView;

            if (view == null)
            {
                // Create a new instance of the IAgentDetailsView implementation using the Unity container.
                view = _container.Resolve <IAgentSummaryView>();

                // Add the view to the right region. This automatically activates the view too.
                mainRegion.Add(view, "AgentSummaryView");
            }
            else
            {
                // The view has already been added to the region so just activate it.
                mainRegion.Activate(view);
            }

            // Set the current agent property on the view model.
            if (view.ViewModel != null)
            {
                view.ViewModel.CurrentEntity = selectedAgent;
            }
        }
Esempio n. 3
0
        private void OnAgentsListUpdated(int id)
        {
            //_dispatcher.Dispatch(DispatcherPriority.DataBind, OnAgentsListUpdatedSafe);

            foreach (var agent in _dataService.GetAgents(a => AgentsCollection.All(la => la.ID != a.ID)))
            {
                AgentsCollection.Add(agent);
            }

            foreach (var agentWrapper in AgentsCollection)
            {
                var thisAgent = agentWrapper;

                var updatedAgent = _dataService.GetAgents(a => a.ID == thisAgent.ID).Single();
                thisAgent.Data   = updatedAgent.Data;
                thisAgent.Status = updatedAgent.Status;
            }

            #region ToDelete

            //if (_dispatcher.CheckAccess())
            //{
            //    foreach (var agent in _dataService.GetAgents(a => AgentsCollection.All(la => la.ID != a.ID)))
            //    {
            //        AgentsCollection.Add(agent);
            //    }
            //}
            //else
            //{

            //    _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback) delegate
            //                            {
            //                                foreach (
            //                                    var agent in
            //                                        _dataService.
            //                                            GetAgents(
            //                                                a =>
            //                                                AgentsCollection
            //                                                    .All(
            //                                                        la
            //                                                        =>
            //                                                        la.
            //                                                            ID !=
            //                                                        a.
            //                                                            ID))
            //                                    )
            //                                {
            //                                    AgentsCollection.Add(
            //                                        agent);
            //                                }
            //                            });


            //}

            //if (UIThread != null)
            //{

            //    Dispatcher.FromThread(UIThread).Invoke((MethodInvoker)delegate
            //    {
            //        queriesViewModel.AddQuery(info);
            //    }
            //    , null);
            //}
            //else
            //{
            //    queriesViewModel.AddQuery(info);
            //}


            //foreach (var agent in _dataService.GetAgents(a => AgentsCollection.All(la => la.ID != a.ID)))
            //{
            //    AgentsCollection.Add(agent);
            //}

            #endregion
        }