using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using PlotLine.Services; namespace PlotLine.Controllers; [Authorize] public sealed class PlotLineWorkspaceController(IPlotLineWorkspaceService workspace) : Controller { public async Task Index( int projectId, int? bookId, [FromQuery(Name = "plotLineId")] int[]? plotLineIds, [FromQuery(Name = "threadId")] int[]? threadIds, int? scenarioId, bool showSuggestions = false) { var model = await workspace.GetAsync(projectId, bookId, plotLineIds, threadIds, scenarioId, showSuggestions, false); return model is null ? NotFound() : Request.Headers["X-Plot-Map"] == "true" ? PartialView("_NarrativeMap", model) : View(model); } public async Task Unattributed(int projectId, int? bookId, int? scenarioId) { var model = await workspace.GetAsync(projectId, bookId, [], [], scenarioId, false, true); return model is null ? NotFound() : View("Index", model); } public async Task Inspector(int projectId, int? bookId, int sceneId, int? scenarioId) { var model = await workspace.GetInspectorAsync(projectId, bookId, sceneId, scenarioId); return model is null ? NotFound() : PartialView("_Inspector", model); } [HttpGet] public async Task Health(int projectId, int? bookId, int plotLineId, int? scenarioId) { var model = await workspace.GetAsync(projectId, bookId, [plotLineId], [], scenarioId, false, false); return model is null || !model.SelectedPlotLineIDs.Contains(plotLineId) ? NotFound() : PartialView("_Health", model); } public async Task Manuscript(int projectId, int? bookId, int sceneId) { var model = await workspace.GetManuscriptAsync(projectId, bookId, sceneId); return model is null ? NotFound() : PartialView("_Manuscript", model); } }