@page "/inspect" @using Microsoft.AspNetCore.Authorization @using JustShortIt.Model @using Microsoft.Extensions.Caching.Distributed @attribute [Authorize] @inject IDistributedCache Db Inspect - Just Short It
@if (Model is null) {

URL not found

The given ID does not exist, it may have expired or been deleted.

} else {

Inspect

ID
@Model.Id
URL-Target
@Model.Target
} Back to URLs
@code { [SupplyParameterFromQuery] public string? Id { get; set; } private string? Message { get; set; } private MessageComponent.AlertType Type { get; set; } private UrlRedirect? Model { get; set; } protected override async Task OnInitializedAsync() { if (Id is not null) { string? url = await Db.GetStringAsync(Id); if (url is not null) Model = new UrlRedirect(Id, url, string.Empty); } } private async Task Submit_Delete() { if (Id is null) { Message = $"Invalid Request: Deletion without Id"; return; } await Db.RemoveAsync(Id); Type = MessageComponent.AlertType.Success; Message = $"Id '{Id}' successfully deleted."; Id = null; Model = null; } }