public async Task <IActionResult> Edit(string url = null) { if (string.IsNullOrEmpty(url)) { return(RedirectToAction("List")); } SpeedWagonContent content = await this._speedWagon.GetContent(url); SpeedWagonContent parent = await this._speedWagon.ContentService.Parent(content); SpeedWagonContent contentType = await this._speedWagon.ContentTypeService.Get(content.Type); IEnumerable <SpeedWagonContent> editors = await this._speedWagon.EditorService.List(); IEnumerable <ContentTypeEditor> properties = this._speedWagon.ContentTypeService.GetEditors(contentType); EditContentViewModel viewModel = new EditContentViewModel(); viewModel.Url = content.RelativeUrl; viewModel.Parent = parent.RelativeUrl; viewModel.Content = content; viewModel.Editors = editors; viewModel.ContentType = contentType; viewModel.ContentTypeProperties = properties; viewModel.ViewEngine = this._viewEngine; viewModel.Values = this._speedWagon.WebContentService.GetValues(content, properties); return(View("~/Views/SpeedWagon/Content/Edit.cshtml", viewModel)); }
public IActionResult Edit(Guid repositoryid, Guid contentid) { ICmsManager manager = new CmsManager(); IRepository repository = manager.GetRepositoryById(repositoryid); if (repository == null) { return(Redirect("/fcmsmanager/home")); } IContentStore contentStore = manager.GetContentStore(repositoryid); EditContentViewModel model = new EditContentViewModel(); model.RepositoryName = repository.Name; model.Item = contentStore.Items.Where(m => m.Id == contentid).FirstOrDefault(); if (model.Item == null) { return(Redirect("/fcmsmanager/repository?d=" + contentid)); } model.ContentDefinition = repository.ContentDefinitions.Where(m => m.DefinitionId == model.Item.DefinitionId).FirstOrDefault(); model.RepositoryId = repositoryid; return(View("Edit", model)); }
public IActionResult EditContentSave(EditContentViewModel model) { if (ModelState.IsValid) { ICmsManager manager = new CmsManager(); IContentStore contentStore = manager.GetContentStore(model.RepositoryId); ContentItem item = contentStore.Items.Where(m => m.Id == model.Item.Id).FirstOrDefault(); IRepository repository = manager.GetRepositoryById(model.RepositoryId); model.ContentDefinition = repository.ContentDefinitions.Where(m => m.DefinitionId == model.DefinitionId).FirstOrDefault(); if (item == null) { item = FCms.Factory.ContentFactory.CreateContentByType(model.ContentDefinition); model.MapToModel(item, Request); contentStore.Items.Add(item); } else { model.MapToModel(contentStore.GetById((Guid)model.Item.Id), Request); } manager.SaveContentStore(contentStore); return(Redirect("/fcmsmanager/pagecontent/list?repositoryid=" + model.RepositoryId + "&definitionid=" + item.DefinitionId.ToString())); } return(View("Edit", new RepositoryViewModel())); }
public async Task <ActionResult> Edit(int id, EditContentViewModel editContent) { if (ModelState.IsValid) { try { if (await _conService.UpdateContentWithID(id, editContent, _env)) { return(RedirectToAction(nameof(Index))); } // TODO: Add update logic here return(View("Error", new ErrorViewModel { RequestId = "Unable to edit" })); } catch { return(View("Error", new ErrorViewModel { RequestId = "Unable to edit" })); } } return(RedirectToAction(nameof(Edit))); }
public ActionResult EditContent(int id, string schema, string editContentHeading) { var model = new EditContentViewModel(); var editContentHelper = new EditContentHelper(Context); editContentHelper.LoadContentViewById(id, model); var userName = UserUtils.CurrentMembershipUsername(); var user = Context.Users.First(usr => usr.Username == userName); model.IsBookmarked = Context.Bookmarks.Any(bookmark => bookmark.Url == Request.RawUrl && bookmark.UserId == user.UserId); schema = schema ?? "0"; // If Schema is Assigned, make sure to show the Field Editor int schemaId = Int32.Parse(schema); if (schemaId > 0) { model.ShowFieldEditor = true; } if (!String.IsNullOrEmpty(editContentHeading)) { model.Heading = editContentHeading; } return(View(model)); }
public async ValueTask <IActionResult> EditPost(EditContentViewModel model) { if (string.IsNullOrEmpty(model.TargetId)) { return(NotFound()); } var contentItem = await _session.Query <ContentItem>() .With <ContentItemIndex>(x => x.ContentItemId == model.TargetId && x.Owner == User.Identity.Name && x.Latest && x.ContentType == PublishContent) .FirstOrDefaultAsync(); if (contentItem == null) { return(NotFound()); } contentItem = await _contentManager.GetAsync(model.TargetId, VersionOptions.DraftRequired); var shape = await _contentItemDisplayManager.UpdateEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, false); if (!ModelState.IsValid) { await _session.CancelAsync(); return(View("Edit", model)); } await _contentManager.PublishAsync(contentItem); _notifier.Success(H["发布成功"]); return(RedirectToAction("index")); }
public async ValueTask <IActionResult> Edit(string id) { if (string.IsNullOrEmpty(id)) { return(NotFound()); } var contentItem = await _session.Query <ContentItem>() .With <ContentItemIndex>(x => x.ContentItemId == id && x.Owner == User.Identity.Name && x.Latest && x.ContentType == PublishContent) .FirstOrDefaultAsync(); if (contentItem == null) { return(NotFound()); } var model = new EditContentViewModel() { Title = contentItem.DisplayText, Content = contentItem.Content.MarkdownBodyPart?.Markdown, Description = contentItem.Content.BlogPost?.Subtitle?.Text, TargetId = id, }; return(View(model)); }
public ActionResult EditContentBasic(int id) { var model = new EditContentViewModel(); var editContentHelper = new EditContentHelper(Context); editContentHelper.LoadContentViewById(id, model); return(View(model)); }
public async Task <IActionResult> Edit(EditContentViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("List", "SpeedWagonContent", new { url = model.Url })); } SpeedWagonContent content = await this._speedWagon.GetContent(model.Url); this._speedWagon.WebContentService.SetValues(content, model.Values); this._speedWagon.WebContentService.Save(content, User.Identity.Name.MaskEmail()); SpeedWagonContent parent = await this._speedWagon.ContentService.Parent(content); return(RedirectToAction("List", "SpeedWagonContent", new { url = parent.RelativeUrl })); }
public ActionResult EditContent(EditContentViewModel contentViewModel) { if (contentViewModel != null) { if (ModelState.IsValid) { var content = _contentRepository.Get(contentViewModel.Slug, contentViewModel.Tag); content.Title = contentViewModel.Title; content.ContentText = contentViewModel.ContentText; content.PostDate = DateTime.Now; _contentRepository.Save(content); } } ViewBag.SlugSelectList = _slugSelectList; ViewBag.TagSelectList = new List <SelectListItem>(); return(View(contentViewModel)); }
public IActionResult Add(Guid repositoryid, Guid definitionid) { ICmsManager manager = new CmsManager(); IRepository repository = manager.GetRepositoryById(repositoryid); if (repository == null) { throw new FCms.Exceptions.RepositoryNotFoundException(); } IContentStore contentStore = manager.GetContentStore(repositoryid); EditContentViewModel model = new EditContentViewModel(); model.Item = FCms.Factory.ContentFactory.CreateContentByType(repository.ContentDefinitions.Where(m => m.DefinitionId == definitionid).FirstOrDefault()); model.ContentDefinition = repository.ContentDefinitions.Where(m => m.DefinitionId == definitionid).FirstOrDefault(); model.RepositoryId = repositoryid; model.Item.DefinitionId = definitionid; return(View("Edit", model)); }
public ActionResult Index() { ContentViewViewModel model = null; //Remove query string var thisUri = new Uri(Request.Url.GetLeftPart(UriPartial.Path)); // Check for content pages before returning a 404 var fullPath = GetPageFullPath(thisUri); // If url has a subdirectory, try the master url list to see if it is a child page bool hasSubDirectory = fullPath.Contains("/"); if (hasSubDirectory) { model = GetSubDirectoryModel(fullPath); } // If not a subdirectory try based on permalink / title if (model == null || model.ThePage == null) { model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsByPermalink(fullPath) }; } // If we found a hit, return the view, otherwise 404 if (model.ThePage != null) { model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template); model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent); if (UserUtils.UserIsAdmin()) { var userName = UserUtils.CurrentMembershipUsername(); var user = Context.Users.First(usr => usr.Username == userName); var pageModel = new EditContentViewModel(); var editContentHelper = new EditContentHelper(Context); editContentHelper.LoadContentViewById(model.ThePage.ContentPageId, pageModel); pageModel.BookmarkTitle = model.ThePage.Title; pageModel.IsBookmarked = Context.Bookmarks.Any( bookmark => bookmark.Title == fullPath && bookmark.Url == Request.RawUrl && bookmark.UserId == user.UserId); ViewBag.PageModel = pageModel; } ViewBag.IsPage = true; ViewBag.PageId = model.ThePage.ContentPageId; ViewBag.IsPublished = model.ThePage.IsActive; ViewBag.OGType = model.ThePage.OGType ?? "website"; ViewBag.MetaDesc = model.ThePage.MetaDescription ?? ""; ViewBag.Title = model.ThePage.Title; ViewBag.OGTitle = model.ThePage.Title ?? model.ThePage.OGTitle; ViewBag.OGImage = model.ThePage.OGImage ?? ""; // Set the page Canonical Tag and OGURl ViewBag.Canonical = GetCanonical(model.ThePage); ViewBag.OGUrl = model.ThePage.OGUrl ?? ViewBag.Canonical; ViewBag.Index = model.ThePage.NoIndex ? "noindex" : "index"; ViewBag.Follow = model.ThePage.NoFollow ? "nofollow" : "follow"; return View(model.TheTemplate.ViewLocation, model); } model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsById(Convert.ToInt16(ConfigurationManager.AppSettings["404ContentPageId"])) }; model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template); model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent); ViewBag.IsPage = true; ViewBag.PageId = model.ThePage.ContentPageId; ViewBag.IsPublished = model.ThePage.IsActive; ViewBag.Title = model.ThePage.Title; ViewBag.Index = "noindex"; ViewBag.Follow = "nofollow"; HttpContext.Response.StatusCode = 404; Response.TrySkipIisCustomErrors = true; return View(model.TheTemplate.ViewLocation, model); }
public ActionResult Index() { ContentViewViewModel model = null; //Remove query string var thisUri = new Uri(Request.Url.GetLeftPart(UriPartial.Path)); // Check for content pages before returning a 404 var title = GetPageTitle(thisUri); // If url has a subdirectory, try the master url list to see if it is a child page bool hasSubDirectory = title.Contains("/"); if (hasSubDirectory) { model = GetSubDirectoryModel(title); } // If not a subdirectory try based on permalink / title if (model == null || model.ThePage == null) { model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsByTitle(title) }; } // If we found a hit, return the view, otherwise 404 if (model.ThePage != null) { model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template); model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent); if (UserUtils.UserIsAdmin()) { var userName = UserUtils.CurrentMembershipUsername(); var user = Context.Users.First(usr => usr.Username == userName); var pageModel = new EditContentViewModel(); var editContentHelper = new EditContentHelper(Context); editContentHelper.LoadContentViewById(model.ThePage.ContentPageId, pageModel); pageModel.BookmarkTitle = model.ThePage.Title; pageModel.IsBookmarked = Context.Bookmarks.Any( bookmark => bookmark.Title == title && bookmark.Url == Request.RawUrl && bookmark.UserId == user.UserId); ViewBag.PageModel = pageModel; } ViewBag.IsPage = true; ViewBag.PageId = model.ThePage.ContentPageId; ViewBag.IsPublished = model.ThePage.IsActive; ViewBag.OGType = model.ThePage.OGType ?? "website"; ViewBag.MetaDesc = model.ThePage.MetaDescription ?? ""; ViewBag.Title = model.ThePage.Title; ViewBag.OGTitle = model.ThePage.Title ?? model.ThePage.OGTitle; ViewBag.OGImage = model.ThePage.OGImage ?? ""; // Set the page Canonical Tag and OGURl ViewBag.Canonical = GetCanonical(model.ThePage); ViewBag.OGUrl = model.ThePage.OGUrl ?? ViewBag.Canonical; ViewBag.Index = model.ThePage.NoIndex ? "noindex" : "index"; ViewBag.Follow = model.ThePage.NoFollow ? "nofollow" : "follow"; return(View(model.TheTemplate.ViewLocation, model)); } model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsByTitle("404") }; model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template); model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent); ViewBag.IsPage = true; ViewBag.PageId = model.ThePage.ContentPageId; ViewBag.IsPublished = model.ThePage.IsActive; ViewBag.Title = model.ThePage.Title; ViewBag.Index = "noindex"; ViewBag.Follow = "nofollow"; HttpContext.Response.StatusCode = 404; Response.TrySkipIisCustomErrors = true; return(View(model.TheTemplate.ViewLocation, model)); }