#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Application.Common.DTO.Pagination;
using Lumina.Contracts.Responses.Common;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
///
/// Extension methods for converting .
///
public static class BookLiteRowMapping
{
///
/// Converts to .
///
/// The read model to be converted.
/// The converted response.
public static BookLiteResponse ToResponse(this BookLiteRow readModel)
{
return new BookLiteResponse(
readModel.Id,
readModel.Title,
readModel.ReleaseYear,
readModel.CoverPath);
}
///
/// Converts to a collection of .
///
/// The read models to be converted.
/// The converted responses.
public static IReadOnlyList ToResponses(this IEnumerable readModels)
{
return [.. readModels.Select(readModel => readModel.ToResponse())];
}
///
/// Converts to a paginated collection of .
///
/// The paginated read models to be converted.
/// The converted paginated responses.
public static PaginatedResponse ToResponses(this PaginatedResultDto readModels)
{
return new PaginatedResponse
{
Data = readModels.Data.ToResponses(),
CurrentPage = readModels.CurrentPage,
PerPage = readModels.PerPage,
Count = readModels.Count,
NumberOfPages = readModels.NumberOfPages
};
}
}