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)); }
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))); }
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))); }
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))))); }