diff --git a/Sources/Data/Data.csproj b/Sources/Data/Data.csproj index ac52241..749750b 100644 --- a/Sources/Data/Data.csproj +++ b/Sources/Data/Data.csproj @@ -1,13 +1,20 @@ + + net6.0 + enable + enable + $(MSBuildProjectDirectory) + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - net6.0 - enable - enable - - - - - - + + + diff --git a/Sources/Data/EF/Players/PlayerDBContext.cs b/Sources/Data/EF/Players/PlayerDBContext.cs new file mode 100644 index 0000000..228d52a --- /dev/null +++ b/Sources/Data/EF/Players/PlayerDBContext.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Data.EF.Players +{ + internal class PlayerDBContext : DbContext + { + public DbSet PlayersSet { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite("Data Source=EFDice.DiceApp.db"); + } + + } +} diff --git a/Sources/Data/EF/Players/PlayerDBManager.cs b/Sources/Data/EF/Players/PlayerDBManager.cs new file mode 100644 index 0000000..663a725 --- /dev/null +++ b/Sources/Data/EF/Players/PlayerDBManager.cs @@ -0,0 +1,42 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Data.EF.Players +{ + internal class PlayerDBManager : IManager + { + PlayerDBContext context = new PlayerDBContext(); + + public PlayerEntity Add(PlayerEntity toAdd) + { + // just to check... + + context.PlayersSet.Add(toAdd); + throw new NotImplementedException(); + } + + public IEnumerable GetAll() + { + throw new NotImplementedException(); + } + + public PlayerEntity GetOneByName(string name) + { + throw new NotImplementedException(); + } + + public void Remove(PlayerEntity toRemove) + { + throw new NotImplementedException(); + } + + public PlayerEntity Update(PlayerEntity before, PlayerEntity after) + { + throw new NotImplementedException(); + } + } +} diff --git a/Sources/Data/EF/Players/PlayerEntity.cs b/Sources/Data/EF/Players/PlayerEntity.cs new file mode 100644 index 0000000..2e178e7 --- /dev/null +++ b/Sources/Data/EF/Players/PlayerEntity.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Data.EF.Players +{ + internal class PlayerEntity + { + public Guid ID { get; set; } + public string Name { get; set; } + } +} diff --git a/Sources/Data/EF/Players/PlayerExtensions.cs b/Sources/Data/EF/Players/PlayerExtensions.cs new file mode 100644 index 0000000..9aa0441 --- /dev/null +++ b/Sources/Data/EF/Players/PlayerExtensions.cs @@ -0,0 +1,27 @@ +using Model.Players; + +namespace Data.EF.Players +{ + internal static class PlayerExtensions + { + public static Player ToModel(this PlayerEntity entity) + { + return new Player(name: entity.Name); + } + + public static IEnumerable ToModels(this IEnumerable entities) + { + return entities.Select(entity => entity.ToModel()); + } + + public static PlayerEntity ToEntity(this Player model) + { + return new PlayerEntity() { Name = model.Name }; + } + + public static IEnumerable ToEntities(this IEnumerable models) + { + return models.Select(model => model.ToEntity()); + } + } +}