You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

using System;
using EFLib;
using Model;
namespace DataManagers
{
public class DbDataManager : IDataManager
{
private LolContext Context { get; set; }
public IChampionsManager ChampionsMgr => throw new NotImplementedException();
public ISkinsManager SkinsMgr => throw new NotImplementedException();
public IRunesManager RunesMgr => throw new NotImplementedException();
public IRunePagesManager RunePagesMgr => throw new NotImplementedException();
public DbDataManager(LolContext context)
{
Context = context;
}
public async Task<int> GetNumbersOfElement()
{
return await Task.Run(() => Context.Champions.Count());
}
public async Task<Champion> GetById(int id)
{
return await Task.Run(() => Context.Champions.SingleOrDefault((ChampionEntity arg) => arg.Id == id).ToPoco());
}
public async Task<Champion> Add(Champion champ)
{
ChampionEntity entity = champ.ToEntity();
await Context.Champions.AddAsync(entity);
Context.SaveChanges();
return await Task.Run(() => Context.Champions.SingleOrDefault((ChampionEntity arg) => arg.Name == champ.Name && arg.Bio == champ.Bio).ToPoco());
}
public void Dispose()
{
Context.Dispose();
}
}
}