implémentation des méthodes de DBChampionsManager.cs jusqu'à GetItemsByCharacteristic

pull/1/head
Théo DUPIN 2 years ago
parent f876b294fd
commit 0d01f21885

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Web_Api\Web_Api.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,65 @@
using Web_Api;
namespace ConsoleAPI
{
class Program
{
static async Task Main(string[] args)
{
using (var client = new HttpClient())
{
// définit l'URL de votre API
client.BaseAddress = new Uri("https://localhost:7189/api/Champions");
// exécute la requete HTTP GET
HttpResponseMessage response = await client.GetAsync("");
// vérifie si la réponse est valide
if (response.IsSuccessStatusCode)
{
// lit le contenu de la réponse
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
else
{
Console.WriteLine("Erreur : " + response.StatusCode);
}
// exécute la requête HTTP GET pour obtenir un champion par nom
HttpResponseMessage response1 = await client.GetAsync("/Akali");
if (response1.IsSuccessStatusCode)
{
// lit le contenu de la réponse
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
else
{
Console.WriteLine("Erreur : " + response.StatusCode);
}
// exécute la requête HTTP POST pour ajouter un champion
var champion = new ChampionDTO
{
Name = "Ashe",
Bio = "La Comtesse du froid",
};
/*response = await client.PostAsync("/addChampion", new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(champion), System.Text.Encoding.UTF8, "application/json"));
HttpResponseMessage response = await client.PostAsync("/addChampion", Content);*/
// vérifie si la réponse est valide
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Le champion a été ajouté avec succès");
}
else
{
Console.WriteLine("Erreur : " + response.StatusCode);
}
}
}
}
}

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

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

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</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>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DBEntitiesWithStub\DBEntitiesWithStub.csproj" />
<ProjectReference Include="..\EntityFrameworkLib\EntityFrameworkLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,46 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ConsoleDbSQLite.Migrations
{
[DbContext(typeof(SQLiteLolContext))]
[Migration("20230201115946_migration_ConsoleDbSQLite")]
partial class migrationConsoleDbSQLite
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLib.ChampionEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ConsoleDbSQLite.Migrations
{
/// <inheritdoc />
public partial class migrationConsoleDbSQLite : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
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.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Champions");
}
}
}

@ -0,0 +1,43 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ConsoleDbSQLite.Migrations
{
[DbContext(typeof(SQLiteLolContext))]
partial class SQLiteLolContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLib.ChampionEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,69 @@
// See https://aka.ms/new-console-template for more information
using DBEntitiesWithStub;
using EntityFrameworkLib;
using Microsoft.EntityFrameworkCore;
ChampionEntity jax = new ChampionEntity
{
Name = "Jax",
Icon = "icon Jax",
Bio = "bio Jax"
};
ChampionEntity darius = new ChampionEntity
{
Name = "Darius",
Icon = "icon Darius",
Bio = "bio Darius"
};
ChampionEntity garen = new ChampionEntity
{
Name = "Garen",
Icon = "icon Garen",
Bio = "bio Garen"
};
ChampionEntity veigar = new ChampionEntity
{
Name = "Veigar",
Icon = "icon Veigar",
Bio = "bio Veigar"
};
using (var context = new SQLiteLolContext())
{
Console.WriteLine("Creates and inserts new Champion");
/*context.Add(garen);
context.Add(darius);
context.Add(jax);
context.Add(veigar);*/
context.SaveChanges();
}
using (var context = new SQLiteLolContext())
{
foreach(var n in context.Champions)
{
Console.WriteLine($"{n.Id} {n.Name}");
}
context.SaveChanges();
}
using (LolContext db = new ChampionsDBEntitiesWithStub())
{
Console.WriteLine("Contenu de la base :");
foreach(var n in db.Champions)
{
Console.WriteLine($"\t{n.Id} - {n.Name} - {n.Bio} - {n.Icon}");
}
}
public class SQLiteLolContext : LolContext
{
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
if (!options.IsConfigured)
{
options.UseSqlite($"Data Source=projet.Champions.db");
}
}
}

