mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Adds favorites and aligns playlist and favorite pagination
This commit is contained in:
1 parent
2e9f7d8496
commit
525ac1348d
193 files changed
+10944
-643
No files matched your search
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.Favorites;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.Favorites;
|
||||
using System;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="FavoriteItemDto"/>.
|
||||
/// </summary>
|
||||
public static class FavoriteItemDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="data"/> to <see cref="FavoriteItemResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="data">The favorite data to be converted.</param>
|
||||
/// <returns>The converted response, flagged as not available with empty display fields when the display data is missing.</returns>
|
||||
public static FavoriteItemResponse ToResponse(this FavoriteItemDto data)
|
||||
{
|
||||
if (data.Display is null)
|
||||
return new FavoriteItemResponse(
|
||||
data.Favorite.MediaKind,
|
||||
data.Favorite.MediaItemId,
|
||||
false,
|
||||
Guid.Empty,
|
||||
string.Empty,
|
||||
Guid.Empty,
|
||||
string.Empty,
|
||||
Guid.Empty,
|
||||
string.Empty,
|
||||
null);
|
||||
|
||||
FavoriteItemDisplayDto display = data.Display;
|
||||
return new FavoriteItemResponse(
|
||||
data.Favorite.MediaKind,
|
||||
data.Favorite.MediaItemId,
|
||||
true,
|
||||
display.LibraryId,
|
||||
display.Title,
|
||||
display.CollectionId,
|
||||
display.CollectionTitle,
|
||||
display.CreatorId,
|
||||
display.CreatorName,
|
||||
display.CoverPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="data"/> to a paginated collection of <see cref="FavoriteItemResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="data">The paginated favorite data to be converted.</param>
|
||||
/// <returns>The converted paginated responses.</returns>
|
||||
public static PaginatedResponse<FavoriteItemResponse> ToResponses(this PaginatedResultDto<FavoriteItemDto> data)
|
||||
{
|
||||
return new PaginatedResponse<FavoriteItemResponse>
|
||||
{
|
||||
Data = [.. data.Data.Select(item => item.ToResponse())],
|
||||
CurrentPage = data.CurrentPage,
|
||||
PerPage = data.PerPage,
|
||||
Count = data.Count,
|
||||
NumberOfPages = data.NumberOfPages
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user