Esempio n. 1
0
        public void ImportIssueClassification()
        {
            mForm.AddMessage(MessageType.Info, "-------------------- Importing Issue Classification --------------------");
            List<Classification> classifications = (from x in mOldIssuesDataContext.Classifications select x).ToList();

            foreach (var classification in classifications)
            {
                IssueClassification newClassification = new IssueClassification()
                {
                    Name = classification.Name,
                    Ordinal = classification.Ordinal
                };

                var classificationExist = (from x in mCee.IssueClassifications where x.Name == newClassification.Name select x).FirstOrDefault();

                if (classificationExist == null)
                {
                    string message = String.Format("Adding Issue Classification '{0}'", newClassification.Name);
                    mForm.AddMessage(MessageType.Info, message);
                    mCee.IssueClassifications.AddObject(newClassification);
                }
                else
                {
                    string message = String.Format("Issue Classification '{0}' already exist, skipping", classificationExist.Name);
                    mForm.AddMessage(MessageType.Warning, message);
                }
            }
            mCee.SaveChanges();
        }
Esempio n. 2
0
        public IssueClassification SaveIssueClassification(IssueClassification issueClassification)
        {
            using (var cee = new CmsEntities())
            {
                //Check if the pipe area exist
                IssueClassification originalObject =
                    (from x in cee.IssueClassifications where x.Id == issueClassification.Id select x).FirstOrDefault();

                if (originalObject == null)
                {
                    //Add new Issue Classification
                    issueClassification.Code = issueClassification.Name.Replace(" ", "");
                    issueClassification.IsActive = true;
                    cee.IssueClassifications.Add(issueClassification);
                }
                else
                {
                    //Update existing Classification
                    originalObject.Name = issueClassification.Name;
                    originalObject.Description = issueClassification.Description;
                    originalObject.IsActive = issueClassification.IsActive;
                    originalObject.Ordinal = issueClassification.Ordinal;
                }

                cee.SaveChanges();
            }
            return issueClassification;
        }