using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Collections;

namespace Admin.Pages.Server
{
    public class EnvModel : PageModel
    {
        public IReadOnlyList<KeyValuePair<string, string>> EnvVars { get; set; } = [];

        public void OnGet()
        {
            EnvVars = Environment.GetEnvironmentVariables()
               .Cast<DictionaryEntry>()
               .Select(e => new KeyValuePair<string, string>(
                   e.Key?.ToString() ?? string.Empty,
                   e.Value?.ToString() ?? string.Empty))
               .OrderBy(kv => kv.Key, StringComparer.OrdinalIgnoreCase)
               .ToArray();
        }
    }
}