@ -0,0 +1,12 @@
{
"profiles": {
"ConsoleDbSQLite": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:63787;http://localhost:63795"
}
}
}

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</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>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EntityFrameworkLib\EntityFrameworkLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,20 @@
using EntityFrameworkLib;
using Microsoft.EntityFrameworkCore;
using Model;
namespace DBEntitiesWithStub
{
public class ChampionsDBEntitiesWithStub : LolContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ChampionEntity>().HasData(
new ChampionEntity { Id = 1, Name = "Yone", Bio = "Bio de Yone", Icon = "Icon de Yone" },
new ChampionEntity { Id = 2, Name = "Akali", Bio = "Bio de Akali", Icon = "Icon de Akali" },
new ChampionEntity { Id = 3, Name = "Bard", Bio = "Bio de Bard", Icon = "Icon de Bard" }
);
}
}
}

@ -0,0 +1,18 @@
<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" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EntityFrameworkLib\EntityFrameworkLib.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Design;
using Model;
namespace EntityFrameworkLib
{
@ -13,5 +14,7 @@ namespace EntityFrameworkLib
public string Name { get; set; }
public string Bio { get; set; }
public string Icon { get; set; }
public LargeImage Image { get; set; }
public ChampionClass Class { get; set; }
}
}

@ -0,0 +1,126 @@
using EntityFrameworkLib.Mappers;
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFrameworkLib
{
public class DBChampionManager : IChampionsManager
{
private readonly LolContext context;
public DBChampionManager()
{
}
public DBChampionManager(LolContext context)
{
this.context = context;
}
async Task<Champion?> IGenericDataManager<Champion?>.AddItem(Champion? item)
{
if(item == null)
{
return null;
}
var additem = await context.AddAsync<Champion?>(item);
await context.SaveChangesAsync();
return additem.Entity;
}
async Task<bool> IGenericDataManager<Champion?>.DeleteItem(Champion? item)
{
if(item == null)
{
return false;
}
context.Remove<Champion>(item);
await context.SaveChangesAsync();
return true;
}
async Task<IEnumerable<Champion?>> IGenericDataManager<Champion?>.GetItems(int index, int count, string? orderingPropertyName, bool descending)
{
IEnumerable<Champion> champions = context.Champions.Skip(index * count)
.Take(count)
.OrderBy(champions => orderingPropertyName)
.Select(champions => champions.toModel());
return champions;
}
Task<IEnumerable<Champion?>> IChampionsManager.GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName, bool descending)
{
throw new NotImplementedException();
}
Task<IEnumerable<Champion?>> IChampionsManager.GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName, bool descending)
{
throw new NotImplementedException();
}
Task<IEnumerable<Champion?>> IGenericDataManager<Champion?>.GetItemsByName(string substring, int index, int count, string? orderingPropertyName, bool descending)
{
throw new NotImplementedException();
}
Task<IEnumerable<Champion?>> IChampionsManager.GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName, bool descending)
{
throw new NotImplementedException();
}
Task<IEnumerable<Champion?>> IChampionsManager.GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName, bool descending)
{
throw new NotImplementedException();
}
Task<IEnumerable<Champion?>> IChampionsManager.GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName, bool descending)
{
throw new NotImplementedException();
}
Task<int> IGenericDataManager<Champion?>.GetNbItems()
{
throw new NotImplementedException();
}
Task<int> IChampionsManager.GetNbItemsByCharacteristic(string charName)
{
throw new NotImplementedException();
}
Task<int> IChampionsManager.GetNbItemsByClass(ChampionClass championClass)
{
throw new NotImplementedException();
}
Task<int> IGenericDataManager<Champion?>.GetNbItemsByName(string substring)
{
throw new NotImplementedException();
}
Task<int> IChampionsManager.GetNbItemsByRunePage(RunePage? runePage)
{
throw new NotImplementedException();
}
Task<int> IChampionsManager.GetNbItemsBySkill(Skill? skill)
{
throw new NotImplementedException();
}
Task<int> IChampionsManager.GetNbItemsBySkill(string skill)
{
throw new NotImplementedException();
}
Task<Champion?> IGenericDataManager<Champion?>.UpdateItem(Champion? oldItem, Champion? newItem)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,21 @@
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFrameworkLib
{
public class DBDataManager : IDataManager
{
public IChampionsManager ChampionsManager => new DBChampionManager();
public ISkinsManager SkinsManager => throw new NotImplementedException();
public IRunesManager RunesManager=> throw new NotImplementedException();
public IRunePagesManager RunePagesManager=> throw new NotImplementedException();
}
}

