Esempio n. 1
0
        public PartialViewResult SaveElement(ModelingLanguageElement element, Guid IdLanguage, Guid IdBaseElement)
        {
            try
            {
                var language = DbFactory.ModelingLanguageRepository.FirstById(IdLanguage);

                var baseElement = DbFactory.ModelingLanguageElementRepository.FirstById(IdBaseElement);

                element.Language = language;
                if (baseElement != null)
                {
                    element.ParentElement = baseElement;
                }

                DbFactory.ModelingLanguageElementRepository.Save(element);

                var elements = DbFactory.ModelingLanguageElementRepository.FindAllElementsByLanguageId(IdLanguage, false)
                               .OrderBy(o => o.Name).ToList();

                ViewBag.Language = language;
                return(PartialView("_TblElements", elements));
            }
            catch (Exception ex)
            {
                return(PartialView("Error", new HandleErrorInfo(ex, "Configuration", "SaveElement")));
            }
        }
Esempio n. 2
0
        public PartialViewResult CopyLanguage(ModelingLanguage language, Guid idLanguage)
        {
            try
            {
                var languageToCopy = DbFactory.ModelingLanguageRepository.FirstById(idLanguage);

                var designer = LoginUtils.Designer;
                language.Inactive     = false;
                language.IsConstant   = false;
                language.Designer     = designer;
                language.RegisterDate = DateTime.Now;
                language.Version      = languageToCopy.Version;
                language.Description += "\n [Copied from: " + languageToCopy.Name + "]";

                language = DbFactory.ModelingLanguageRepository.Save(language);

                var tempElements = new List <ModelingLanguageElement>();
                foreach (var elementToCopy in languageToCopy.Elements.OrderBy(o => o.ParentElement != null))
                {
                    ModelingLanguageElement parentElement = null;
                    if (elementToCopy.ParentElement != null)
                    {
                        parentElement = tempElements.FirstOrDefault(f => f.Metamodel == elementToCopy.ParentElement.Metamodel);
                    }

                    var element = new ModelingLanguageElement()
                    {
                        Name          = elementToCopy.Name,
                        Description   = elementToCopy.Description,
                        Metamodel     = elementToCopy.Metamodel,
                        Language      = language,
                        ParentElement = parentElement
                    };

                    element = DbFactory.ModelingLanguageElementRepository.Save(element);

                    tempElements.Add(element);
                }

                var languages = DbFactory.ModelingLanguageRepository.FindAllLanguagesByDesigner(designer, false);

                return(PartialView("_TblLanguages", languages));
            }
            catch (Exception ex)
            {
                return(PartialView("Error", new HandleErrorInfo(ex, "Configuration", "SaveLanguage")));
            }
        }