Compare commits

...

1 Commits

Author SHA1 Message Date
Maxence LANONE 8f1f3f2863 🚧 ajout dbadatamaneger + manque a implémenter certaines methodes
continuous-integration/drone/push Build is failing Details
2 years ago

@ -0,0 +1,34 @@
using System;
using Model;
namespace DbDataManager
{
public class CaseManager: ICasesManager
{
public Task<Case?> AddItem(Case? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Case? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Case?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<Case?> UpdateItem(Case? oldItem, Case? newItem)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,22 @@
using System;
using Model;
namespace DbDataManager
{
public class DbDataManager : IDataManager
{
public IPlayersManager PlayersMgr => new PlayerManager();
public IGamesManager GamesMgr => new GameManager();
public IGamesModeManager GamesModeMgr => new GameModeManager();
public ICasesManager CasesMgr => new CaseManager();
public IGrillesManager GrillesMgr => new GrilleManager();
public IStatsManager StatsMgr => new StatsManager();
public ITurnsManager TurnsMgr => new TurnManager();
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Sources\Trek12_Lib\EntityFrameWorkLib.csproj" />
<ProjectReference Include="..\Sources\Model\Model.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="Mapper\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Mapper\" />
</ItemGroup>
</Project>

@ -0,0 +1,64 @@
using System;
using Model;
namespace DbDataManager
{
static class ExtensionDataManager
{
internal static Task<IEnumerable<T?>> GetItemsWithFilterAndOrdering<T>(this IEnumerable<T> collection,
Func<T, bool> filter, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
IEnumerable<T> temp = collection;
temp = temp.Where(item => filter(item));
if (orderingPropertyName != null)
{
var prop = typeof(T).GetProperty(orderingPropertyName!);
if (prop != null)
{
temp = descending ? temp.OrderByDescending(item => prop.GetValue(item))
: temp.OrderBy(item => prop.GetValue(item));
}
}
return Task.FromResult<IEnumerable<T?>>(temp.Skip(index * count).Take(count));
}
internal static Task<int> GetNbItemsWithFilter<T>(this IEnumerable<T> collection, Func<T, bool> filter)
{
return Task.FromResult(collection.Count(item => filter(item)));
}
internal static Task<T?> AddItem<T>(this IList<T> collection, T? item)
{
if (item == null || collection.Contains(item))
{
return Task.FromResult<T?>(default(T));
}
collection.Add(item);
return Task.FromResult<T?>(item);
}
internal static Task<bool> DeleteItem<T>(this IList<T> collection, T? item)
{
if (item == null)
{
return Task.FromResult(false);
}
bool result = collection.Remove(item!);
return Task.FromResult(result);
}
internal static Task<T?> UpdateItem<T>(this IList<T> collection, T? oldItem, T? newItem)
{
if (oldItem == null || newItem == null) return Task.FromResult<T?>(default(T));
if (!collection.Contains(oldItem))
{
return Task.FromResult<T?>(default(T));
}
collection.Remove(oldItem!);
collection.Add(newItem!);
return Task.FromResult<T?>(newItem);
}
}
}

@ -0,0 +1,76 @@
using System;
using EntityFrameWorkLib;
using Model;
using System.Linq;
using Shared;
namespace DbDataManager
{
public class GameManager: IGamesManager
{
private TrekContext trekcontext;
public Task<bool> AddCaseValueToPlayer(int idGame, int idPlayer, int value, int index)
{
throw new NotImplementedException();
}
public async Task<Game?> AddItem(Game? item)
{
if (item == null)
{
return null;
}
var addItem = await trekcontext.AddAsync<Game>(item);
await trekcontext.SaveChangesAsync();
return addItem.Entity;
}
public Task<bool> AddPlayer(Player player)
{
throw new NotImplementedException();
}
public Task<bool> AddScoreToPlayer(int idGame, int idPlayer, int score)
{
throw new NotImplementedException();
}
public Task<bool> AddTime(TimeSpan time)
{
var game = trekcontext.Game.FirstOrDefault();
if (game == null)
{
return Task.FromResult(false);
}
game.AddTime(time);
return Task.FromResult(true);
}
public Task<bool> AddTurn(Turn turn)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Game? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Game?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<Game?> UpdateItem(Game? oldItem, Game? newItem)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,34 @@
using System;
using Model;
namespace DbDataManager
{
public class GameModeManager: IGamesModeManager
{
public Task<GameMode?> AddItem(GameMode? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(GameMode? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<GameMode?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<GameMode?> UpdateItem(GameMode? oldItem, GameMode? newItem)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,33 @@
using System;
using Model;
namespace DbDataManager
{
public class GrilleManager: IGrillesManager
{
public Task<Grille?> AddItem(Grille? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Grille? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Grille?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<Grille?> UpdateItem(Grille? oldItem, Grille? newItem)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,11 @@
using System;
namespace DbDataManager.Mapper
{
public class CaseMapper
{
public CaseMapper()
{
}
}
}

@ -0,0 +1,11 @@
using System;
namespace DbDataManager.Mapper
{
public class GameMapper
{
public GameMapper()
{
}
}
}

@ -0,0 +1,11 @@
using System;
namespace DbDataManager.Mapper
{
public class GameModeMapper
{
public GameModeMapper()
{
}
}
}

@ -0,0 +1,11 @@
using System;
namespace DbDataManager.Mapper
{
public class GrilleMapper
{
public GrilleMapper()
{
}
}
}

@ -0,0 +1,14 @@
using System;
using EntityFrameWorkLib;
using Model;
namespace DbDataManager.Mapper
{
public static class PlayerMapper
{
public static Player ToPoco(this PlayerEntity player)
{
return new Player(player.Pseudo, new Stats { player.NbWin, player.NbPlayed, player.MaxChain, player.MaxZone, player.MaxPoints }, player.PlayerId);
}
}
}

@ -0,0 +1,11 @@
using System;
namespace DbDataManager.Mapper
{
public class StatsMapper
{
public StatsMapper()
{
}
}
}

@ -0,0 +1,11 @@
using System;
namespace DbDataManager.Mapper
{
public class TurnMapper
{
public TurnMapper()
{
}
}
}

@ -0,0 +1,78 @@
using System;
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Model;
namespace DbDataManager
{
public class PlayerManager: IPlayersManager
{
private TrekContext trekContext;
public async Task<Player?> AddItem(Player? item)
{
if (item == null)
{
return null;
}
var addItem = await trekContext.AddAsync<Player>(item);
await trekContext.SaveChangesAsync();
return addItem.Entity;
}
public async Task<bool> DeleteItem(Player? item)
{
if (item == null)
{
return false;
}
var deleteItem = trekContext.Remove<Player>(item);
trekContext.SaveChanges();
return true;
}
public async Task<IEnumerable<Player?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
//IEnumerable<Player> players = trekContext.Players.Skip(index * count)
// .Take(count)
// .OrderBy(champions => orderingPropertyName)
// .Select(champions => champions.ToPoco());
//return players;
throw new NotImplementedException();
}
private Func<Player, string, bool> filterByPseudo = (player, substring) => player.Pseudo.Contains(substring, StringComparison.InvariantCultureIgnoreCase);
private Func<Player, int, bool> filterById = (player, id) => player.Id.Equals(id);
public async Task<IEnumerable<Player?>> GetItemsById(int id)
{
//return trekContext.Players.GetItemsWithFilterAndOrdering<Player>(player => filterById(player, id), 0, 1);
throw new NotImplementedException();
}
public Task<IEnumerable<Player?>> GetItemsByPseudo(string charPseudo)
{
//return trekContext.Players.GetItemsWithFilterAndOrdering<Player>(player => filterByPseudo(player, charPseudo), 0, trekContext.Players.Count());
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
return Task.FromResult(trekContext.Players.Count());
}
public Task<int> GetNbItemsByPseudo(string charPseudo)
{
throw new NotImplementedException();
}
public Task<Player?> UpdateItem(Player? oldItem, Player? newItem)
{
//return trekContext.Players.UpdateItem(oldItem, newItem);
throw new NotImplementedException();
}
}
}

@ -0,0 +1,33 @@
using System;
using Model;
namespace DbDataManager
{
public class StatsManager : IStatsManager
{
public Task<Stats?> AddItem(Stats? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Stats? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Stats?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<Stats?> UpdateItem(Stats? oldItem, Stats? newItem)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,33 @@
using System;
using Model;
namespace DbDataManager
{
public class TurnManager : ITurnsManager
{
public Task<Turn?> AddItem(Turn? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Turn? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Turn?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<Turn?> UpdateItem(Turn? oldItem, Turn? newItem)
{
throw new NotImplementedException();
}
}
}

@ -20,11 +20,11 @@
<None Remove="projet.Score.db" /> <None Remove="projet.Score.db" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -9,13 +9,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2"> <PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csp
EndProject EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{7DF17583-2166-4ABE-82EE-F63CEE2132C2}" Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{7DF17583-2166-4ABE-82EE-F63CEE2132C2}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbDataManager", "..\DbDataManager\DbDataManager.csproj", "{BECCFECE-4BFE-49E6-BD8F-5A791180922C}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -61,6 +63,10 @@ Global
{7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Debug|Any CPU.Build.0 = Debug|Any CPU {7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Release|Any CPU.Build.0 = Release|Any CPU {7DF17583-2166-4ABE-82EE-F63CEE2132C2}.Release|Any CPU.Build.0 = Release|Any CPU
{BECCFECE-4BFE-49E6-BD8F-5A791180922C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BECCFECE-4BFE-49E6-BD8F-5A791180922C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BECCFECE-4BFE-49E6-BD8F-5A791180922C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BECCFECE-4BFE-49E6-BD8F-5A791180922C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -13,9 +13,9 @@
<None Remove="Microsoft.EntityFrameworkCore.Tools" /> <None Remove="Microsoft.EntityFrameworkCore.Tools" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

@ -13,6 +13,7 @@ namespace EntityFrameWorkLib
public int NbWin { get; set; } public int NbWin { get; set; }
public int NbPlayed { get; set; } public int NbPlayed { get; set; }
public int MaxZone { get; set; } public int MaxZone { get; set; }
public int MaxChain { get; set; }
public int MaxPoints { get; set; } public int MaxPoints { get; set; }
public int NbPoints { get; set; } public int NbPoints { get; set; }
} }

Loading…
Cancel
Save