@ -20,5 +20,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -4,12 +4,12 @@ using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLib
{
public class ChampionContext : DbContext
public class LolContext : DbContext
{
public DbSet<ChampionEntity> Champions { get; set; }
public ChampionContext () { }
public ChampionContext(DbContextOptions<ChampionContext> options)
public LolContext () { }
public LolContext(DbContextOptions<LolContext> options)
: base(options) { }
protected override void OnConfiguring(DbContextOptionsBuilder options)

@ -0,0 +1,29 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFrameworkLib.Mappers
{
public static class ChampionChanger
{
public static Champion toModel(this ChampionEntity championEntity)
{
return new Champion(championEntity.Name, championEntity.Bio, championEntity.Icon, championEntity.Image, championEntity.Class);
}
public static ChampionEntity toEntity(this Champion champion)
{
return new ChampionEntity
{
Name = champion.Name,
Bio = champion.Bio,
Icon = champion.Icon,
Image = champion.Image,
Class = champion.Class,
};
}
}
}

@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFrameworkLib.Migrations
{
[DbContext(typeof(ChampionContext))]
[DbContext(typeof(LolContext))]
[Migration("20230201082358_myFirstMigration")]
partial class myFirstMigration
{

@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFrameworkLib.Migrations
{
[DbContext(typeof(ChampionContext))]
[DbContext(typeof(LolContext))]
[Migration("20230201084126_projet_SQLite")]
partial class projetSQLite
{

@ -0,0 +1,47 @@
// <auto-generated />
using EntityFrameworkLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkLib.Migrations
{
[DbContext(typeof(LolContext))]
[Migration("20230201103421_migration_projet")]
partial class migrationprojet
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLib.ChampionEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkLib.Migrations
{
/// <inheritdoc />
public partial class migrationprojet : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFrameworkLib.Migrations
{
[DbContext(typeof(ChampionContext))]
[DbContext(typeof(LolContext))]
partial class ChampionContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)

@ -0,0 +1,12 @@
{
"profiles": {
"EntityFrameworkLib": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:63785;http://localhost:63791"
}
}
}

@ -15,7 +15,21 @@ 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}") = "EntityFrameworkLib", "EntityFrameworkLib\EntityFrameworkLib.csproj", "{46FBEB1B-700D-4990-A8FC-41B044014A59}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkLib", "EntityFrameworkLib\EntityFrameworkLib.csproj", "{46FBEB1B-700D-4990-A8FC-41B044014A59}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleDbSQLite", "ConsoleDbSQLite\ConsoleDbSQLite.csproj", "{F26BD4B5-BC8D-4773-98F3-FB55A6B57DEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestsSQLiteInMemory", "UnitTestsSQLiteInMemory\UnitTestsSQLiteInMemory.csproj", "{2AE5C2DD-6EE1-4115-803B-963B25A5D0F5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Consommation", "Consommation", "{F18B03EC-963B-4EEA-842D-5C041A931D20}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web_Api", "Web_Api\Web_Api.csproj", "{B9D905BB-F4CD-4CE4-B718-7534AE5C3862}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleAPI", "ConsoleAPI\ConsoleAPI.csproj", "{313DC068-AFD4-4FCC-BB19-F344F996050D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DBWithStub", "DBWithStub", "{F0711CE6-C48B-4E96-8DE0-79BDBB4635D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DBEntitiesWithStub", "DBEntitiesWithStub\DBEntitiesWithStub.csproj", "{C9D40527-6F42-4FA9-8063-554D2A0E9161}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -43,6 +57,26 @@ Global
{46FBEB1B-700D-4990-A8FC-41B044014A59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46FBEB1B-700D-4990-A8FC-41B044014A59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46FBEB1B-700D-4990-A8FC-41B044014A59}.Release|Any CPU.Build.0 = Release|Any CPU
{F26BD4B5-BC8D-4773-98F3-FB55A6B57DEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F26BD4B5-BC8D-4773-98F3-FB55A6B57DEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F26BD4B5-BC8D-4773-98F3-FB55A6B57DEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F26BD4B5-BC8D-4773-98F3-FB55A6B57DEE}.Release|Any CPU.Build.0 = Release|Any CPU
{2AE5C2DD-6EE1-4115-803B-963B25A5D0F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AE5C2DD-6EE1-4115-803B-963B25A5D0F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AE5C2DD-6EE1-4115-803B-963B25A5D0F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AE5C2DD-6EE1-4115-803B-963B25A5D0F5}.Release|Any CPU.Build.0 = Release|Any CPU
{B9D905BB-F4CD-4CE4-B718-7534AE5C3862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9D905BB-F4CD-4CE4-B718-7534AE5C3862}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9D905BB-F4CD-4CE4-B718-7534AE5C3862}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9D905BB-F4CD-4CE4-B718-7534AE5C3862}.Release|Any CPU.Build.0 = Release|Any CPU
{313DC068-AFD4-4FCC-BB19-F344F996050D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{313DC068-AFD4-4FCC-BB19-F344F996050D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{313DC068-AFD4-4FCC-BB19-F344F996050D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{313DC068-AFD4-4FCC-BB19-F344F996050D}.Release|Any CPU.Build.0 = Release|Any CPU
{C9D40527-6F42-4FA9-8063-554D2A0E9161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9D40527-6F42-4FA9-8063-554D2A0E9161}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9D40527-6F42-4FA9-8063-554D2A0E9161}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9D40527-6F42-4FA9-8063-554D2A0E9161}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -50,6 +84,11 @@ Global
GlobalSection(NestedProjects) = preSolution
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
{F26BD4B5-BC8D-4773-98F3-FB55A6B57DEE} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{2AE5C2DD-6EE1-4115-803B-963B25A5D0F5} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B9D905BB-F4CD-4CE4-B718-7534AE5C3862} = {F18B03EC-963B-4EEA-842D-5C041A931D20}
{313DC068-AFD4-4FCC-BB19-F344F996050D} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{C9D40527-6F42-4FA9-8063-554D2A0E9161} = {F0711CE6-C48B-4E96-8DE0-79BDBB4635D6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}

@ -6,6 +6,10 @@ using System.Text;
namespace Model;
public class Champion : IEquatable<Champion>
{
public int Id
{
get => Id;
}
public string Name
{
get => name;
@ -53,6 +57,15 @@ public class Champion : IEquatable<Champion>
Skins = new ReadOnlyCollection<Skin>(skins);
}
public Champion(string name, string bio, string icon, LargeImage image, ChampionClass @class)
{
Name = name;
Bio = bio;
Icon = icon;
Image = image;
Class = @class;
}
public ReadOnlyCollection<Skin> Skins { get; private set; }
private List<Skin> skins = new ();
@ -146,6 +159,6 @@ public class Champion : IEquatable<Champion>
}
}
return sb.ToString();
}
}
}

@ -0,0 +1,12 @@
{
"profiles": {
"Model": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:63789;http://localhost:63792"
}
}
}

@ -48,6 +48,12 @@ namespace Model
Description = description;
}
public Rune(string name, string description)
{
this.name = name;
this.description = description;
}
public override bool Equals(object? obj)
{
if(ReferenceEquals(obj, null)) return false;

@ -62,6 +62,13 @@ namespace Model
Description = description;
}
public Skin(string name, string description, float price)
{
this.name = name;
this.description = description;
Price = price;
}
public override bool Equals(object? obj)
{
if(ReferenceEquals(obj, null)) return false;
@ -76,7 +83,7 @@ namespace Model
public override int GetHashCode()
=> Name.GetHashCode() % 997;
public override string ToString()
public override string ToString()
=> $"{Name}";
}
}

@ -0,0 +1,12 @@
{
"profiles": {
"Shared": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:63788;http://localhost:63793"
}
}
}

