using Microsoft.AspNetCore.Mvc.RazorPages; using maintenance.Services.Templates; namespace maintenance.Pages.Errors; public sealed class UnavailableModel : PageModel { private readonly ITemplateService _templateService; public UnavailableModel(ITemplateService templateService) { _templateService = templateService; } public string Title { get; private set; } = "Application Unavailable"; public string DescriptionLine1 { get; private set; } = "MAX applications may be down for scheduled maintenance 2AM-8AM Sunday morning."; public string DescriptionLine2 { get; private set; } = "If you are receiving this message at any other time, please contact MAX Support."; public string ErrorCode { get; private set; } = "eau"; public string? SupportContactBlock { get; private set; } public async Task OnGetAsync() { var template = await _templateService.GetByNameAsync("unavailable", HttpContext.RequestAborted); if (template is null) { return; } Title = string.IsNullOrWhiteSpace(template.Title) ? Title : template.Title; if (!string.IsNullOrWhiteSpace(template.Body)) { var lines = template.Body .Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); if (lines.Length > 0) { DescriptionLine1 = lines[0]; } if (lines.Length > 1) { DescriptionLine2 = lines[1]; } } SupportContactBlock = template.SupportContactBlock; } }