push Migration (enfin)

Louison
Louison PARANT 2 years ago
parent b2d5c62ae4
commit 70ce74cb28

@ -7,7 +7,20 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup>
</Project>

@ -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/<ChampionController>
[HttpGet]
public async Task<IActionResult> Get()
{
var champions = await dataManager.GetItems(0, await dataManager.GetNbItems());
return Ok(new { result = champions.Select(c => c.ToDto())});
}
// GET api/<ChampionController>/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/<ChampionController>
[HttpPost]
public void Post([FromBody] ChampionDTO championDTO)
{
}
// PUT api/<ChampionController>/5
[HttpPut("{name}")]
public void Put(string name, [FromBody] ChampionDTO championDTO)
{
}
// DELETE api/<ChampionController>/5
[HttpDelete("{name}")]
public void Delete(string name)
{
}
}
}
/*
var champion = new Champion("");
var dto = ChampionMapper.ToDto(champion);
*/

@ -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,
};
}
}
}

@ -0,0 +1,7 @@
namespace DTO
{
public class ChampionDTO
{
public string Name { get; set; }
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
</ItemGroup>
</Project>

@ -0,0 +1,12 @@
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL
{
class ChampionContext : DbContext
{
public DbSet<ChampionEntity> Champions { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

@ -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; }
}
}

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

@ -0,0 +1,42 @@
// <auto-generated />
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
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLOL.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
/// <inheritdoc />
public partial class MigrationWallah : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Champions", x => x.Name);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Champions");
}
}
}

@ -0,0 +1,39 @@
// <auto-generated />
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<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

@ -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

@ -12,6 +12,15 @@
<ItemGroup>
<Folder Include="enums\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>

@ -6,4 +6,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
</ItemGroup>
</Project>

@ -6,6 +6,16 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>

@ -15,6 +15,13 @@
<None Remove="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</ItemGroup>
</Project>

Loading…
Cancel
Save