private void EditJournal(JournalViewModel viewModel)
 {
     if (viewModel != null)
     {
         Owner.EditJournal(viewModel.JournalID);
     }
 }
        private void DeleteJournal(JournalViewModel model)
        {
            if (!User.HasPermission(PermissionCategory.SUPPORT_JOURNALS, PERMISSION_MASK.DELETE))
            {
                ErrorMessage.Show("You do not have sufficient priviledges to delete journals!");
                return;
            }

            var service = new SupportService(User);

            if (service.OkToDeleteJournal(model.JournalID))
            {
                if (this.Question(string.Format("Are you sure you wish to permanently delete the journal '{0}'?", model.FullName), "Delete Journal?"))
                {
                    if (_findModel.Contains(model))
                    {
                        _findModel.Remove(model);
                    }

                    if (_page.Model.Contains(model))
                    {
                        _findModel.Remove(model);
                    }

                    RegisterPendingChange(new DeleteJournalCommand(model.Model));
                }
            }
            else
            {
                ErrorMessage.Show("You cannot delete this Journal at this time. This is most probably because this Journal is cited in one or more References.");
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            JournalViewModel selected = GetSelected();

            if (selected != null)
            {
                DeleteJournal(selected);
            }
        }
        private void btnProperties_Click(object sender, RoutedEventArgs e)
        {
            JournalViewModel selected = GetSelected();

            if (selected != null)
            {
                EditJournal(selected);
            }
        }
        public SelectionResult Select()
        {
            JournalViewModel selected = GetSelected();

            if (selected != null)
            {
                var res = new JournalSelectionResult(selected.Model);
                return(res);
            }
            return(null);
        }
        private JournalViewModel GetSelected()
        {
            JournalViewModel selected = null;

            if (tab.SelectedItem == findTab)
            {
                selected = lstResults.SelectedItem as JournalViewModel;
            }
            else
            {
                selected = _page.SelectedItem;
            }

            return(selected);
        }
Пример #7
0
        public JournalDetails(User user, int journalID) : base(user, "Journal:" + journalID)
        {
            InitializeComponent();
            Journal model = null;

            if (journalID >= 0)
            {
                var service = new SupportService(user);
                model = service.GetJournal(journalID);
            }
            else
            {
                model           = new Journal();
                model.JournalID = -1;
                model.FullName  = "<New Journal>";
            }

            _viewModel = new JournalViewModel(model);

            _traits = tabJournal.AddTabItem("Traits", new TraitControl(user, TraitCategoryType.Journal, _viewModel));
            _notes  = tabJournal.AddTabItem("Notes", new NotesControl(user, TraitCategoryType.Journal, _viewModel));
            tabJournal.AddTabItem("Ownership", new OwnershipDetails(model));


            if (_viewModel.JournalID >= 0)
            {
                _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged);
            }
            else
            {
                Loaded           += new RoutedEventHandler(JournalDetails_Loaded);
                _traits.IsEnabled = false;
                _notes.IsEnabled  = false;
            }

            ChangesCommitted += new PendingChangesCommittedHandler(JournalDetails_ChangesCommitted);

            this.DataContext = _viewModel;
        }