@ -0,0 +1,12 @@
{
"profiles": {
"StubLib": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:63790;http://localhost:63794"
}
}
}

@ -1,7 +1,8 @@
namespace EntityFrameworkLib
using System;
namespace Test
{
public class Class1
{
}
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

@ -0,0 +1,12 @@
{
"profiles": {
"ConsoleTests": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:63786;http://localhost:63796"
}
}
}

@ -0,0 +1,93 @@
using EntityFrameworkLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
namespace UnitTestsSQLiteInMemory
{
public class ChampionsDbTests
{
[Fact]
public void Add_Champions_Test()
{
//connection must be opened to use In-memory database
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LolContext>()
.UseInMemoryDatabase(databaseName: "TestChampions_database")
.Options;
using(var context = new LolContext(options))
{
ChampionEntity akali = new ChampionEntity { Name = "Akali", Bio = "Bio Akali", Icon = "Icon Akali" };
ChampionEntity alistar = new ChampionEntity { Name = "Alistar", Bio = "Bio Alistar", Icon = "Icon Alistar" };
ChampionEntity bard = new ChampionEntity { Name = "Bard", Bio = "Bio Bard", Icon = "Icon Bard" };
context.Champions.Add(akali);
context.Champions.Add(alistar);
context.Champions.Add(bard);
context.SaveChanges();
}
using(var context = new LolContext(options))
{
Assert.Equal(3, context.Champions.Count());
Assert.Equal("Akali", context.Champions.First().Name);
}
}
[Fact]
public void Modify_Champions_Test()
{
//connection must be opened to use In-memory database
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LolContext>()
.UseSqlite(connection)
.Options;
//prepares the database with one instance of the context
using (var context = new LolContext(options))
{
//context.Database.OpenConnection();
context.Database.EnsureCreated();
ChampionEntity akali = new ChampionEntity { Name = "Akali", Bio = "Bio Akali", Icon = "Icon Akali" };
ChampionEntity akshan = new ChampionEntity { Name = "Akshan", Bio = "Bio Akshan", Icon = "Icon Akshan" };
ChampionEntity twitch = new ChampionEntity { Name = "Twitch", Bio = "Bio Twitch", Icon = "icon Twitch" };
context.Champions.Add(akali);
context.Champions.Add(akshan);
context.Champions.Add(twitch);
context.SaveChanges();
}
//uses another instance of the context to do the tests
using (var context = new LolContext(options))
{
context.Database.EnsureCreated();
string nameToFind = "ak";
Assert.Equal(2, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
nameToFind = "wi";
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
var akshan = context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).First();
akshan.Name = "Volibear";
context.SaveChanges();
}
//uses another instance of the context to do the tests
using (var context = new LolContext(options))
{
context.Database.EnsureCreated();
string nameToFind = "i";
Assert.Equal(2, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
nameToFind = "voli";
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
}
}
}
}

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EntityFrameworkLib\EntityFrameworkLib.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,16 @@
using Model;
namespace Web_Api
{
public class ChampionDTO
{
public int Id { get; set; }
public string Name { get; set; }
public string Bio { get; set; }
public Champion toModel()
{
return new Champion(Name, Bio);
}
}
}

@ -0,0 +1,163 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Model;
using StubLib;
using Web_Api.Mapper;
namespace Web_Api.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class ChampionsController : Controller
{
private StubData.ChampionsManager ChampionsManager { get; set; } = new StubData.ChampionsManager(new StubData());
private readonly ILogger<ChampionsController> _logger;
public ChampionsController(ILogger<ChampionsController> logger)
{
_logger = logger;
}
[HttpGet]
public async Task<IActionResult> Get()
{
var list = await ChampionsManager.GetItems(0, await ChampionsManager.GetNbItems());
return Ok(list.Select(champion => champion?.toDTO()));
}
[HttpGet("name")]
public async Task<IActionResult> GetById(string name)
{
var championSelected = await ChampionsManager.GetItemsByName(name, 0, await ChampionsManager.GetNbItemsByName(name), null);
return Ok(championSelected.Select(c => c?.toDTO()));
}
[HttpPost("addChampion")]
public async Task<IActionResult> AddChampion(ChampionDTO champion)
{
var newChampion = champion.toModel();
await ChampionsManager.AddItem(newChampion);
if(champion.Bio == "string")
{
champion.Bio = "Aucune bio";
}
Console.WriteLine("Le champion { " + champion.Name + " } avec pour bio { " + champion.Bio + " } a bien été ajouté");
return Ok();
}
[HttpPut("updateChampion")]
public async Task<IActionResult> UpdateChampion(string name, ChampionDTO champion)
{
var championSelected = await ChampionsManager.GetItemsByName(name, 0, await ChampionsManager.GetNbItemsByName(name), null);
var existingChampion = championSelected.FirstOrDefault();
if (existingChampion == null)
{
Console.WriteLine("Le champion { " + name + " } n'existe pas !");
return NotFound();
}
var updatedChampion = champion.toModel();
await ChampionsManager.UpdateItem(existingChampion, updatedChampion);
if(updatedChampion.Bio == "string")
{
updatedChampion.Bio = "Aucune bio";
}
Console.WriteLine("Le champion { " + name + " } a été modifié en { " + updatedChampion.Name + " } avec pour bio { " + updatedChampion.Bio + " }");
return Ok();
}
[HttpDelete("deleteChampion")]
public async Task<IActionResult> DeleteChampion(string name)
{
var championSelected = await ChampionsManager.GetItemsByName(name, 0, await ChampionsManager.GetNbItemsByName(name), null);
if(!await ChampionsManager.DeleteItem(championSelected.FirstOrDefault()))
{
Console.WriteLine("champion { " + name + " } non trouvé !");
return NotFound();
}
Console.WriteLine("champion { " + name + " } supprimé");
return Ok();
}
/*[HttpGet(Name = "GetChampionsById")]
public async Task<IActionResult> GetById()
{
}*/
/*// GET: ChampionsController
public ActionResult Index()
{
return View();
}
// GET: ChampionsController/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: ChampionsController/Create
public ActionResult Create()
{
return View();
}
// POST: ChampionsController/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: ChampionsController/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: ChampionsController/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: ChampionsController/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: ChampionsController/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}*/
}
}

