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()); }
/// <summary> /// 获取章节阅读信息 /// </summary> /// <param name="novelId"></param> /// <param name="chapterCode"></param> /// <returns></returns> public ChapterDetail GetChapterView(int novelId, int chapterCode) { string sql = @"select n.Title as NovelTitle,n.Id as NovelId,n.Author,n.CPId,n.FeeType,n.FreeChapterCount,n.FilePath,n.ClassId,n.FreeChapterCount,n.TotalChapterCount,n.ContentType, c.Id as ChapterId,c.ChapterName,c.ChapterCode,c.OnlineTime,c.WordSize,c.FileName,c.IsFree,c.Fee from Novel n with (nolock) left join Chapter c with (nolock) on n.Id=c.NovelId where c.Status=1 and c.OnlineTime<=@OnlineTime and n.Id=@novelId and c.ChapterCode=@chapterCode"; ChapterDetail view = DbManage.Query <ChapterDetail>(sql, new { novelId = novelId, chapterCode = chapterCode, OnlineTime = DateTime.Now }).FirstOrDefault(); return(view); }
public ActionResult AddChapter(int id) { var user = (UserLogin)Session[Constants.USER_SESSION]; var manga = db.Mangas.Where(i => i.mId == id).FirstOrDefault(); if (user.UserId != manga.CreatedBy) { return(RedirectToAction("Error")); } var chapter = new ChapterDetail(); chapter.mId = id; return(View(chapter)); }
public ActionResult C(int id) { var chapter = db.Chapters.Where(i => i.cId == id).FirstOrDefault(); var chapterDetail = new ChapterDetail(); chapterDetail.Images = db.Images.Where(i => i.cId == id).Select(i => i.source).ToList(); var nextChapter = db.Chapters.Where(i => i.mId == chapter.mId && i.cId > id).OrderBy(i => i.cId).FirstOrDefault(); var prevChapter = db.Chapters.Where(i => i.mId == chapter.mId && i.cId < id).OrderByDescending(i => i.cId).FirstOrDefault(); chapterDetail.nextChapter = (nextChapter != null) ? nextChapter.cId : 0; chapterDetail.prevChapter = (prevChapter != null) ? prevChapter.cId : 0; chapterDetail.displayName = chapter.cName; chapterDetail.mId = chapter.mId; return(View(chapterDetail)); }
public ActionResult AddChapter(ChapterDetail chapter) { var dao = new MangaDao(); var path = ""; var fileName = ""; var imgList = new List <ImageViewModel>(); var user = (UserLogin)Session[Constants.USER_SESSION]; if (chapter.imgFile.Any()) { var c = new Chapter(); c.cName = chapter.displayName; c.cPostOn = DateTime.Now; c.mId = chapter.mId; var cId = dao.AddChapter(c); var currentDir = Path.Combine(HttpRuntime.AppDomainAppPath, "Image", chapter.mId.ToString(), cId.ToString()); if (!Directory.Exists(currentDir)) { Directory.CreateDirectory(currentDir); } foreach (var file in chapter.imgFile) { fileName = file.FileName; if (file.ContentLength > 0) { if (Path.GetExtension(fileName).ToLower() == ".jpg" || Path.GetExtension(fileName).ToLower() == ".png" || Path.GetExtension(fileName).ToLower() == ".gif" || Path.GetExtension(fileName).ToLower() == ".jpeg") { file.SaveAs(Path.Combine(currentDir, fileName)); var image = new ImageViewModel(); image.src = "/Image/" + c.mId.ToString() + "/" + c.cId.ToString() + "/" + fileName; imgList.Add(image); } } } foreach (var img in imgList) { var i = new Image(); i.cId = cId; i.source = img.src; dao.AddImage(i); } } return(RedirectToAction("UploadedManga")); }
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()); }
public ChapterDetail Get(ChapterCriteria criteria) { var qChapter = Table <Chapter>().All(); if (criteria.IDToInt > 0) { qChapter = qChapter.Where(w => w.ID == criteria.IDToInt); } var chapter = qChapter.FirstOrDefault(); if (chapter == null) { return(null); } var chapterDetail = new ChapterDetail(); MapProperty(chapter, chapterDetail); return(chapterDetail); }
public void Update(ChapterDetail chapterDetail) { _chapterDetailRepository.Update(chapterDetail); }
public void Delete(ChapterDetail chapterDetail) { _chapterDetailRepository.Delete(chapterDetail); }
public void Create(ChapterDetail chapterDetail) { _chapterDetailRepository.Create(chapterDetail); }
/// <summary> /// 设置自定义章节详情 /// </summary> /// <param name="detail">章节详情</param> /// <param name="mode">起始位置</param> /// <param name="addonLength">偏移值</param> public void SetCustomContent(ChapterDetail detail, ReaderStartMode mode, int addonLength = 0) { _readerView.SetContent(detail.GetReadContent(), mode, addonLength); }