|
|
|
@ -33,7 +33,7 @@ namespace EFManager
|
|
|
|
|
var toDelete = parent.DbContext.Champions.Find(item.Name);
|
|
|
|
|
if (toDelete != null)
|
|
|
|
|
{
|
|
|
|
|
parent.DbContext.Champions.Remove(item.toEF(parent.DbContext));
|
|
|
|
|
parent.DbContext.Champions.Remove(toDelete);
|
|
|
|
|
parent.DbContext.SaveChangesAsync();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -51,30 +51,16 @@ namespace EFManager
|
|
|
|
|
{
|
|
|
|
|
if (descending)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(parent.DbContext.Champions.OrderByDescending(
|
|
|
|
|
c => typeof(EFChampion).GetProperty(orderingPropertyName))
|
|
|
|
|
.Skip(index * count)
|
|
|
|
|
.Take(count)
|
|
|
|
|
.Select(ce => ce.toModel())
|
|
|
|
|
);
|
|
|
|
|
return await Task.FromResult(parent.DbContext.Champions.OrderByDescending(champ => typeof(EFChampion).GetProperty(orderingPropertyName)).Skip(index * count).Take(count).Select(efChampion => efChampion.toModel()));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(parent.DbContext.Champions.OrderBy(
|
|
|
|
|
c => typeof(EFChampion).GetProperty(orderingPropertyName))
|
|
|
|
|
.Skip(index * count)
|
|
|
|
|
.Take(count)
|
|
|
|
|
.Select(ce => ce.toModel())
|
|
|
|
|
);
|
|
|
|
|
return await Task.FromResult(parent.DbContext.Champions.OrderBy(champ => typeof(EFChampion).GetProperty(orderingPropertyName)).Skip(index * count).Take(count).Select(efChampion => efChampion.toModel()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(parent.DbContext.Champions
|
|
|
|
|
.Skip(index * count)
|
|
|
|
|
.Take(count)
|
|
|
|
|
.Select(ce => ce.toModel())
|
|
|
|
|
);
|
|
|
|
|
return await Task.FromResult(parent.DbContext.Champions.Skip(index * count).Take(count).Select(efChampion => efChampion.toModel()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -90,11 +76,26 @@ namespace EFManager
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
|
public async Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var EfChampion = from champ in parent.DbContext.Champions where champ.Name.Contains(substring) select champ;
|
|
|
|
|
if (orderingPropertyName != null)
|
|
|
|
|
{
|
|
|
|
|
if (descending)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(EfChampion.OrderByDescending(champ => typeof(EFChampion).GetProperty(orderingPropertyName)).Skip(index * count).Take(count).Select(efChampion => efChampion.toModel()));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(EfChampion.OrderBy(champ => typeof(EFChampion).GetProperty(orderingPropertyName)).Skip(index * count).Take(count).Select(efChampion => efChampion.toModel()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(EfChampion.Skip(index * count).Take(count).Select(efChampion => efChampion.toModel()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
|
|
|
{
|
|
|
|
@ -122,12 +123,12 @@ namespace EFManager
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByClass(ChampionClass championClass)
|
|
|
|
|
public async Task<int> GetNbItemsByClass(ChampionClass championClass)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsByName(string substring)
|
|
|
|
|
public async Task<int> GetNbItemsByName(string substring)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
@ -137,24 +138,25 @@ namespace EFManager
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> GetNbItemsBySkill(Skill? skill)
|
|
|
|
|
public async Task<int> GetNbItemsBySkill(Skill? skill)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<int> GetNbItemsBySkill(string skill)
|
|
|
|
|
{
|
|
|
|
|
return parent.DbContext.Champions.Where(champ => skill != null && champ.Skills.Any(Skill => Skill.Name.Equals(skill)))
|
|
|
|
|
.Count();
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<Champion?> UpdateItem(Champion? oldItem, Champion? newItem)
|
|
|
|
|
{
|
|
|
|
|
var toUpdate = parent.DbContext.Champions.Find(oldItem.Name);
|
|
|
|
|
|
|
|
|
|
toUpdate = newItem.toEF();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
toUpdate = newItem.toEF(parent.DbContext);
|
|
|
|
|
parent.DbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch(DbUpdateException) { }
|
|
|
|
|
return newItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|