|
|
@ -1,6 +1,6 @@
|
|
|
|
using EFlib;
|
|
|
|
using EFlib;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using System.Linq;
|
|
|
|
using Model;
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
|
|
|
|
namespace EFManager
|
|
|
|
namespace EFManager
|
|
|
@ -19,101 +19,44 @@ namespace EFManager
|
|
|
|
return item;
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<bool> DeleteItem(Champion? item)
|
|
|
|
public async Task<bool> DeleteItem(Champion? item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (item == null)
|
|
|
|
if (item == null)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
await context.Remove(item.toEF());
|
|
|
|
context.Remove(item.toEF());
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
public Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IQueryable<Champion> query = Champions.Skip(index).Take(count);
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(orderingPropertyName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = descending ?
|
|
|
|
|
|
|
|
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
|
|
|
|
|
|
|
|
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await query.ToListAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IQueryable<Champion> query = Champions
|
|
|
|
throw new NotImplementedException();
|
|
|
|
.Where(c => c.Characteristics.ContainsKey(charName))
|
|
|
|
|
|
|
|
.Skip(index)
|
|
|
|
|
|
|
|
.Take(count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(orderingPropertyName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = descending ?
|
|
|
|
|
|
|
|
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
|
|
|
|
|
|
|
|
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await query.ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IQueryable<Champion> query = Champions
|
|
|
|
throw new NotImplementedException();
|
|
|
|
.Where(c => c.Class == championClass)
|
|
|
|
|
|
|
|
.Skip(index)
|
|
|
|
|
|
|
|
.Take(count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(orderingPropertyName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = descending ?
|
|
|
|
|
|
|
|
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
|
|
|
|
|
|
|
|
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await query.ToListAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IQueryable<Champion> query = Champions
|
|
|
|
throw new NotImplementedException();
|
|
|
|
.Where(c => c.Name.Contains(substring))
|
|
|
|
|
|
|
|
.Skip(index)
|
|
|
|
|
|
|
|
.Take(count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(orderingPropertyName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = descending ?
|
|
|
|
|
|
|
|
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
|
|
|
|
|
|
|
|
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await query.ToListAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IQueryable<Champion> query = Champions;
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
|
|
if (runePage != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = query.Where(c => c.RunePageId == runePage.Id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = query.Skip(index).Take(count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(orderingPropertyName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = descending ?
|
|
|
|
|
|
|
|
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
|
|
|
|
|
|
|
|
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await query.ToListAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
@ -131,9 +74,9 @@ namespace EFManager
|
|
|
|
throw new NotImplementedException();
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByCharacteristic(string charName)
|
|
|
|
public async Task<int> GetNbItemsByCharacteristic(string charName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return await context.Where(c => c.Characteristics.Any(ch => ch.Name == charName)).CountAsync();
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByClass(ChampionClass championClass)
|
|
|
|
public Task<int> GetNbItemsByClass(ChampionClass championClass)
|
|
|
|