rune
Lucas Delanier 2 years ago
commit 937d6ddefe

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

@ -4,6 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>036530f1-7b72-4f69-a1a3-0b4039b6a80a</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
@ -14,6 +16,7 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

@ -0,0 +1,26 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["APILOL/APILOL.csproj", "APILOL/"]
COPY ["DTO/DTO.csproj", "DTO/"]
COPY ["Model/Model.csproj", "Model/"]
COPY ["Shared/Shared.csproj", "Shared/"]
COPY ["StubLib/StubLib.csproj", "StubLib/"]
RUN dotnet restore "APILOL/APILOL.csproj"
COPY . .
WORKDIR "/src/APILOL"
RUN dotnet build "APILOL.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "APILOL.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "APILOL.dll"]

@ -1,23 +1,14 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4308",
"sslPort": 44305
}
},
{
"profiles": {
"APILOL": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7015;http://localhost:5015",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7015;http://localhost:5015"
},
"IIS Express": {
"commandName": "IISExpress",
@ -26,6 +17,22 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4308",
"sslPort": 44305
}
}
}
}

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

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

@ -0,0 +1,15 @@
using EntityFrameworkLOL.Entities;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL.DBContexts
{
class SQLiteContext : DbContext
{
/*public DbSet<ChampionEntity> Champion { get; set; }
public DbSet<SkinEntity> Skin { get; set; }*/
public DbSet<RuneEntity> Rune { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

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

@ -5,8 +5,9 @@ using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
namespace EntityFrameworkLOL
namespace EntityFrameworkLOL.Entities
{
class ChampionEntity
{

@ -0,0 +1,18 @@
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.Entities
{
class RuneEntity
{
[Key]
public string Name { get; set; }
public string Description { get; set; }
}
}

@ -0,0 +1,22 @@
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.Entities
{
class SkinEntity
{
[Key]
public string Name { get; set; }
public string Description { get; set; }
/*public string Icon { get; set; }
public float Price { get; set; }*/
}
}

@ -20,4 +20,8 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>

@ -1,5 +1,5 @@
// <auto-generated />
using EntityFrameworkLOL;
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
@ -9,9 +9,9 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFrameworkLOL.Migrations
{
[DbContext(typeof(ChampionContext))]
[Migration("20230201163336_MigrationWallah")]
partial class MigrationWallah
[DbContext(typeof(SQLiteContext))]
[Migration("20230202105714_MigrationWallah2")]
partial class MigrationWallah2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -19,22 +19,18 @@ namespace EntityFrameworkLOL.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLOL.ChampionEntity", b =>
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Champions");
b.ToTable("Rune");
});
#pragma warning restore 612, 618
}

@ -5,22 +5,21 @@
namespace EntityFrameworkLOL.Migrations
{
/// <inheritdoc />
public partial class MigrationWallah : Migration
public partial class MigrationWallah2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Champions",
name: "Rune",
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)
Description = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Champions", x => x.Name);
table.PrimaryKey("PK_Rune", x => x.Name);
});
}
@ -28,7 +27,7 @@ namespace EntityFrameworkLOL.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Champions");
name: "Rune");
}
}
}

@ -1,5 +1,5 @@
// <auto-generated />
using EntityFrameworkLOL;
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@ -8,30 +8,26 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFrameworkLOL.Migrations
{
[DbContext(typeof(ChampionContext))]
partial class ChampionContextModelSnapshot : ModelSnapshot
[DbContext(typeof(SQLiteContext))]
partial class SQLiteContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLOL.ChampionEntity", b =>
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Champions");
b.ToTable("Rune");
});
#pragma warning restore 612, 618
}

@ -1,2 +1,97 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using System.Linq;
using System;
using System.Text;
class Program
{
static void Main(string[] args)
{
/*ChampionEntity akali = new ChampionEntity {Name="Akali"};
ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox" };
ChampionEntity ahri = new ChampionEntity { Name = "Ahri" };
ChampionEntity bard = new ChampionEntity { Name = "Bard" };
ChampionEntity alistar = new ChampionEntity { Name = "Alistar" };
ChampionEntity akshan = new ChampionEntity { Name = "Akshan" };
using (var context = new ChampionContext())
{
// Crée des champions et les insère dans la base
Console.WriteLine("Creates and inserts new Champions");
context.Add(akali);
context.Add(aatrox);
context.Add(ahri);
context.Add(bard);
context.Add(alistar);
context.Add(akshan);
context.SaveChanges();
Console.WriteLine("Creates and executes a query retrieving the first Champion of the database whose name starts with an \"A\":");
var aChampion = context.Champions
.Where(c => c.Name.StartsWith("A"))
.First();
Console.WriteLine($"{aChampion.Name} (with bio : {aChampion.Bio}");
}*/
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" };
RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" };
RuneEntity alacrity = new RuneEntity { Name = "Legend : Alacrity", Description = "" };
RuneEntity tenacity = new RuneEntity { Name = "Legend : Tenacity", Description = "" };
RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" };
RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" };
using (var context = new RuneContext())
{
// Crée des Runes et les insère dans la base
Console.WriteLine("Creates and inserts new Runes");
context.Add(conqueror);
context.Add(thriumph);
context.Add(alacrity);
context.Add(tenacity);
context.Add(laststand);
context.Add(laststand2);
context.SaveChanges();
Console.WriteLine("Creates and executes a query retrieving the first Runes of the database whose name starts with an \"L\":");
var lRune = context.Rune
.Where(r => r.Name.StartsWith("L"))
.First();
Console.WriteLine($"{lRune.Name} (with Description : {lRune.Description}");
}
/*SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" };
SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" };
SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" };
SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" };
SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" };
SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" };
using (var context = new SkinContext())
{
// Crée des Skins et les insère dans la base
Console.WriteLine("Creates and inserts new Skins");
context.Add(stinger);
context.Add(infernal);
context.Add(allStar);
context.Add(justicar);
context.Add(mecha);
context.Add(seaHunter);
context.SaveChanges();
Console.WriteLine("Creates and executes a query retrieving the first Skins of the database whose name starts with an \"I\":");
var iSkin = context.Skin
.Where(s => s.Name.StartsWith("I"))
.First();
Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}");
Console.WriteLine("Updates the name of the Infernal Skin");
iSkin.Name = "Infernal of Hell (Wallah)";
context.SaveChanges();
Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}");
Console.WriteLine("Deletes one item from the database");
var droid = context.Skin
.SingleOrDefault(s => s.Name.Equals("Infernal"));
context.Remove(droid);
context.SaveChanges();
}*/
}
}

@ -102,5 +102,4 @@ namespace StubLib
=> parent.champions.UpdateItem(oldItem, newItem);
}
}
}
}
Loading…
Cancel
Save