How do I delete a chapter?

Jun 9, 2011 at 10:27 PM

Am I missing something obvious? I see how to delete a book, but I don't see how to delete a chapter.

Sep 7, 2011 at 4:05 PM

The chapter delete is not fully completed in this version from what I could tell but it is really easy to get up and going.  Two files need to be modified: "Views\ChapterAdmin\Index.cshtml"  and the  "Controllers\ChapterAdminController.cs"

 

The Index.cshtml file needs to have the delete link added to it:

 

				<td>
				@Html.ActionLink(T("Properties").ToString(), "Edit", new { id = chapter.Id }) |
				@Html.ActionLink(T("Move").ToString(), "MoveChapter", new { bookId = Model.Book.Id, chapterId = chapter.Id }) |
				@Html.ActionLink(T("Delete").Text, "Delete", new { Id = chapter.Id }, new object { })
				</td>

 

And the ChapterAdminController.cs file needs to have the Delete function changed:

 

        public ActionResult Delete(int id) {
            if (!Services.Authorizer.Authorize(Permissions.ManageChapters, T("Couldn't create chapter")))
                return new HttpUnauthorizedResult();

            var chapter = Services.ContentManager.Get<ChapterPart>(id);

            if (chapter == null) {
                return HttpNotFound();
            }

            bool redirectToChapter = chapter.Record.Book != null;

            _chapterService.Delete(chapter);

            Services.Notifier.Information(T("Chapter was successfully deleted"));

	    //if (redirectToChapter) {
	    //    return RedirectToAction("EditChapters", new { id = chapter.Record.Book.Id });
	    //}

	    return RedirectToAction("Index", new { bookId = chapter.Record.Book.Id });
        }