示例#1
0
        public async Task <IActionResult> Index(Guid titleId, ushort page = 1)
        {
            if (await _titleManager.GetById(titleId) is var title && title == null)
            {
                TempData["ErrorMessage"] = new[] { ValidationMessages.TitleNotFound };

                return(RedirectToAction("Index", "TitlesManager"));
            }

            var totalPages = Math.Ceiling(await _chapterManager.Count(title) / (decimal)Constants.ItemsPerPageChapterAdmin);

            page = page >= 1 && page <= totalPages ? page : (ushort)1;

            ViewData["Title"]         = $"{Labels.Chapters} - {title.Name}";
            ViewData["Page"]          = page;
            ViewData["TotalPages"]    = totalPages;
            ViewData["DeletionRoute"] = Url.Action("Delete", new { titleId, chapterId = Guid.Empty }).Replace(Guid.Empty.ToString(), string.Empty);

            return(View(await _chapterManager.GetRange(title, Constants.ItemsPerPageChapterAdmin * (page - 1), Constants.ItemsPerPageChapterAdmin)));
        }
示例#2
0
        public async Task <IActionResult> Titles(Guid titleId)
        {
            if (await _titlesManager.GetById(titleId) is var title && title == null)
            {
                return(RedirectToAction("Titles"));
            }

            if (!_signInManager.IsSignedIn(User) && !title.Visible)
            {
                return(RedirectToAction("Titles"));
            }

            if (title.Nsfw && !HasNsfwCookie())
            {
                return(View("NSFWTitleWarning", title));
            }

            ViewData["TotalPages"] = Math.Ceiling(await _chapterManager.Count(title, _signInManager.IsSignedIn(User)) / (decimal)Constants.ItemsPerPageChapters);

            return(View("Title", ValueTuple.Create(title, await _titlesManager.GetTags(title), await _chapterManager.GetRange(title, 0, Constants.ItemsPerPageChapters, _signInManager.IsSignedIn(User)))));
        }