コード例 #1
0
        private void LinkIssueButtonHandler(object parameter)
        {
            AddRelatedIssueDialog dialog = new AddRelatedIssueDialog();
            dialog.Show();
            dialog.Closed +=
                (s1, e1) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        List<Issue> toAdd = dialog.SelectedIssues.ToList();

                        foreach (var issue in toAdd)
                        {
                            var existing = (from x in mControlSystem.IssueRelatedControlSystems
                                            where x.IssueId == issue.Id
                                                  && x.ControlSystemId == mControlSystem.Id
                                            select x).FirstOrDefault();

                            if (existing == null)
                            {
                                IssueRelatedControlSystem ird = new IssueRelatedControlSystem
                                {
                                    IssueId = issue.Id,
                                    Issue = issue,
                                    ControlSystemId = mControlSystem.Id,
                                    ControlSystem = mControlSystem
                                };

                                mControlSystem.IssueRelatedControlSystems.Add(ird);

                            }
                        }

                        if (toAdd.Any())
                        {
                            LoadData();

                            Utils.OnCollectionChanged(EventAggregator, mControlSystem, "ControlSystemRelatedIssuesViewModel", true);

                            OnCollectionChanged();
                        }
                    }
                };
        }
コード例 #2
0
        private void SaveIssueRelatedControlSystem(Issue issue, Issue originalIssue, CmsEntities cee)
        {
            log.Verbose("SaveIssueRelatedControlSystem()");
            //Delete originalIssueRelatedControlSystems
            cee.DeleteWhere<IssueRelatedControlSystem>(cee, x => x.IssueId == issue.Id);

            cee.Configuration.AutoDetectChangesEnabled = false;
            foreach (IssueRelatedControlSystem issueRelatedControlSystem in issue.IssueRelatedControlSystems)
            {
                var newIssueRelatedControlSystem = new IssueRelatedControlSystem();

                newIssueRelatedControlSystem.IssueId = issueRelatedControlSystem.IssueId;
                newIssueRelatedControlSystem.ControlSystemId = issueRelatedControlSystem.ControlSystemId;

                if (issueRelatedControlSystem.Implemented && issueRelatedControlSystem.ImplementedById.HasValue)
                {
                    newIssueRelatedControlSystem.Implemented = issueRelatedControlSystem.Implemented;
                    newIssueRelatedControlSystem.ImplementedDate = issueRelatedControlSystem.ImplementedDate;
                    newIssueRelatedControlSystem.ImplementedById = issueRelatedControlSystem.ImplementedById;
                }

                if (issueRelatedControlSystem.Tested && issueRelatedControlSystem.TestedById.HasValue)
                {
                    newIssueRelatedControlSystem.Tested = issueRelatedControlSystem.Tested;
                    newIssueRelatedControlSystem.TestedDate = issueRelatedControlSystem.TestedDate;
                    newIssueRelatedControlSystem.TestedById = issueRelatedControlSystem.TestedById;
                }

                if (issueRelatedControlSystem.Loaded && issueRelatedControlSystem.LoadedById.HasValue)
                {
                    newIssueRelatedControlSystem.Loaded = issueRelatedControlSystem.Loaded;
                    newIssueRelatedControlSystem.LoadedDate = issueRelatedControlSystem.LoadedDate;
                    newIssueRelatedControlSystem.LoadedById = issueRelatedControlSystem.LoadedById;
                }

                newIssueRelatedControlSystem.Notes = issueRelatedControlSystem.Notes;

                originalIssue.IssueRelatedControlSystems.Add(newIssueRelatedControlSystem);
            }
            cee.Configuration.AutoDetectChangesEnabled = true;
        }
コード例 #3
0
        private void AddRelatedIssueHandler(object parameter)
        {
            AddIssueDialog aid = new AddIssueDialog();

            aid.Closed += (s1, e1) =>
            {
                //Hadle dialog closed
                if (aid.DialogResult.HasValue && aid.DialogResult.Value)
                {
                    Issue newIssue = aid.Issue;

                    IssueRelatedControlSystem issueRelatedControlSystem = (from x in mControlSystem.IssueRelatedControlSystems
                                                                     where x.IssueId == newIssue.Id
                                                                           && x.ControlSystemId == mControlSystem.Id
                                                                     select x).FirstOrDefault();
                    if (issueRelatedControlSystem == null)
                    {
                        IssueRelatedControlSystem ird = new IssueRelatedControlSystem
                        {
                            IssueId = newIssue.Id,
                            Issue = newIssue,
                            ControlSystemId = mControlSystem.Id,
                            ControlSystem = mControlSystem
                        };

                        mControlSystem.IssueRelatedControlSystems.Add(ird);

                        LoadData();

                        Utils.OnCollectionChanged(EventAggregator, mControlSystem, "ControlSystemRelatedIssuesViewModel", true);

                        OnCollectionChanged();
                    }

                }
            };

            aid.Show();
        }
コード例 #4
0
        private void SaveControlSystemRelatedIssues(ControlSystem controlSystem, CmsEntities cee)
        {
            //Delete original
            var originals =
                (from x in cee.IssueRelatedControlSystems where x.ControlSystemId == controlSystem.Id select x).ToList();
            originals.ForEach(x => cee.IssueRelatedControlSystems.Remove(x));

            foreach (var relatedControlSystem in controlSystem.IssueRelatedControlSystems)
            {
                var newObject = new IssueRelatedControlSystem
                {
                    ControlSystemId = controlSystem.Id,
                    IssueId = relatedControlSystem.IssueId,
                    Notes = relatedControlSystem.Notes,
                    TestedById = relatedControlSystem.TestedById,
                    TestedDate = relatedControlSystem.TestedDate,
                    ImplementedById = relatedControlSystem.ImplementedById,
                    ImplementedDate = relatedControlSystem.ImplementedDate
                };

                cee.IssueRelatedControlSystems.Add(newObject);
            }
        }