|
|
|
@ -0,0 +1,132 @@
|
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace EFLol.DBDataManager
|
|
|
|
|
{
|
|
|
|
|
public class EFDataManager : IDataManager
|
|
|
|
|
{
|
|
|
|
|
public IChampionsManager ChampionsMgr => new EFChampionManager();
|
|
|
|
|
|
|
|
|
|
public ISkinsManager SkinsMgr => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
public IRunesManager RunesMgr => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
public IRunePagesManager RunePagesMgr => throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class EFChampionManager : IChampionsManager
|
|
|
|
|
{
|
|
|
|
|
private MyDbContext _context;
|
|
|
|
|
|
|
|
|
|
public async Task<Champion?> AddItem(Champion? item)
|
|
|
|
|
{
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
var addItem = await _context.AddAsync(item);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
return addItem.Entity;
|
|
|
|
|
|
|
|
|
|
// Va chercher les info du context (Context.champions.get)(DbSet) et les map en champion model
|
|
|
|
|
// Dans Program.cs de API rajouter un scope (AddScope <IDataManager, EFDataManager>) -> Ca va dire que a chaque fois que j'utilise un IDataManager, il va créer un EFDataManager
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> DeleteItem(Champion? item)
|
|
|
|
|
{
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
var deletedItem = _context.Remove(item);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Func<Champion, string, bool> filterByName = (champion, substring) =>
|
|
|
|
|
champion.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Task<Champion?> UpdateItem(Champion? oldItem, Champion? newItem)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItems()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool @descending = false)
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<Champion> champions = _context.Champions.Skip(index * count).Take(count).OrderBy(champion => orderingPropertyName).Select(champion => champion.ChampionToPoco());
|
|
|
|
|
return champions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByName(string substring)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null,
|
|
|
|
|
bool @descending = false)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByCharacteristic(string charName)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null,
|
|
|
|
|
bool @descending = false)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByClass(ChampionClass championClass)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null,
|
|
|
|
|
bool @descending = false)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsBySkill(Skill? skill)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool @descending = false)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByRunePage(RunePage? runePage)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null,
|
|
|
|
|
bool @descending = false)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsBySkill(string skill)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool @descending = false)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|