[CHANGE] Added video info page
This commit is contained in:
48
Manager.App/Components/Pages/Video.razor.cs
Normal file
48
Manager.App/Components/Pages/Video.razor.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user