1
0
mirror of synced 2024-12-23 19:44:51 +01:00
GC-local-server-rewrite/Application/Game/Card/Read/ReadMusicQuery.cs

32 lines
1.1 KiB
C#
Raw Normal View History

using System.Diagnostics.CodeAnalysis;
namespace Application.Game.Card.Read;
public record ReadMusicQuery(long CardId) : IRequestWrapper<string>;
2023-02-16 17:38:01 +01:00
public class ReadMusicQueryHandler : RequestHandlerBase<ReadMusicQuery, string>
{
private const string MUSIC_XPATH = "/root/music/record";
public ReadMusicQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate)
{
}
[SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records",
Justification = "To return all musics, the whole table need to be returned")]
public override async Task<ServiceResult<string>> Handle(ReadMusicQuery request, CancellationToken cancellationToken)
{
var musics = await MusicDbContext.MusicUnlocks.ToListAsync(cancellationToken: cancellationToken);
var dtoList = musics.Select((unlock, i) =>
{
var dto = unlock.MusicToDto();
dto.Id = i;
return dto;
});
var result = dtoList.SerializeCardDataList(MUSIC_XPATH);
return new ServiceResult<string>(result);
}
}