Добавьте файлы проекта.

This commit is contained in:
FrigaT
2026-04-13 14:16:44 +03:00
parent b2b5a3945a
commit 37c997dbe0
120 changed files with 5364 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using System.Security.Claims;
namespace PlaylistShared.Api.Extensions;
public static class ClaimsPrincipalExtensions
{
public static Guid GetUserId(this ClaimsPrincipal user)
{
var id = user.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (string.IsNullOrEmpty(id))
throw new UnauthorizedAccessException("User ID not found");
return Guid.Parse(id);
}
public static Guid? GetUserIdOrNull(this ClaimsPrincipal user)
{
var id = user.FindFirst(ClaimTypes.NameIdentifier)?.Value;
return string.IsNullOrEmpty(id) ? null : Guid.Parse(id);
}
}

View File

@@ -0,0 +1,19 @@
using YandexMusic.API.Models.Common.Cover;
namespace PlaylistShared.Api.Extensions;
public static class YCoverExtensions
{
public static string GetUrl(this YCover cover, string size = "200x200")
{
switch (cover)
{
case YCoverImage img when !string.IsNullOrEmpty(img.Uri):
return $"https://{img.Uri.Replace("%%", size)}";
case YCoverPic pic when !string.IsNullOrEmpty(pic.Uri):
return $"https://{pic.Uri.Replace("%%", size)}";
default:
return string.Empty;
}
}
}