using LibEntityFramework; using Model; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TrucAuMilieu { public partial class DataBdd { public ChampionContext contextCh = new ChampionContext(); public class ChampionsManager : IChampionsManager { private readonly DataBdd parent; public ChampionsManager(DataBdd parent) => this.parent = parent; public async Task AddItem (Champion? item) { await parent.contextCh.AddAsync(item.ChampToEf()); await parent.contextCh.SaveChangesAsync(); Debug.WriteLine("champion ajouté"); return item; } public Task DeleteItem(Champion? item) { throw new NotImplementedException(); } public async Task> 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 List lch = parent.contextCh.Champs.Take(count).Skip(index).ToList(); List items = new List(); foreach (var c in lch) { items.Add(c.EfToChamp()); } return items; }*/ public Task> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false) { throw new NotImplementedException(); } public Task> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false) { throw new NotImplementedException(); } public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) { throw new NotImplementedException(); } public Task> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false) { throw new NotImplementedException(); } public Task> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false) { throw new NotImplementedException(); } public Task> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false) { throw new NotImplementedException(); } public Task GetNbItems() => Task.FromResult(parent.contextCh.Champs.Count()); public Task GetNbItemsByCharacteristic(string charName) { throw new NotImplementedException(); } public Task GetNbItemsByClass(ChampionClass championClass) { throw new NotImplementedException(); } public Task GetNbItemsByName(string substring) { throw new NotImplementedException(); } public Task GetNbItemsByRunePage(RunePage? runePage) { throw new NotImplementedException(); } public Task GetNbItemsBySkill(Skill? skill) { throw new NotImplementedException(); } public Task GetNbItemsBySkill(string skill) { throw new NotImplementedException(); } public Task UpdateItem(Champion? oldItem, Champion? newItem) { throw new NotImplementedException(); } } } }