Update Manager
continuous-integration/drone/push Build is failing Details

pull/10/head^2
Louwar 2 years ago
parent 0fc57a3bcb
commit 1371e86c20

@ -1,4 +1,5 @@
using EFlib; using EFlib;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using Model; using Model;
@ -10,39 +11,109 @@ namespace EFManager
public async Task<Champion?> AddItem(Champion? item) public async Task<Champion?> AddItem(Champion? item)
{ {
//await context.AddAsync(item.); TO DO if (item == null)
return null;
await context.AddAsync(item.toEF());
await context.SaveChangesAsync(); await context.SaveChangesAsync();
return item; return item;
} }
public Task<bool> DeleteItem(Champion? item) public Task<bool> DeleteItem(Champion? item)
{ {
throw new NotImplementedException(); if (item == null)
return false;
context.Remove(item.toEF());
await context.SaveChangesAsync();
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)
{ {
throw new NotImplementedException(); IQueryable<Champion> query = Champions.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?>> 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)
{ {
throw new NotImplementedException(); IQueryable<Champion> query = Champions
.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)
{ {
throw new NotImplementedException(); IQueryable<Champion> query = Champions
.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)
{ {
throw new NotImplementedException(); IQueryable<Champion> query = Champions
.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)
{ {
throw new NotImplementedException(); IQueryable<Champion> query = Champions;
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)
@ -62,7 +133,7 @@ namespace EFManager
public Task<int> GetNbItemsByCharacteristic(string charName) public Task<int> GetNbItemsByCharacteristic(string charName)
{ {
throw new NotImplementedException(); return await context.Where(c => c.Characteristics.Any(ch => ch.Name == charName)).CountAsync();
} }
public Task<int> GetNbItemsByClass(ChampionClass championClass) public Task<int> GetNbItemsByClass(ChampionClass championClass)

Loading…
Cancel
Save