Ejemplo n.º 1
0
        private void SaveInstrumentRelatedIssues(Instrument instrument, CmsEntities cee)
        {
            //Delete
            List<IssueRelatedInstrument> originals = (from x in cee.IssueRelatedInstruments where x.InstrumentId == instrument.Id select x).ToList();

            originals.ForEach(x => cee.IssueRelatedInstruments.Remove(x));

            foreach (IssueRelatedInstrument issueRelatedInstrument in instrument.IssueRelatedInstruments)
            {
                IssueRelatedInstrument newObject = new IssueRelatedInstrument
                {
                    InstrumentId = instrument.Id,
                    IssueId = issueRelatedInstrument.IssueId,
                    Notes = issueRelatedInstrument.Notes,
                    TestedById = issueRelatedInstrument.TestedById,
                    TestedDate = issueRelatedInstrument.TestedDate,
                    ImplementedById = issueRelatedInstrument.ImplementedById,
                    ImplementedDate = issueRelatedInstrument.ImplementedDate
                };

                cee.IssueRelatedInstruments.Add(newObject);
            }
        }
Ejemplo n.º 2
0
        private void SaveIssueRelatedInstrumentEquipments(Issue issue, Issue originalIssue, CmsEntities cee)
        {
            log.Verbose("SaveIssueRelatedInstrumentEquipments()");
            //Delete IssueRelatedInstrument
            cee.DeleteWhere<IssueRelatedInstrument>(cee, x => x.IssueId == issue.Id);

            cee.Configuration.AutoDetectChangesEnabled = false;

            //Save SaveIssueRelatedInstruments
            foreach (IssueRelatedInstrument instrument in issue.IssueRelatedInstruments.ToList())
            {
                var newInstrument = new IssueRelatedInstrument
                {
                    IssueId = issue.Id,
                    InstrumentId = instrument.InstrumentId,
                    Notes = instrument.Notes
                };

                if (instrument.Implemented && instrument.ImplementedById.HasValue)
                {
                    newInstrument.Implemented = true;
                    newInstrument.ImplementedById = instrument.ImplementedById;
                    newInstrument.ImplementedDate = instrument.ImplementedDate;
                }

                if (instrument.Tested && instrument.TestedById.HasValue)
                {
                    newInstrument.Tested = true;
                    newInstrument.TestedById = instrument.ImplementedById;
                    newInstrument.TestedDate = instrument.ImplementedDate;
                }

                originalIssue.IssueRelatedInstruments.Add(newInstrument);
            }
            cee.Configuration.AutoDetectChangesEnabled = true;
        }