From 70ce74cb282f307b40dbc3b6690800d9c940f5b5 Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Wed, 1 Feb 2023 17:34:54 +0100 Subject: [PATCH] push Migration (enfin) --- Sources/APILOL/APILOL.csproj | 13 ++++ .../APILOL/Controllers/ChampionsController.cs | 59 ++++++++++++++++++ Sources/APILOL/Mapper/ChampionMapper.cs | 16 +++++ Sources/DTO/ChampionDTO.cs | 7 +++ Sources/DTO/DTO.csproj | 19 ++++++ Sources/EntityFrameworkLOL/ChampionContext.cs | 12 ++++ Sources/EntityFrameworkLOL/ChampionEntity.cs | 20 ++++++ Sources/EntityFrameworkLOL/DBLOL.db | Bin 0 -> 20480 bytes .../EntityFrameworkLOL.DBLOL.db | Bin 0 -> 20480 bytes .../EntityFrameworkLOL.csproj | 23 +++++++ ...20230201163336_MigrationWallah.Designer.cs | 42 +++++++++++++ .../20230201163336_MigrationWallah.cs | 34 ++++++++++ .../ChampionContextModelSnapshot.cs | 39 ++++++++++++ Sources/EntityFrameworkLOL/Program.cs | 2 + Sources/LeagueOfLegends.sln | 14 ++++- Sources/Model/Model.csproj | 9 +++ Sources/Shared/Shared.csproj | 10 +++ Sources/StubLib/StubLib.csproj | 10 +++ .../Tests/ConsoleTests/ConsoleTests.csproj | 7 +++ 19 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 Sources/APILOL/Controllers/ChampionsController.cs create mode 100644 Sources/APILOL/Mapper/ChampionMapper.cs create mode 100644 Sources/DTO/ChampionDTO.cs create mode 100644 Sources/DTO/DTO.csproj create mode 100644 Sources/EntityFrameworkLOL/ChampionContext.cs create mode 100644 Sources/EntityFrameworkLOL/ChampionEntity.cs create mode 100644 Sources/EntityFrameworkLOL/DBLOL.db create mode 100644 Sources/EntityFrameworkLOL/EntityFrameworkLOL.DBLOL.db create mode 100644 Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.Designer.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/ChampionContextModelSnapshot.cs create mode 100644 Sources/EntityFrameworkLOL/Program.cs diff --git a/Sources/APILOL/APILOL.csproj b/Sources/APILOL/APILOL.csproj index 60bf9ea..2ac89b4 100644 --- a/Sources/APILOL/APILOL.csproj +++ b/Sources/APILOL/APILOL.csproj @@ -7,7 +7,20 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/Sources/APILOL/Controllers/ChampionsController.cs b/Sources/APILOL/Controllers/ChampionsController.cs new file mode 100644 index 0000000..c5d795c --- /dev/null +++ b/Sources/APILOL/Controllers/ChampionsController.cs @@ -0,0 +1,59 @@ +using APILOL.Mapper; +using DTO; +using Microsoft.AspNetCore.Mvc; +using Model; +using StubLib; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace APILOL.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ChampionsController : ControllerBase + { + IChampionsManager dataManager = new StubData().ChampionsMgr; + + // GET: api/ + [HttpGet] + public async Task Get() + { + var champions = await dataManager.GetItems(0, await dataManager.GetNbItems()); + return Ok(new { result = champions.Select(c => c.ToDto())}); + } + + // GET api//5 + [HttpGet("{name}")] + public IActionResult Get(string name) + { + if (dataManager.GetNbItemsByName(name) != null) + { + return Ok(dataManager.GetItemsByName(name, 0, dataManager.GetNbItemsByName(name))); + } + return NotFound(); + } + + // POST api/ + [HttpPost] + public void Post([FromBody] ChampionDTO championDTO) + { + } + + // PUT api//5 + [HttpPut("{name}")] + public void Put(string name, [FromBody] ChampionDTO championDTO) + { + } + + // DELETE api//5 + [HttpDelete("{name}")] + public void Delete(string name) + { + } + } +} + +/* +var champion = new Champion(""); +var dto = ChampionMapper.ToDto(champion); +*/ \ No newline at end of file diff --git a/Sources/APILOL/Mapper/ChampionMapper.cs b/Sources/APILOL/Mapper/ChampionMapper.cs new file mode 100644 index 0000000..33bde68 --- /dev/null +++ b/Sources/APILOL/Mapper/ChampionMapper.cs @@ -0,0 +1,16 @@ +using DTO; +using Model; + +namespace APILOL.Mapper +{ + public static class ChampionMapper + { + public static ChampionDTO ToDto(this Champion champion) + { + return new ChampionDTO() + { + Name = champion.Name, + }; + } + } +} diff --git a/Sources/DTO/ChampionDTO.cs b/Sources/DTO/ChampionDTO.cs new file mode 100644 index 0000000..5ef392e --- /dev/null +++ b/Sources/DTO/ChampionDTO.cs @@ -0,0 +1,7 @@ +namespace DTO +{ + public class ChampionDTO + { + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Sources/DTO/DTO.csproj b/Sources/DTO/DTO.csproj new file mode 100644 index 0000000..94a926e --- /dev/null +++ b/Sources/DTO/DTO.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/Sources/EntityFrameworkLOL/ChampionContext.cs b/Sources/EntityFrameworkLOL/ChampionContext.cs new file mode 100644 index 0000000..719926b --- /dev/null +++ b/Sources/EntityFrameworkLOL/ChampionContext.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace EntityFrameworkLOL +{ + class ChampionContext : DbContext + { + public DbSet Champions { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => options.UseSqlite($"Data Source=DBLOL.db"); + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/ChampionEntity.cs b/Sources/EntityFrameworkLOL/ChampionEntity.cs new file mode 100644 index 0000000..f693c37 --- /dev/null +++ b/Sources/EntityFrameworkLOL/ChampionEntity.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; + +namespace EntityFrameworkLOL +{ + class ChampionEntity + { + [Key] + public string Name { get; set; } + + public string Bio { get; set; } + + public string Icon { get; set; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBLOL.db b/Sources/EntityFrameworkLOL/DBLOL.db new file mode 100644 index 0000000000000000000000000000000000000000..6e8e7c513bb882be2ef983154f94548171efa3cd GIT binary patch literal 20480 zcmeI&zi!h&9Ki8&lC}`Z4VxvF93BuzD2ijLSxF-!tfomw4YUKYOk-M0NeqrF!PveC zPr%DCG4TR@0Y=Uhaf{_Jv9$XBe*Zq(ORE28B;)EmD)PrU>=&% za}GT@9I5hpFp&Mx@W7k&+@UAU@t%L zsa4xFoTetC#Wei9{4`U~s(x^m##im@xqK_1cH{g|+cLUc?P7G5rtdp1_M?*|NV8mD zM$0r#zLa)W{!YJipKFSIOm|v1?V`wCC zzW=MA{s{ySKmY**5I_I{1Q0*~0R#}Z!vfj&f1dyE@C7C{1Q0*~0R#|0009ILKmY** Gl)!ImeaBG% literal 0 HcmV?d00001 diff --git a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.DBLOL.db b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.DBLOL.db new file mode 100644 index 0000000000000000000000000000000000000000..e40710c96492a259a9812802b2d7b5b83a14c274 GIT binary patch literal 20480 zcmeI&zi!h&9Ki9jleQ4a4VxvF92pQuD2g44Fp@?_SWT0V8fXV(nZ~7-k{BFUg0X!O zo`9EOV&Vn*0*st1;ugzcVrljL$tT~P?K}TI_ToSLuLe;X%Hueh2dV6cdqUU6b18)o zx+)v0tRibyR}Hn+uGQC7b;w%TF`)tm+4+X?)qfn#;HHX*bRev@NsS)y_wkY5KnNVlVoT1ZkG* z%V?R#$(Pbj{qOWk_qn3T$8@KK(=Ljv8K^{OoW#@9qx4OfEY-;thE*D_zG=SeuG1); z$G1wmE9#EAligK@Dq8)APz!+o0tg_000IagfB*srAb7PIV0R#|0009ILKmY**5I_KdTP%=$|L6Jt7GGdeLjVB;5I_I{1Q0*~0R#|0 HKneT?YZ%8* literal 0 HcmV?d00001 diff --git a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj new file mode 100644 index 0000000..d683ca4 --- /dev/null +++ b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj @@ -0,0 +1,23 @@ + + + + Exe + net6.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.Designer.cs b/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.Designer.cs new file mode 100644 index 0000000..e24c7dc --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.Designer.cs @@ -0,0 +1,42 @@ +// +using EntityFrameworkLOL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + [DbContext(typeof(ChampionContext))] + [Migration("20230201163336_MigrationWallah")] + partial class MigrationWallah + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameworkLOL.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.cs b/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.cs new file mode 100644 index 0000000..eb2dfc8 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + /// + public partial class MigrationWallah : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Champions", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Bio = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Champions", x => x.Name); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Champions"); + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/ChampionContextModelSnapshot.cs b/Sources/EntityFrameworkLOL/Migrations/ChampionContextModelSnapshot.cs new file mode 100644 index 0000000..351bf79 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/ChampionContextModelSnapshot.cs @@ -0,0 +1,39 @@ +// +using EntityFrameworkLOL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + [DbContext(typeof(ChampionContext))] + partial class ChampionContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameworkLOL.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameworkLOL/Program.cs b/Sources/EntityFrameworkLOL/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/Sources/LeagueOfLegends.sln b/Sources/LeagueOfLegends.sln index fe317f6..19c01c7 100644 --- a/Sources/LeagueOfLegends.sln +++ b/Sources/LeagueOfLegends.sln @@ -15,7 +15,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stub", "Stub", "{2C607793-B EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib.csproj", "{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APILOL", "APILOL\APILOL.csproj", "{88538F30-9D26-4A70-88FD-12BA05576E39}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APILOL", "APILOL\APILOL.csproj", "{88538F30-9D26-4A70-88FD-12BA05576E39}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{1434DEF6-0575-4C3D-BF14-AF29A444BC74}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkLOL", "EntityFrameworkLOL\EntityFrameworkLOL.csproj", "{61D807B0-FA1A-439D-9810-9F31A0C47034}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -43,6 +47,14 @@ Global {88538F30-9D26-4A70-88FD-12BA05576E39}.Debug|Any CPU.Build.0 = Debug|Any CPU {88538F30-9D26-4A70-88FD-12BA05576E39}.Release|Any CPU.ActiveCfg = Release|Any CPU {88538F30-9D26-4A70-88FD-12BA05576E39}.Release|Any CPU.Build.0 = Release|Any CPU + {1434DEF6-0575-4C3D-BF14-AF29A444BC74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1434DEF6-0575-4C3D-BF14-AF29A444BC74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1434DEF6-0575-4C3D-BF14-AF29A444BC74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1434DEF6-0575-4C3D-BF14-AF29A444BC74}.Release|Any CPU.Build.0 = Release|Any CPU + {61D807B0-FA1A-439D-9810-9F31A0C47034}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61D807B0-FA1A-439D-9810-9F31A0C47034}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61D807B0-FA1A-439D-9810-9F31A0C47034}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61D807B0-FA1A-439D-9810-9F31A0C47034}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Sources/Model/Model.csproj b/Sources/Model/Model.csproj index 89f6363..4eb62df 100644 --- a/Sources/Model/Model.csproj +++ b/Sources/Model/Model.csproj @@ -12,6 +12,15 @@ + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Sources/Shared/Shared.csproj b/Sources/Shared/Shared.csproj index 132c02c..94a926e 100644 --- a/Sources/Shared/Shared.csproj +++ b/Sources/Shared/Shared.csproj @@ -6,4 +6,14 @@ enable + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/Sources/StubLib/StubLib.csproj b/Sources/StubLib/StubLib.csproj index 1b714b9..a3c6686 100644 --- a/Sources/StubLib/StubLib.csproj +++ b/Sources/StubLib/StubLib.csproj @@ -6,6 +6,16 @@ enable + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/Sources/Tests/ConsoleTests/ConsoleTests.csproj b/Sources/Tests/ConsoleTests/ConsoleTests.csproj index c52655b..c805564 100644 --- a/Sources/Tests/ConsoleTests/ConsoleTests.csproj +++ b/Sources/Tests/ConsoleTests/ConsoleTests.csproj @@ -15,6 +15,13 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + +