|
|
@ -1,27 +1,63 @@
|
|
|
|
using Model;
|
|
|
|
using EntityFramwork.Factories;
|
|
|
|
using System;
|
|
|
|
using Model;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace EntityFramwork.Manager
|
|
|
|
namespace EntityFramwork.Manager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class ManagerChampion : IChampionsManager
|
|
|
|
public class ManagerChampion : IChampionsManager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public Task<Champion?> AddItem(Champion? item)
|
|
|
|
public Task<Champion?> AddItem(Champion? item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (BDDContext db = new BDDContext())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
db.Champions.Add(item.ChampionModelToEntity());
|
|
|
|
|
|
|
|
db.SaveChanges();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Task.FromResult<Champion?>(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Task.FromResult<Champion?>(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<bool> DeleteItem(Champion? item)
|
|
|
|
public Task<bool> DeleteItem(Champion? item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
if(item == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using (BDDContext db = new BDDContext())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EntityChampions ?entityChamp = db.Champions.Where(e => e.Name == item.Name).FirstOrDefault();
|
|
|
|
|
|
|
|
if ( entityChamp == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
db.Champions.Remove(entityChamp);
|
|
|
|
|
|
|
|
db.SaveChanges();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Task.FromResult(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();
|
|
|
|
IEnumerable<Champion?> items = new List<Champion>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (BDDContext db = new BDDContext())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( descending == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
items = db.Champions.Skip(index).Take(count).OrderBy(e => e.Name).Select(e => e.EntityChampionToModele());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
items = db.Champions.Skip(index).Take(count).OrderByDescending(e => e.Name).Select(e => e.EntityChampionToModele());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Task.FromResult<IEnumerable<Champion?>>(items);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|