Lots of data and model setup
This commit is contained in:
36
SVSim.Database/Repositories/Globals/GlobalsRepository.cs
Normal file
36
SVSim.Database/Repositories/Globals/GlobalsRepository.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Database.Repositories.Globals;
|
||||
|
||||
public class GlobalsRepository : IGlobalsRepository
|
||||
{
|
||||
private readonly SVSimDbContext _dbContext;
|
||||
|
||||
public GlobalsRepository(SVSimDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<ClassExpEntry>> GetClassExpCurve()
|
||||
{
|
||||
return await _dbContext.Set<ClassExpEntry>().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<BattlefieldEntry>> GetBattlefields(bool onlyOpen)
|
||||
{
|
||||
return await _dbContext.Set<BattlefieldEntry>().Where(bf => !onlyOpen || bf.IsOpen).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<GameConfiguration> GetGameConfiguration(string key)
|
||||
{
|
||||
return await _dbContext.Set<GameConfiguration>().Include(gc => gc.DefaultMyPageBackground)
|
||||
.Include(gc => gc.DefaultEmblem).Include(gc => gc.DefaultDegree).Include(gc => gc.DefaultSleeve).FirstOrDefaultAsync(gc => gc.Id == key) ??
|
||||
new GameConfiguration();
|
||||
}
|
||||
|
||||
public async Task<List<RankInfoEntry>> GetRankInfo()
|
||||
{
|
||||
return await _dbContext.Set<RankInfoEntry>().ToListAsync();
|
||||
}
|
||||
}
|
||||
11
SVSim.Database/Repositories/Globals/IGlobalsRepository.cs
Normal file
11
SVSim.Database/Repositories/Globals/IGlobalsRepository.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Database.Repositories.Globals;
|
||||
|
||||
public interface IGlobalsRepository
|
||||
{
|
||||
Task<List<ClassExpEntry>> GetClassExpCurve();
|
||||
Task<List<BattlefieldEntry>> GetBattlefields(bool onlyOpen);
|
||||
Task<GameConfiguration> GetGameConfiguration(string key);
|
||||
Task<List<RankInfoEntry>> GetRankInfo();
|
||||
}
|
||||
Reference in New Issue
Block a user