public ActionResult Add(ChapterDetailModelInput chapter) { if (ModelState.IsValid) { if (_chapterDetailRepository.IsContainInListChapterBook(chapter.IDBook, chapter.ChapterID)) { ModelState.AddModelError("", "ChapterID này đã tồn tại"); } else { ChapterDetail ch = new ChapterDetail { IDBook = chapter.IDBook, ChapterID = chapter.ChapterID, Alias = chapter.Alias, NameChapter = chapter.NameChapter, Content = chapter.Content }; _chapterDetailRepository.Create(ch); return(RedirectToAction("Edit", "Book", new { id = chapter.IDBook })); } } LoadData(chapter.IDBook); return(View()); }
public ActionResult Edit(int idbook, int idChapter) { LoadData(idbook); var chapter = _chapterDetailRepository.getByID2(idbook, idChapter); var model = new ChapterDetailModelInput { IDBook = chapter.IDBook, ChapterID = chapter.ChapterID, Alias = chapter.Alias, NameChapter = chapter.NameChapter, Content = chapter.Content }; return(View("Edit", model)); }
public ActionResult Edit(ChapterDetailModelInput chapter) { if (ModelState.IsValid) { ChapterDetail ch = new ChapterDetail { IDBook = chapter.IDBook, ChapterID = chapter.ChapterID, Alias = chapter.Alias, NameChapter = chapter.NameChapter, Content = chapter.Content }; _chapterDetailRepository.Update(ch); return(RedirectToAction("Edit", "Book", new { id = chapter.IDBook })); } LoadData(chapter.IDBook); return(View()); }