59 lines
2.3 KiB
C#
59 lines
2.3 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PlotLine.Services;
|
|
|
|
namespace PlotLine.Controllers;
|
|
|
|
[Authorize]
|
|
public sealed class PlotLineWorkspaceController(IPlotLineWorkspaceService workspace, IPlotService plots) : Controller
|
|
{
|
|
public async Task<IActionResult> 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<IActionResult> Manage(int projectId)
|
|
{
|
|
var lines = await plots.GetPlotLinesAsync(projectId);
|
|
if (lines is null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
var threads = await plots.GetPlotThreadsAsync(projectId);
|
|
return threads is null ? NotFound() : View((lines, threads));
|
|
}
|
|
|
|
public async Task<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> Manuscript(int projectId, int? bookId, int sceneId)
|
|
{
|
|
var model = await workspace.GetManuscriptAsync(projectId, bookId, sceneId);
|
|
return model is null ? NotFound() : PartialView("_Manuscript", model);
|
|
}
|
|
}
|