| 1 |
using System.Text.Json; |
| 2 |
using System.Text.RegularExpressions; |
| 3 |
using Blog.Services; |
| 4 |
using Microsoft.AspNetCore.Components; |
| 5 |
|
| 6 |
namespace Blog.Components.Pages; |
| 7 |
|
| 8 |
public partial class BRP : ComponentBase |
| 9 |
{ |
| 10 |
[Parameter] |
| 11 |
public required string BSN { get; set; } |
| 12 |
|
| 13 |
[Inject] |
| 14 |
public required BrpService Service { get; set; } |
| 15 |
|
| 16 |
private JsonDocument RequestBody { get; set; } |
| 17 |
|
| 18 |
private JsonDocument Entry { get; set; } |
| 19 |
|
| 20 |
protected override async Task OnInitializedAsync() |
| 21 |
{ |
| 22 |
(RequestBody, Entry) = await Service.GetBrpEntryAsync(BSN).ConfigureAwait(true); |
| 23 |
await base.OnInitializedAsync(); |
| 24 |
} |
| 25 |
|
| 26 |
internal static string Url(string bsn) |
| 27 |
{ |
| 28 |
return $"/BRP/{bsn}"; |
| 29 |
} |
| 30 |
|
| 31 |
internal static bool LooksLikeBSN(string value) |
| 32 |
{ |
| 33 |
return BsnRegex().IsMatch(value); |
| 34 |
} |
| 35 |
|
| 36 |
[GeneratedRegex(@"^\d{8,9}$", RegexOptions.NonBacktracking)] |
| 37 |
private static partial Regex BsnRegex(); |
| 38 |
} |