using Manager.YouTube.Models; using Microsoft.AspNetCore.Components; using MudBlazor; namespace Manager.App.Components.Pages; public partial class Video : ComponentBase { [Parameter] public required string VideoId { get; set; } [SupplyParameterFromQuery(Name = "clientId")] public string ClientId { get; set; } = ""; private bool _loading = true; private YouTubeVideo? _video; protected override async Task OnInitializedAsync() { if (string.IsNullOrEmpty(VideoId)) { Snackbar.Add("Video id is null or empty!", Severity.Error); _loading = false; return; } var clientResult = await ClientService.LoadClientByIdAsync(ClientId); if (!clientResult.IsSuccess) { Snackbar.Add(clientResult.Error?.Description ?? "Failed to load client!", Severity.Error); _loading = false; return; } var client = clientResult.Value; var videoResult = await client.GetVideoByIdAsync(VideoId); if (!videoResult.IsSuccess) { Snackbar.Add(videoResult.Error?.Description ?? "Failed to get video.", Severity.Error); _loading = false; return; } _video = videoResult.Value; _loading = false; } }