Exemplo n.º 1
0
        public void MapViewModelToEntity(GreenTemplateViewModel aModel)
        {
            DB.GreenTemplate lTemplate = this.GetOrCreateGreenTemplate(aModel);

            foreach (ConstraintViewModel lConstraint in aModel.childConstraints)
            {
                this.UpdateConstraint(lTemplate, lConstraint);
            }
        }
Exemplo n.º 2
0
        private DB.GreenTemplate GetOrCreateGreenTemplate(GreenTemplateViewModel aModel)
        {
            DB.GreenTemplate lTemplate = _tdb.GreenTemplates.DefaultIfEmpty(null).SingleOrDefault(gt => gt.Id == aModel.Id);

            if (lTemplate == null)
            {
                lTemplate = new DB.GreenTemplate()
                {
                    Name       = aModel.Name,
                    TemplateId = aModel.TemplateId
                };

                _tdb.GreenTemplates.AddObject(lTemplate);
            }

            return(lTemplate);
        }
Exemplo n.º 3
0
        public GreenTemplateViewModel MapEntityToViewModel(DB.Template aTemplate)
        {
            DB.GreenTemplate       lGreenTemplate = aTemplate.GreenTemplates.DefaultIfEmpty(null).FirstOrDefault();
            GreenTemplateViewModel lViewModel     = new GreenTemplateViewModel();

            if (lGreenTemplate == null)
            {
                lViewModel.Name  = this.GetCamelCaseTemplateName(aTemplate.Name);
                lViewModel.IsNew = true;
            }
            else
            {
                lViewModel.Id   = lGreenTemplate.Id;
                lViewModel.Name = lGreenTemplate.Name;
            }

            lViewModel.TemplateId   = aTemplate.Id;
            lViewModel.TemplateName = aTemplate.Name;
            lViewModel.TemplateOid  = aTemplate.Oid;

            IGSettingsManager igManager    = new IGSettingsManager(_tdb, aTemplate.OwningImplementationGuideId);
            IIGTypePlugin     igTypePlugin = aTemplate.OwningImplementationGuide.ImplementationGuideType.GetPlugin();
            string            baseLink     = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path) + "?Id=";

            int constraintCount = 0;

            foreach (DB.TemplateConstraint cDbConstraint
                     in aTemplate.ChildConstraints
                     .Where(y => y.Parent == null)
                     .Where(c => c.IsPrimitive == false)
                     .Where(c => string.IsNullOrEmpty(c.Value)).OrderBy(y => y.Order))
            {
                ConstraintViewModel lConstraintView = this.BuildConstraint(_tdb, baseLink, igManager, igTypePlugin, cDbConstraint, constraintCount);
                this.CreateIfRequiredGreenTemplateTree(lConstraintView);

                lViewModel.childConstraints.Add(lConstraintView);
            }

            return(lViewModel);
        }