@ -0,0 +1,156 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using StubLib;
using Web_Api.Mapper;
using static StubLib.StubData;
namespace Web_Api.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class RunesController : Controller
{
private StubData.RunesManager RunesManager { get; set; } = new StubData.RunesManager(new StubData());
private readonly ILogger<RunesController> _logger;
public RunesController(ILogger<RunesController> logger)
{
_logger = logger;
}
[HttpGet]
public async Task<IActionResult> Get()
{
var list = await RunesManager.GetItems(0, await RunesManager.GetNbItems());
return Ok(list.Select(rune => rune?.toDTO()));
}
[HttpGet("name")]
public async Task<IActionResult> GetById(string name)
{
var runeSelected = await RunesManager.GetItemsByName(name, 0, await RunesManager.GetNbItemsByName(name), null);
return Ok(runeSelected.Select(rune => rune?.toDTO()));
}
[HttpPost("addRune")]
public async Task<IActionResult> AddRune(RuneDTO rune)
{
var newRune = rune.toModel();
await RunesManager.AddItem(newRune);
if(rune.Description == "string")
{
rune.Description = "Aucune bio";
}
Console.WriteLine("La rune { " + rune.Name + " } avec pour descrption { " + rune.Description + " } a bien été ajoutée");
return Ok(newRune);
}
[HttpPut("updateRune")]
public async Task<IActionResult> UpdateRune(string name, RuneDTO rune)
{
var runeSelected = await RunesManager.GetItemsByName(name, 0, await RunesManager.GetNbItemsByName(name), null);
var existingRune = runeSelected.FirstOrDefault();
if (existingRune == null)
{
Console.WriteLine("La rune { " + name + " } n'existe pas !");
return NotFound();
}
var updatedRune = rune.toModel();
await RunesManager.UpdateItem(existingRune, updatedRune);
if (rune.Description == "string")
{
rune.Description = "Aucune bio";
}
Console.WriteLine("La rune { " + name + " } a été modifiée en { " + updatedRune.Name + " } avec pour description { " + rune.Description + " }");
return Ok();
}
[HttpDelete("deleteRune")]
public async Task<IActionResult> DeleteRune(string name)
{
var runeSelected = await RunesManager.GetItemsByName(name, 0, await RunesManager.GetNbItemsByName(name), null);
if(!await RunesManager.DeleteItem(runeSelected.FirstOrDefault()))
{
Console.WriteLine("rune { " + name + " } non trouvée !");
return NotFound();
}
Console.WriteLine("rune { " + name + " } supprimée");
return Ok();
}
/*// GET: RuneController
public ActionResult Index()
{
return View();
}
// GET: RuneController/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: RuneController/Create
public ActionResult Create()
{
return View();
}
// POST: RuneController/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: RuneController/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: RuneController/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: RuneController/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: RuneController/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}*/
}
}

