|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
@ -13,14 +14,16 @@ namespace TrucAuMilieu
|
|
|
|
|
public ChampionContext contextCh = new ChampionContext();
|
|
|
|
|
public class ChampionsManager : IChampionsManager
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private readonly DataBdd parent;
|
|
|
|
|
public ChampionsManager(DataBdd parent)
|
|
|
|
|
=> this.parent = parent;
|
|
|
|
|
public async Task<Champion?> AddItem (Champion? item)
|
|
|
|
|
{// ya comme une erreur le truc n'est pas save dans la bdd :(
|
|
|
|
|
await parent.contextCh.AddAsync(item.ChampToEf);
|
|
|
|
|
{
|
|
|
|
|
await parent.contextCh.AddAsync(item.ChampToEf());
|
|
|
|
|
await parent.contextCh.SaveChangesAsync();
|
|
|
|
|
return item; //ou elle est lerreur je vais menerve elle est ou lerreur >:(
|
|
|
|
|
Debug.WriteLine("champion ajouté");
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<bool> DeleteItem(Champion? item)
|
|
|
|
@ -28,17 +31,31 @@ namespace TrucAuMilieu
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)/*
|
|
|
|
|
public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
|
{
|
|
|
|
|
if (descending)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(parent.contextCh.Champs.OrderByDescending(c => typeof(ChampionEntity).GetProperty(orderingPropertyName)).Skip(index * count).Take(count).Select(ce => ce.EfToChamp()));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var hi = parent.contextCh.Champs.OrderBy(c => typeof(ChampionEntity).GetProperty(orderingPropertyName)).Skip(index * count).Take(count).Select(ce => ce.EfToChamp());
|
|
|
|
|
return Task.FromResult(hi); //ya une petite betise ça marche pas trop menfin bref c'est a corriger
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
=> parent.contextCh.Champs.Take(count).Skip(index). /*
|
|
|
|
|
=> parent.contextCh..GetItemsWithFilterAndOrdering(
|
|
|
|
|
c => true,
|
|
|
|
|
index, count,
|
|
|
|
|
orderingPropertyName, descending);*/
|
|
|
|
|
{// hihihi les arguments servent à rien pour l'instant y'a zero arguments utilises oupsi :3
|
|
|
|
|
orderingPropertyName, descending);
|
|
|
|
|
{// hihihi les arguments servent à rien pour l'instant y'a zero arguments utilises oupsi
|
|
|
|
|
List<ChampionEntity> lch = parent.contextCh.Champs.Take(count).Skip(index).ToList();
|
|
|
|
|
List<Champion> items = new List<Champion>();
|
|
|
|
|
foreach (var c in lch) { items.Add(c.EfToChamp()); }
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
|
{
|
|
|
|
@ -70,10 +87,7 @@ namespace TrucAuMilieu
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItems()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
public Task<int> GetNbItems() => Task.FromResult(parent.contextCh.Champs.Count());
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByCharacteristic(string charName)
|
|
|
|
|
{
|
|
|
|
|