public IActionResult Edit(NovelModel novel) { DBModel db = new DBModel(); bool editCheck = db.EditNovel(Int32.Parse(novel.Id), novel); if (editCheck) { return(Redirect("/Novel/Detail/?id=" + novel.Id)); } else { return(View()); } }
public void EditNovelInfor() { DBModel db = new DBModel(); //get novel by id NovelModel nv = db.SelectOneNovel("1"); //new infor, cannot change id NovelModel newNv = new NovelModel(); newNv.Name = "Hello"; newNv.Author = "Fire"; bool novel = db.EditNovel(nv, newNv); Assert.IsTrue(novel); //check that add new novel is success or not }
public IActionResult Index(string id, string chapter) { DBModel db = new DBModel(); NovelModel nv = db.SelectOneNovel(id); //increasing view nv.Viewer += 1; bool viewChecking = db.EditNovel(Int32.Parse(id), nv); ViewBag.BookID = id; if (chapter == null) { chapter = "1"; } ViewBag.Chapter = chapter; ViewBag.NextChapter = Int32.Parse(chapter) + 1; ViewBag.Previous = (Int32.Parse(chapter) > 1) ? Int32.Parse(chapter) - 1 : Int32.Parse(chapter); int chap = 1; //get maximum chapter using (StreamReader sr = new StreamReader("./database/novel_book/" + nv.Link)) { string line = sr.ReadLine(); //first is a chapter while (line != null) { if (line.ToLower() == ("chapter " + chap)) { chap += 1; } line = sr.ReadLine(); } } if (ViewBag.NextChapter > chap - 1) { ViewBag.NextChapter = chap - 1; } return(View(nv)); }