using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using OliverBooth.Common.Data.Web; using OliverBooth.Common.Services; namespace OliverBooth.Pages.Tutorials; /// /// Represents the page model for the Article page. /// public class Article : PageModel { private readonly ITutorialService _tutorialService; /// /// Initializes a new instance of the class. /// /// The . public Article(ITutorialService tutorialService) { _tutorialService = tutorialService; } /// /// Gets the requested article. /// /// The requested article. public ITutorialArticle CurrentArticle { get; private set; } = null!; public IActionResult OnGet(string slug) { if (!_tutorialService.TryGetArticle(slug, out ITutorialArticle? article)) { Response.StatusCode = 404; return NotFound(); } CurrentArticle = article; return Page(); } }