Ejemplo n.º 1
0
        public ViewAnalogousVM CollectExistingAnalogousReactions()
        {
            var               mainViewModel   = ((MainWindow)(App.Current.MainWindow)).DataContext as MainVM;
            List <RsnVM>      tanRsns         = new List <RsnVM>();
            List <ReactionVM> tanReactions    = new List <ReactionVM>();
            var               tanParticipants = new List <ReactionParticipantVM>();

            AnalogousReactions.Clear();
            AllParticipants.Clear();
            ReactionParticipants.Clear();
            try
            {
                var analogousReactions = mainViewModel.TanVM.Reactions.Where(r => r.AnalogousVMId == SelectedMasterReaction.Id);
                foreach (var existingAnalogousReaction in analogousReactions)
                {
                    AnalogousReactions.Add(existingAnalogousReaction);
                    AllParticipants.AddRange(mainViewModel.TanVM.ReactionParticipants.Where(rp => rp.ReactionVM.Id == existingAnalogousReaction.Id));
                    ReactionParticipants.AddRange(mainViewModel.TanVM.ReactionParticipants.Where(rp => rp.ReactionVM.Id == existingAnalogousReaction.Id));
                    foreach (var rsn in (mainViewModel.TanVM.Rsns.Where(rsn => rsn.Reaction.Id == existingAnalogousReaction.Id)))
                    {
                        Rsns.Add(rsn);
                    }
                }
            }
            catch (Exception ex)
            {
                AppErrorBox.ShowErrorMessage("Error while collecting analogous reactions", ex.Message);
            }
            return(this);
        }
Ejemplo n.º 2
0
        public void RefreshView()
        {
            AnalogousReactions.Clear();
            AnalogousReactionPreview = new ReactionViewVM();
            MasterReactionPreview    = new ReactionViewVM();
            Rsns = new ObservableCollection <ViewModels.RsnVM>(mainViewModel.TanVM.Rsns.Where(p => p.Reaction.Id == SelectedMasterReaction.Id).ToList());
            var participants = mainViewModel.TanVM.ReactionParticipants.Where(rp => rp.ReactionVM.Id == SelectedMasterReaction.Id).Select(rp => rp);

            AllParticipants = new ObservableCollection <ViewModels.ReactionParticipantVM>(participants);
            UpdateReactionPreview(SelectedMasterReaction);
            UpdateAnalogousReactionPreview(null);
            MasterReactionChanged.Invoke(this, SelectedMasterReaction);
        }