private void UpdateTemplateConstraints(PublishModel aModel, DB.Template aTemplate) { foreach (PublishConstraint lConstraintView in aModel.Constraints) { DB.TemplateConstraint lConstraint = _tdb.TemplateConstraints.Single(tc => tc.Id == lConstraintView.Id && tc.TemplateId == aTemplate.Id); this.UpdateConstraint(lConstraint, lConstraintView); } }
private void UpdateTemplateSamples(PublishModel aModel, DB.Template aTemplate) { IEnumerable <XmlSample> lDeletedSamples = from x in aModel.XmlSamples where x.IsDeleted && x.Id.HasValue select x; foreach (XmlSample lDeletedSample in lDeletedSamples) { DB.TemplateSample lSample = aTemplate.TemplateSamples.Single(s => s.Id == lDeletedSample.Id); _tdb.TemplateSamples.Remove(lSample); } IEnumerable <XmlSample> lNewSamples = from x in aModel.XmlSamples where !x.Id.HasValue select x; foreach (XmlSample lNewSample in lNewSamples) { DB.TemplateSample lSample = new DB.TemplateSample() { Name = lNewSample.Name, XmlSample = lNewSample.SampleText }; aTemplate.TemplateSamples.Add(lSample); } IEnumerable <XmlSample> lUpdatedSamples = from x in aModel.XmlSamples where !x.IsDeleted && x.Id.HasValue select x; foreach (XmlSample lUpdatedSample in lUpdatedSamples) { DB.TemplateSample lSample = _tdb.TemplateSamples.Single(ts => ts.Id == lUpdatedSample.Id); lSample.Name = lUpdatedSample.Name; lSample.XmlSample = lUpdatedSample.SampleText; } }