| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using Application.Abstractions.Data;
- using Application.Abstractions.Messaging;
- using Domain.Entities.Members;
- using Microsoft.EntityFrameworkCore;
- namespace Application.Features.Api.TrackRecord.GetTrackRecord;
- internal sealed class Handler(IAppDbContext db) : IQueryHandler<Query, Response>
- {
- public async Task<Response> Handle(Query request, CancellationToken ct)
- {
- var sid = request.SID?.Trim() ?? string.Empty;
- var row = await db.MemberTrackRecord.AsNoTracking()
- .Where(c => c.Member.SID == sid)
- .Select(c => new
- {
- c.Tier,
- c.HitRate,
- c.Predictions,
- c.Hits,
- c.Misses,
- c.Voids,
- c.CurrentStreak,
- c.BestStreak
- })
- .FirstOrDefaultAsync(ct);
- if (row is null)
- {
- return new Response { SID = sid, HasRecord = false };
- }
- return new Response
- {
- SID = sid,
- HasRecord = true,
- Tier = row.Tier.ToString(),
- TierCode = (byte)row.Tier,
- HitRate = row.HitRate,
- Predictions = row.Predictions,
- Hits = row.Hits,
- Misses = row.Misses,
- Voids = row.Voids,
- CurrentStreak = row.CurrentStreak,
- BestStreak = row.BestStreak
- };
- }
- }
|