Esempio n. 1
0
        public AddRelatedControlModel(AddRelatedControlDialog view)
        {
            mGridRefreshTimer.Interval = TimeSpan.FromMilliseconds(500);
            mGridRefreshTimer.Tick += (sender, eventArgs) => { mGridRefreshTimer.Stop(); ProcessSearchFilter(); };

            this.View = view;
            if (DesignerProperties.IsInDesignTool){return;}

            LoadData();

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander);
            SearchCommand = new DelegateCommand<object>(x => ProcessSearchFilter(), x => true);
        }
        private void AddControlButtonHandler(object parameter)
        {
            AddRelatedControlDialog addRelatedControlDialog = new AddRelatedControlDialog();
            addRelatedControlDialog.Show();
            addRelatedControlDialog.Closed +=
                (s1, e1) =>
                {
                    if (addRelatedControlDialog.DialogResult.HasValue && addRelatedControlDialog.DialogResult.Value)
                    {
                        List<QuickControlSystem> quickControlSystems = addRelatedControlDialog.SelectedControlSystems.ToList();

                        foreach (QuickControlSystem quickControlSystem in quickControlSystems)
                        {
                            IssueRelatedControlSystem relatedControl = (from x in mIssue.IssueRelatedControlSystems
                                                                    where x.ControlSystemId == quickControlSystem.Id
                                                                    select x).FirstOrDefault();

                            if (relatedControl == null)
                            {
                                mIssue.IssueRelatedControlSystems.Add(new IssueRelatedControlSystem
                                                                     {
                                                                         IssueId = mIssue.Id,
                                                                         ControlSystem =
                                                                         new ControlSystem
                                                                         {
                                                                             Id = quickControlSystem.Id,
                                                                             Name = quickControlSystem.Name,
                                                                             Description = quickControlSystem.Description,
                                                                             IsActive = quickControlSystem.IsActive
                                                                         },
                                                                         ControlSystemId = quickControlSystem.Id,
                                                                     });

                            }
                        }

                        RaiseChangeEvent();

                        RaisePropertyChanged("IssueRelatedControlSystems");

                        OnCollectionChanged();

                        View.TelerikGrid.Rebind();

                    }
                };
        }