t2
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user