Aggregate (Config + SlotRates + CardWeights) and a single-pack getter loaded as one unit per /pack/open. PackOpenService consumes the aggregate; tests use the production seed (fixture overlay) to validate shape. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
31 lines
884 B
C#
31 lines
884 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace SVSim.Database.Repositories.PackDrawTables;
|
|
|
|
public class PackDrawTableRepository : IPackDrawTableRepository
|
|
{
|
|
private readonly SVSimDbContext _db;
|
|
public PackDrawTableRepository(SVSimDbContext db) { _db = db; }
|
|
|
|
public async Task<PackDrawTable?> GetAsync(int packId)
|
|
{
|
|
var config = await _db.PackDrawConfigs.FirstOrDefaultAsync(c => c.Id == packId);
|
|
if (config is null) return null;
|
|
|
|
var slotRates = await _db.PackDrawSlotRates
|
|
.Where(s => s.PackId == packId)
|
|
.ToListAsync();
|
|
|
|
var cardWeights = await _db.PackDrawCardWeights
|
|
.Where(w => w.PackId == packId)
|
|
.ToListAsync();
|
|
|
|
return new PackDrawTable
|
|
{
|
|
Config = config,
|
|
SlotRates = slotRates,
|
|
CardWeights = cardWeights,
|
|
};
|
|
}
|
|
}
|