diff --git a/Sources/EF_UT/EFDataManagerChampionTest.cs b/Sources/EF_UT/EFDataManagerChampionTest.cs new file mode 100644 index 0000000..843a4e5 --- /dev/null +++ b/Sources/EF_UT/EFDataManagerChampionTest.cs @@ -0,0 +1,26 @@ +using EntityFramework; +using EntityFramework.Manager; +using FluentAssertions; +using Microsoft.EntityFrameworkCore; +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EF_UT +{ + [TestClass] + public class EFDataManagerChampionTest + { + [TestMethod] + public void Add_ValidChampion_Added() + { + IDataManager dataManager = new EFDataManager(); + IChampionsManager championsManager = dataManager.ChampionsMgr; + + var champ = championsManager.AddItem(new Champion("test")); + } + } +} diff --git a/Sources/EntityFramework/EntityFramework.csproj b/Sources/EntityFramework/EntityFramework.csproj index 2d1f7fc..358fe36 100644 --- a/Sources/EntityFramework/EntityFramework.csproj +++ b/Sources/EntityFramework/EntityFramework.csproj @@ -1,4 +1,4 @@ - + Exe @@ -8,6 +8,14 @@ $(MSBuildProjectDirectory) + + + + + + + + @@ -18,6 +26,7 @@ + diff --git a/Sources/EntityFramework/Manager/EFDataManager.Champions.cs b/Sources/EntityFramework/Manager/EFDataManager.Champions.cs new file mode 100644 index 0000000..8dd70b4 --- /dev/null +++ b/Sources/EntityFramework/Manager/EFDataManager.Champions.cs @@ -0,0 +1,124 @@ +using EntityFramework.Mapper; +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace EntityFramework.Manager +{ + public partial class EFDataManager + { + public class ChampionsManager : IChampionsManager + { + private readonly EFDataManager parent; + + public ChampionsManager(EFDataManager parent) + { + this.parent = parent; + } + + public async Task AddItem(Champion? item) + { + using(var context = new LoLDBContextWithStub()) + { + if (item != null) + { + context.Add(item.ToEntity()); + return item; + } + else + { + throw new Exception(); + } + } + } + + public Task DeleteItem(Champion? item) + { + throw new NotImplementedException(); + } + + public Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByClass(Model.ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + using (var context = new LoLDBContextWithStub()) + { + IEnumerable champ = context.Champions.Where(c => c.Name.Contains(substring)); + return champ. + } + } + + public Task> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task GetNbItems() + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByCharacteristic(string charName) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByClass(Model.ChampionClass championClass) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByName(string substring) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByRunePage(RunePage? runePage) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsBySkill(Skill? skill) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsBySkill(string skill) + { + throw new NotImplementedException(); + } + + public Task UpdateItem(Champion? oldItem, Champion? newItem) + { + throw new NotImplementedException(); + } + } + } +} diff --git a/Sources/EntityFramework/Manager/EFDataManager.cs b/Sources/EntityFramework/Manager/EFDataManager.cs new file mode 100644 index 0000000..9465809 --- /dev/null +++ b/Sources/EntityFramework/Manager/EFDataManager.cs @@ -0,0 +1,24 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFramework.Manager +{ + public partial class EFDataManager : IDataManager + { + public EFDataManager() { + ChampionsMgr = new ChampionsManager(this); + } + public IChampionsManager ChampionsMgr { get; } + + public ISkinsManager SkinsMgr { get; } + + public IRunesManager RunesMgr { get; } + + public IRunePagesManager RunePagesMgr { get; } + + } +} diff --git a/Sources/EntityFramework/Mapper/ChampionMapper.cs b/Sources/EntityFramework/Mapper/ChampionMapper.cs index 862264d..09b48c3 100644 --- a/Sources/EntityFramework/Mapper/ChampionMapper.cs +++ b/Sources/EntityFramework/Mapper/ChampionMapper.cs @@ -12,5 +12,6 @@ namespace EntityFramework.Mapper public static ChampionEntity ToEntity(this Champion champion) { return new ChampionEntity(champion.Name, champion.Bio, champion.Icon); } + } } diff --git a/Sources/EntityFramework/champion.db-shm b/Sources/EntityFramework/champion.db-shm new file mode 100644 index 0000000..fe9ac28 Binary files /dev/null and b/Sources/EntityFramework/champion.db-shm differ diff --git a/Sources/EntityFramework/champion.db-wal b/Sources/EntityFramework/champion.db-wal new file mode 100644 index 0000000..e69de29