@ -0,0 +1,155 @@
using Microsoft.AspNetCore.Mvc;
using StubLib;
using Web_Api.Mapper;
namespace Web_Api.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class SkinsController : Controller
{
private StubData.SkinsManager SkinsManager { get; set; } = new StubData.SkinsManager(new StubData());
private readonly ILogger<SkinsController> _logger;
public SkinsController(ILogger<SkinsController> logger)
{
_logger = logger;
}
[HttpGet]
public async Task<IActionResult> Get()
{
var list = await SkinsManager.GetItems(0, await SkinsManager.GetNbItems());
return Ok(list.Select(skin => skin?.toDTO()));
}
[HttpGet("name")]
public async Task<IActionResult> GetById(string name)
{
var skinSelected = await SkinsManager.GetItemsByName(name, 0, await SkinsManager.GetNbItemsByName(name), null);
return Ok(skinSelected.Select(skin => skin?.toDTO()));
}
[HttpPost("addSkin")]
public async Task<IActionResult> AddSkin(SkinDTO skin)
{
var newSkin = skin.toModel();
await SkinsManager.AddItem(newSkin);
if(skin.Description == "string")
{
skin.Description = "Aucune bio";
}
Console.WriteLine("Le skin { " + skin.Name + " } avec pour description { " + skin.Description + " } a bien été ajouté");
return Ok(newSkin);
}
[HttpPut("updateSkin")]
public async Task<IActionResult> UpdateChampion(string name, SkinDTO skin)
{
var skinSelected = await SkinsManager.GetItemsByName(name, 0, await SkinsManager.GetNbItemsByName(name), null);
var existingSkin = skinSelected.FirstOrDefault();
if(existingSkin == null)
{
Console.WriteLine("Le skin { " + name + " } n'existe pas !");
return NotFound();
}
var updatedSkin = skin.toModel();
await SkinsManager.UpdateItem(existingSkin, updatedSkin);
if(skin.Description == "string")
{
skin.Description = "Aucune bio";
}
Console.WriteLine("Le skin { " + name + " } a été modifié en " + " { " + updatedSkin.Name + " } avec pour description { " + updatedSkin.Description + " }<");
return Ok();
}
[HttpDelete("deleteSkin")]
public async Task<IActionResult> DeleteChampion(string name)
{
var skinSelected = await SkinsManager.GetItemsByName(name, 0, await SkinsManager.GetNbItemsByName(name), null);
if (!await SkinsManager.DeleteItem(skinSelected.FirstOrDefault()))
{
Console.WriteLine("skin { " + name + " } non trouvé !");
return NotFound();
}
Console.WriteLine("skin { " + name + " } supprimé");
return Ok();
}
/*// GET: SkinsController
public ActionResult Index()
{
return View();
}
// GET: SkinsController/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: SkinsController/Create
public ActionResult Create()
{
return View();
}
// POST: SkinsController/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: SkinsController/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: SkinsController/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: SkinsController/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: SkinsController/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}*/
}
}

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace Web_Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

