Esempio n. 1
0
        /// <summary>
        /// 获取章节信息(上一章/本章/下一章)
        /// </summary>
        /// <param name="novelId">小说Id</param>
        /// <param name="chapterCode">章节编号</param>
        /// <param name="direction">向前/当前/向后</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public Chapter GetChapter(int novelId, int chapterCode, Constants.Novel.ChapterDirection direction, int status = 1)
        {
            if (novelId <= 0 || chapterCode < 0)
            {
                return(null);
            }

            Chapter model = null;

            using (var conn = DbConnection(DbOperation.Read))
            {
                using (var tran = BeginTransaction(conn))
                {
                    var repo = new Repository.ChapterRepo(conn, tran);
                    if ((model = repo.GetChapter(novelId, chapterCode, direction, status)).IsNullOrEmpty <Chapter>() && direction != Constants.Novel.ChapterDirection.none)
                    {
                        model = repo.GetTopChapter(novelId, chapterCode, direction, status);
                    }

                    tran.Commit();
                }
            }

            return(model);
        }
Esempio n. 2
0
        public IEnumerable <ChapterView> GetPagerList(string columns, string where, string orderBy, out int rowCount, int pageIndex, int pageSize, object param)
        {
            IEnumerable <ChapterView> list = null;

            using (var conn = DbConnection(DbOperation.Read))
            {
                var repo = new Repository.ChapterRepo(conn);
                list = repo.GetPagerList(columns, where, orderBy, out rowCount, pageIndex, pageSize, param);
            }

            return(list);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取最新章节
        /// </summary>
        /// <param name="novelId"></param>
        /// <returns></returns>
        public ChapterView GetLatestChapter(int novelId, int status = 1)
        {
            if (novelId <= 0)
            {
                return(null);
            }

            using (var conn = DbConnection(DbOperation.Read))
            {
                var repo = new Repository.ChapterRepo(conn);
                return(repo.GetLatestChapter(novelId, status));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 获取章节阅读信息
        /// </summary>
        /// <param name="novelId"></param>
        /// <param name="chapterCode"></param>
        /// <returns></returns>
        public ChapterDetail GetChapterView(int novelId, int chapterCode = 0)
        {
            if (novelId <= 0 || chapterCode < 0)
            {
                return(null);
            }

            using (var conn = DbConnection(DbOperation.Read))
            {
                var repo  = new Repository.ChapterRepo(conn);
                var model = repo.GetChapterView(novelId, chapterCode);
                return(model);
            }
        }
Esempio n. 5
0
        public ChapterCodeRange GetChapterCodeRange(int novelId, int status = 1)
        {
            if (novelId <= 0)
            {
                return(null);
            }

            using (var conn = DbConnection(DbOperation.Read))
            {
                var repo  = new Repository.ChapterRepo(conn);
                var model = repo.GetChapterCodeRange(novelId, status);
                return(model);
            }
        }