summaryrefslogtreecommitdiff
path: root/Blog/Components/Pages/BRP.razor.cs
blob: 1398a01406ebc0e99ce84f403a2111b056befffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Text.Json;
using System.Text.RegularExpressions;
using Blog.Services;
using Microsoft.AspNetCore.Components;

namespace Blog.Components.Pages;

public partial class BRP : ComponentBase
{
    [Parameter]
    public required string BSN { get; set; }
    
    [Inject]
    public required BrpService Service { get; set; }
    
    private JsonDocument RequestBody { get; set; }

    private JsonDocument Entry { get; set; }

    protected override async Task OnInitializedAsync()
    {
        (RequestBody, Entry) = await Service.GetBrpEntryAsync(BSN).ConfigureAwait(true);
        await base.OnInitializedAsync();
    }

    internal static string Url(string bsn)
    {
        return $"/BRP/{bsn}";
    }

    internal static bool LooksLikeBSN(string value)
    {
        return BsnRegex().IsMatch(value);
    }

    [GeneratedRegex(@"^\d{8,9}$", RegexOptions.NonBacktracking)]
    private static partial Regex BsnRegex();
}