@ -0,0 +1,17 @@
using Model;
using Web_Api.Controllers;
namespace Web_Api.Mapper
{
public static class ChampionMapper
{
public static ChampionDTO toDTO(this Champion champion)
{
return new ChampionDTO()
{
Name = champion.Name,
Bio = champion.Bio
};
}
}
}

@ -0,0 +1,16 @@
using Model;
namespace Web_Api.Mapper
{
public static class RuneMapper
{
public static RuneDTO toDTO(this Rune rune)
{
return new RuneDTO
{
Name= rune.Name,
Description= rune.Description
};
}
}
}

@ -0,0 +1,18 @@
using Model;
using System.Runtime.CompilerServices;
namespace Web_Api.Mapper
{
public static class SkinMapper
{
public static SkinDTO toDTO(this Skin skin)
{
return new SkinDTO()
{
Name = skin.Name,
Description = skin.Description,
Price = skin.Price
};
}
}
}

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:43712",
"sslPort": 44391
}
},
"profiles": {
"Web_Api": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7189;http://localhost:5097",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -0,0 +1,18 @@
using Model;
namespace Web_Api
{
public class RuneDTO
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Rune toModel()
{
return new Rune(Name, Description);
}
}
}

@ -0,0 +1,20 @@
using Model;
namespace Web_Api
{
public class SkinDTO
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public float Price { get; set; }
public Skin toModel()
{
return new Skin(Name, Description, Price);
}
}
}

@ -0,0 +1,13 @@
namespace Web_Api
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading…
Cancel
Save