Exemplo n.º 1
0
        public IActionResult SavePost(RepositoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                ICmsManager manager = CmsManager.Load();

                if (model.IsItANewRepository())
                {
                    var newRrepository = model.MapToModel(new Repository());
                    manager.AddRepository(newRrepository);
                }
                else
                {
                    try
                    {
                        int repoindex = manager.GetIndexById(model.Id.Value);
                        model.MapToModel(manager.Repositories[repoindex]);
                    }
                    catch (InvalidOperationException)
                    {
                        throw new Exception("The content definition not found");
                    }
                }
                manager.Save();
                return(Redirect("/fcmsmanager/repository"));
            }

            return(View("Edit", new RepositoryViewModel()));
        }
Exemplo n.º 2
0
        public IActionResult SavePost(RepositoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                ICmsManager manager = new CmsManager();
                IRepository repo;

                if (model.IsItANewRepository())
                {
                    repo = model.MapToModel(new Repository());
                    model.ApplyTemplate(repo);
                    manager.AddRepository(repo);
                }
                else
                {
                    try
                    {
                        int repoindex = manager.GetIndexById(model.Id.Value);
                        repo = manager.Data.Repositories[repoindex];
                        model.MapToModel(repo);
                    }
                    catch (InvalidOperationException)
                    {
                        throw new Exception("The content definition not found");
                    }
                }
                manager.Save();
                return(Redirect("/fcmsmanager/" + ViewModelHelpers.GetRepositoryBaseUrl(repo)));
            }

            return(View("Edit", new RepositoryViewModel()));
        }