74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PlotLine.Models;
|
|
using PlotLine.Services;
|
|
using PlotLine.ViewModels;
|
|
|
|
namespace PlotLine.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("onboarding")]
|
|
public sealed class OnboardingController(IOnboardingService onboarding) : Controller
|
|
{
|
|
[HttpGet("")]
|
|
public async Task<IActionResult> Index()
|
|
{
|
|
var model = await onboarding.GetWizardAsync();
|
|
return View(model);
|
|
}
|
|
|
|
[HttpPost("welcome")]
|
|
[ValidateAntiForgeryToken]
|
|
public async Task<IActionResult> Welcome()
|
|
{
|
|
await onboarding.MoveToNextStepAsync();
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
|
|
[HttpPost("writing-journey")]
|
|
[ValidateAntiForgeryToken]
|
|
public async Task<IActionResult> WritingJourney(WritingJourneyOnboardingForm form)
|
|
{
|
|
if (!ModelState.IsValid || string.IsNullOrWhiteSpace(form.WritingJourney))
|
|
{
|
|
var model = await onboarding.GetWizardAsync();
|
|
model.CurrentStep = OnboardingSteps.WritingJourney;
|
|
model.StepNumber = 2;
|
|
return View(nameof(Index), model);
|
|
}
|
|
|
|
await onboarding.SaveWritingJourneyAsync(form.WritingJourney);
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
|
|
[HttpPost("writing-software")]
|
|
[ValidateAntiForgeryToken]
|
|
public async Task<IActionResult> WritingSoftware(WritingSoftwareOnboardingForm form)
|
|
{
|
|
if (!ModelState.IsValid || string.IsNullOrWhiteSpace(form.WritingSoftware))
|
|
{
|
|
var model = await onboarding.GetWizardAsync();
|
|
model.CurrentStep = OnboardingSteps.WritingSoftware;
|
|
model.StepNumber = 3;
|
|
return View(nameof(Index), model);
|
|
}
|
|
|
|
await onboarding.SaveWritingSoftwareAsync(form.WritingSoftware);
|
|
TempData["ArchiveMessage"] = "Setup saved. PlotDirector will use those answers to guide future story setup.";
|
|
return RedirectToAction("Index", "Projects");
|
|
}
|
|
|
|
[HttpPost("back")]
|
|
[ValidateAntiForgeryToken]
|
|
public async Task<IActionResult> Back(string currentStep)
|
|
{
|
|
var targetStep = currentStep == OnboardingSteps.WritingSoftware
|
|
? OnboardingSteps.WritingJourney
|
|
: OnboardingSteps.Welcome;
|
|
|
|
await onboarding.SetCurrentStepAsync(targetStep);
|
|
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
}
|