Добавлен playlist shared

This commit is contained in:
FrigaT
2026-04-11 15:41:24 +03:00
parent 8444fc5f8e
commit ba9d97239e
84 changed files with 61796 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
@page "/myplaylists"
@attribute [Authorize]
@using System.Security.Claims
@using Microsoft.EntityFrameworkCore
@using Microsoft.AspNetCore.Components.Authorization
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject AppDbContext Db
@inject NavigationManager Navigation
<h3>Мои плейлисты</h3>
<a href="/createplaylist" class="btn btn-success mb-3">Создать новый плейлист</a>
@if (playlists == null)
{
<p>Загрузка...</p>
}
else if (!playlists.Any())
{
<p>У вас пока нет общих плейлистов. Создайте первый!</p>
}
else
{
<table class="table">
<thead>
<tr><th>Название</th><th>Дата создания</th><th>Ссылка</th><th>Настройки</th></tr>
</thead>
<tbody>
@foreach (var pl in playlists)
{
<tr>
<td>@pl.Title</td>
<td>@pl.CreatedAt.ToShortDateString()</td>
<td><a href="/playlist/@pl.ShareSlug">открыть</a></td>
<td><a href="/settings/@pl.Id">настройки</a></td>
</tr>
}
</tbody>
</table>
}
@code {
private List<SharedPlaylist>? playlists;
private string? userId;
protected override async Task OnInitializedAsync()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
userId = authState.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (userId != null)
{
playlists = await Db.SharedPlaylists
.Where(p => p.OwnerUserId == userId)
.OrderByDescending(p => p.CreatedAt)
.ToListAsync();
}
}
}