Exemplo n.º 1
0
        public async Task <IActionResult> Chapters(Guid titleId)
        {
            var title = await _titlesManager.GetById(titleId);

            if (title == null || !title.Visible)
            {
                return(NotFound());
            }

            var result = new
            {
                title.Id,
                title.Name,
                Type = title.GetType().Name,
                title.Author,
                title.Artist,
                Synopsis = title.Synopsis.RemoveHtmlTags(),
                title.Status,
                title.Nsfw,
                CoverUrl  = $"/content/{title.Id}/cover.png",
                UpdatedAt = (await _chapterManager.GetLatestChapter(title, false))?.ReleaseDate,
                Tags      = (await _titlesManager.GetTags(title)).Select(tag => tag.Name).ToArray(),
                Chapters  = (await _chapterManager.GetAll(title, false)).Select(chapter => new
                {
                    chapter.Id,
                    chapter.Volume,
                    chapter.Number,
                    chapter.Name,
                    chapter.ReleaseDate
                }).ToArray()
            };

            return(Json(result));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(Guid titleId)
        {
            if (await _titleManager.GetById(titleId) is var title && title == null)
            {
                TempData["ErrorMessage"] = new[] { ValidationMessages.TitleNotFound };

                return(RedirectToAction("Index"));
            }

            ViewData["Title"]       = Labels.EditTitle;
            ViewData["ActionRoute"] = Url.Action("Edit", new { titleId });
            ViewData["Method"]      = "PATCH";

            return(GetEditor(title, await _titleManager.GetTags(title)));
        }
Exemplo n.º 3
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)))));
        }