/// <summary>
        /// Creates a data trigger view model.
        /// </summary>
        /// <param name="trigger">The trigger.</param>
        /// <param name="parentViewModel">The parent view model.</param>
        /// <returns>The <see cref="IDataTriggerViewModel" />.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// trigger
        /// or
        /// parentViewModel
        /// </exception>
        /// <exception cref="System.NotSupportedException"></exception>
        /// <exception cref="ArgumentNullException">The <paramref name="trigger" /> parameter is null.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="parentViewModel" /> parameter is null.</exception>
        /// <exception cref="NotSupportedException">The trigger type is not supported.</exception>
        public IDataTriggerViewModel CreateViewModel(ProcessDataTriggerEdit trigger, IProcessDataTriggersViewModel parentViewModel)
        {
            if (trigger == null)
                throw new ArgumentNullException("trigger");

            if (parentViewModel == null)
                throw new ArgumentNullException("parentViewModel");

            switch (trigger.TriggerType)
            {
                case DataTriggerTypes.Process:
                    {
                        var viewModel = ProcessTriggerViewModelFactory.CreateExport().Value;
                        viewModel.Initialize(trigger, parentViewModel);

                        return viewModel;
                    }

                case DataTriggerTypes.StoredProcedure:
                    {
                        var viewModel = StoredProcedureTriggerViewModelFactory.CreateExport().Value;
                        viewModel.Initialize(trigger, parentViewModel);

                        return viewModel;
                    }

                default:
                    throw new NotSupportedException(string.Format("Trigger type \"{0}\" is not supported.", trigger.TriggerType));
            }
        }
        /// <summary>
        /// Creates a data trigger type selector view model.
        /// </summary>
        /// <param name="trigger">The trigger.</param>
        /// <param name="parentViewModel">The parent view model.</param>
        /// <returns>The <see cref="IDataTriggerTypeSelectorViewModel" />.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// trigger
        /// or
        /// parentViewModel
        /// </exception>
        /// <exception cref="ArgumentNullException">The <paramref name="trigger" /> parameter is null.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="parentViewModel" /> parameter is null.</exception>
        public IDataTriggerTypeSelectorViewModel CreateViewModel(ProcessDataTriggerEdit trigger, IProcessDataTriggersViewModel parentViewModel)
        {
            if (trigger == null)
                throw new ArgumentNullException("trigger");

            if (parentViewModel == null)
                throw new ArgumentNullException("parentViewModel");

            var viewModel = DataTriggerTypeSelectorFactory.CreateExport().Value;
            viewModel.Initialize(trigger, parentViewModel);

            return viewModel;
        }
        /// <summary>
        /// Initializes the view model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parentViewModel">The parent view model.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="model" /> parameter is null.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="parentViewModel" /> parameter is null.</exception>
        public void Initialize(ProcessDataTriggerEdit model, IProcessDataTriggersViewModel parentViewModel)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (parentViewModel == null)
                throw new ArgumentNullException("parentViewModel");

            ParentViewModel = parentViewModel;
            Model = model;
            RuntimeDatabaseProcedures = ParentViewModel.UnitOfWork != null ? ParentViewModel.UnitOfWork.RuntimeDatabaseProcedures : null;
        }
        /// <summary>
        /// Initializes the current <see cref="ProcessDataTriggerViewModel"/>.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parent">The parent view model.</param>
        public void Initialize(ProcessDataTriggerEdit model, IProcessDataTriggersViewModel parent)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (parent == null)
                throw new ArgumentNullException("parent");

            ParentViewModel = parent;
            Model = model;
            _processList = parent.PublishedProcesses.Where(CanIncludeInProcessToModifyList).ToList();
            _processToModify = _processList.FirstOrDefault(p => p.SystemName == Model.ProcessToModifySystemName);

            if (_processToModify == null)
            {
                Model.ProcessToModifySystemName = null;
            }
        }
        /// <summary>
        /// Initializes the view model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parentViewModel">The parent view model.</param>
        /// <exception cref="System.ArgumentNullException">
        /// model
        /// or
        /// parentViewModel
        /// </exception>
        /// <exception cref="ArgumentNullException">The <paramref name="model" /> parameter is null.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="parentViewModel" /> parameter is null.</exception>
        public void Initialize(ProcessDataTriggerEdit model, IProcessDataTriggersViewModel parentViewModel)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (parentViewModel == null)
                throw new ArgumentNullException("parentViewModel");

            ParentViewModel = parentViewModel;
            Model = model;

            _triggerType = Model.TriggerType;
            RaisePropertyChanged(() => TriggerType);
            TriggerViewModel = TriggerViewModelFactory.CreateViewModel(Model, ParentViewModel);
        }