I'm an idiot, they store encoded data for towers, we dont need a separate object unless we want to
This commit is contained in:
38
TOOHUCardAPI/Data/Repositories/RankRepository.cs
Normal file
38
TOOHUCardAPI/Data/Repositories/RankRepository.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TOOHUCardAPI.Data.Enums;
|
||||
using TOOHUCardAPI.Data.Models;
|
||||
|
||||
namespace TOOHUCardAPI.Data.Repositories
|
||||
{
|
||||
public class RankRepository
|
||||
{
|
||||
private readonly AppDbContext _appDbContext;
|
||||
private readonly ILogger<RankRepository> _logger;
|
||||
|
||||
public RankRepository(AppDbContext appDbContext, ILogger<RankRepository> logger)
|
||||
{
|
||||
_appDbContext = appDbContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private IQueryable<RankEntry> AllIncluded()
|
||||
{
|
||||
return _appDbContext.RankEntries.Include(i => i.TowersUsed);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RankEntry>> GetRankEntries(RankType rankType)
|
||||
{
|
||||
return await AllIncluded().Where(i => i.RankType == rankType).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task InsertRankEntry(RankEntry entry)
|
||||
{
|
||||
await _appDbContext.RankEntries.AddAsync(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user