feat(repo): IArenaTwoPickRewardRepository + tests
Adds GetRewardsByWinCountAsync and GetMaxWinCountAsync (short-circuits to 0 on empty table). Registers as AddTransient in Program.cs alongside other global catalog repos. 3 NUnit tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Database.Repositories.Globals;
|
||||
|
||||
public class ArenaTwoPickRewardRepository : IArenaTwoPickRewardRepository
|
||||
{
|
||||
private readonly SVSimDbContext _db;
|
||||
public ArenaTwoPickRewardRepository(SVSimDbContext db) => _db = db;
|
||||
|
||||
public async Task<List<ArenaTwoPickReward>> GetRewardsByWinCountAsync(int winCount) =>
|
||||
await _db.ArenaTwoPickRewards
|
||||
.Where(r => r.WinCount == winCount)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<int> GetMaxWinCountAsync()
|
||||
{
|
||||
if (!await _db.ArenaTwoPickRewards.AnyAsync()) return 0;
|
||||
return await _db.ArenaTwoPickRewards.MaxAsync(r => r.WinCount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Database.Repositories.Globals;
|
||||
|
||||
public interface IArenaTwoPickRewardRepository
|
||||
{
|
||||
Task<List<ArenaTwoPickReward>> GetRewardsByWinCountAsync(int winCount);
|
||||
Task<int> GetMaxWinCountAsync();
|
||||
}
|
||||
Reference in New Issue
Block a user