This commit is contained in:
Ccjcarkbla
2026-02-23 13:05:16 -05:00
parent 637787d016
commit 1a8d8fef70
9 changed files with 189 additions and 39 deletions
+35 -1
View File
@@ -1,10 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using maintenance.Services.Templates;
namespace maintenance.Pages.Errors;
public sealed class TemplateModel : PageModel
{
private readonly ITemplateService _templateService;
public TemplateModel(ITemplateService templateService)
{
_templateService = templateService;
}
[FromQuery(Name = "template")]
public string TemplateName { get; set; } = "template";
[FromQuery(Name = "errorName")]
public string ErrorName { get; set; } = "Error Name";
@@ -29,13 +40,36 @@ public sealed class TemplateModel : PageModel
[FromQuery(Name = "code")]
public string ErrorCode { get; set; } = "eaX";
public string? SupportContactBlock { get; private set; }
public IReadOnlyList<string> InstructionSteps { get; private set; } = new List<string>
{
"Change some setting"
};
public void OnGet()
public async Task OnGetAsync()
{
var template = await _templateService.GetByNameAsync(TemplateName, HttpContext.RequestAborted);
if (template is not null)
{
if (!Request.Query.ContainsKey("errorName") && !string.IsNullOrWhiteSpace(template.Title))
{
ErrorName = template.Title;
}
if (!Request.Query.ContainsKey("desc") && !string.IsNullOrWhiteSpace(template.Body))
{
Description = template.Body;
}
SupportContactBlock = template.SupportContactBlock;
if (!Request.Query.ContainsKey("showSupport") && string.IsNullOrWhiteSpace(SupportContactBlock))
{
ShowSupport = false;
}
}
if (!string.IsNullOrWhiteSpace(StepsCsv))
{
InstructionSteps = StepsCsv