public ActionResult Manage(Manage model) { if (!_auth.IsContentAdmin(HttpContext)) return new HttpStatusCodeResult(403); ViewBag.CkEditorPath = _config.CkEditorPath + "/ckeditor.js"; if (string.IsNullOrEmpty(model.ManageUrl)) ModelState.AddModelError("ManageUrl", "Url is required."); if (model.Partial && !string.IsNullOrEmpty(model.ContentTitle)) ModelState.AddModelError("ContentTitle", "Title can not be applied to partial content."); if (!ModelState.IsValid) return MeekResult("Manage", model); //Since the route table does not accept routes starting with / then trim it off if (model.ManageUrl.StartsWith("/")) model.ManageUrl = model.ManageUrl.Substring(1); _repository.Save(model.ManageUrl, new MeekContent(model.ContentTitle, model.EditorContents, model.Partial)); if (!model.Partial && !RouteTable.Routes.Cast<Route>().Any(x => x.Url == model.ManageUrl)) RouteTable.Routes.Insert(0, new MeekRoute(model.ManageUrl)); if (model.Partial) return Redirect("/"); if (!model.ManageUrl.StartsWith("/")) model.ManageUrl = "/" + model.ManageUrl; return Redirect(model.ManageUrl); }
public ActionResult Manage(string aspxerrorpath, bool partial = false) { if (!_auth.IsContentAdmin(HttpContext)) { if (string.IsNullOrEmpty(_config.NotFoundView)) return new HttpNotFoundResult(); else return new HttpNotFoundViewResult(_config.NotFoundView); } ViewBag.CkEditorPath = _config.CkEditorPath + "/ckeditor.js"; var model = new Manage { ManageUrl = aspxerrorpath, IncludeFormTag = _config.ViewEngineOptions.IncludeFormTag }; if (model.ManageUrl.StartsWith("/")) model.ManageUrl = model.ManageUrl.Substring(1); if (_repository.Exists(model.ManageUrl)) { var existingContent = _repository.Get(model.ManageUrl); model.ContentTitle = existingContent.Title; model.EditorContents = existingContent.Contents; model.Partial = existingContent.Partial; } else { model.Partial = partial; } return MeekResult("Manage", model); }