Ejemplo n.º 1
0
        public IActionResult saveDefinition(ContentDefinitionViewModel model)
        {
            if (ModelState.IsValid)
            {
                ICmsManager manager   = CmsManager.Load();
                int         repoindex = manager.GetIndexById(model.RepositoryId.Value);
                if (repoindex < 0)
                {
                    throw new Exception("The content definition not found");
                }
                IRepository repository = manager.Repositories[repoindex];
                if (model.DefinitionId == null)
                {
                    repository.ContentDefinitions.Add(model.MapToModel(null, this.Request));
                }
                else
                {
                    model.MapToModel(repository.ContentDefinitions.Where(m => m.DefinitionId == model.DefinitionId).FirstOrDefault(), this.Request);
                }


                manager.Save();
                return(Redirect("/fcmsmanager/definition?repositoryid=" + model.RepositoryId));
            }

            return(View("Edit", new ContentDefinitionViewModel()));
        }
Ejemplo n.º 2
0
        public IActionResult edit(Guid repositoryid, Guid id)
        {
            ICmsManager        manager    = CmsManager.Load();
            var                repo       = manager.GetRepositoryById(repositoryid);
            IContentDefinition definition = repo?.ContentDefinitions.Where(m => m.DefinitionId == id).FirstOrDefault();

            if (definition == null)
            {
                return(Redirect("/fcmsmanager/repository"));
            }

            ContentDefinitionViewModel model = new ContentDefinitionViewModel()
            {
                RepositoryId = repositoryid
            };

            model.MapFromModel(definition);

            return(View("Edit", model));
        }