API Skill (Mapper+Controller)
continuous-integration/drone/push Build is failing Details

ApiSkill
Louison PARANT 2 years ago
parent 0673268745
commit 096dc87b5f

@ -69,8 +69,3 @@ namespace APILOL.Controllers
}
}
}
/*
var champion = new Champion("");
var dto = ChampionMapper.ToDto(champion);
*/

@ -11,12 +11,17 @@ namespace APILOL.Mapper
{
Name = champion.Name,
Bio = champion.Bio,
Class = champion.Class,
Icon = champion.Icon,
Image = champion.Image,
Characteristics = champion.Characteristics,
Skills = champion.Skills,
};
}
public static Champion ToModel(this ChampionDTO champion)
{
return new Champion(champion.Name);
return new Champion(champion.Name/*, champion.Class, champion.Icon, champion.Image.ToString(), champion.Bio*/);
}
}
}

@ -1,8 +1,23 @@
namespace DTO
using Model;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
namespace DTO
{
public class ChampionDTO
{
public string Name { get; set; }
public string Bio { get; set; }
public ChampionClass Class { get; set; }
public string Icon { get; set; }
public LargeImage Image { get; set; }
public ReadOnlyDictionary<string, int> Characteristics { get; set; }
public ImmutableHashSet<Skill> Skills { get; set; }
}
}

@ -16,4 +16,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,18 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
{
public class SkillDTO
{
public SkillType Type { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
}

@ -22,6 +22,7 @@ namespace EntityFrameworkLOL.DBContexts
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// Fluent API
}
public SQLiteContext()

@ -18,5 +18,7 @@ namespace EntityFrameworkLOL.Entities
public ImageEntity Image { get; set; }
public RuneFamilyEntity Family { get; set; }
public ICollection<RunePageEntity> Pages { get; set; }
}
}

@ -23,5 +23,7 @@ namespace EntityFrameworkLOL.Entities
[NotMapped]
public Dictionary<CategoryEntity, RuneEntity> Dictionary { get; set; }
// Switch Dictionary to List puis faudra juste mapper la liste en dico
public ICollection<RuneEntity> Entities { get; set; }
}
}

@ -8,6 +8,72 @@ class Program
{
static void Main(string[] args)
{
using (var context = new SQLiteContext()) {
if (context.Champion.Count() > 0)
{
foreach (var c in context.Champion.ToArray())
{
context.Champion.Remove(c);
}
}
if (context.Rune.Count() > 0)
{
foreach (var r in context.Rune.ToArray())
{
context.Rune.Remove(r);
}
}
if (context.Skin.Count() > 0)
{
foreach (var s in context.Skin.ToArray())
{
context.Skin.Remove(s);
}
}
if (context.Skill.Count() > 0)
{
foreach (var s in context.Skill.ToArray())
{
context.Skill.Remove(s);
}
}
if (context.RunePage.Count() > 0)
{
foreach (var rp in context.RunePage.ToArray())
{
context.RunePage.Remove(rp);
}
}
if (context.ChampionClass.Count() > 0)
{
foreach (var cc in context.ChampionClass.ToArray())
{
context.ChampionClass.Remove(cc);
}
}
if (context.RuneFamily.Count() > 0)
{
foreach (var rf in context.RuneFamily.ToArray())
{
context.RuneFamily.Remove(rf);
}
}
if (context.SkillType.Count() > 0)
{
foreach (var st in context.SkillType.ToArray())
{
context.SkillType.Remove(st);
}
}
if (context.Image.Count() > 0)
{
foreach (var i in context.Image.ToArray())
{
context.Image.Remove(i);
}
}
context.SaveChanges();
}
ChampionEntity akali = new ChampionEntity { Name = "Akali", Bio = "" };
ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox", Bio = "" };
ChampionEntity ahri = new ChampionEntity { Name = "Ahri", Bio = "" };
@ -19,12 +85,13 @@ class Program
{
// Crée des champions et les insère dans la base
Console.WriteLine("Creates and inserts new Champions");
context.Add(akali);
context.AddRange(new ChampionEntity[] { akali, aatrox, ahri, bard, alistar, akshan });
/*context.Add(akali);
context.Add(aatrox);
context.Add(ahri);
context.Add(bard);
context.Add(alistar);
context.Add(akshan);
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.Champion
@ -44,12 +111,13 @@ class Program
{
// Crée des Runes et les insère dans la base
Console.WriteLine("Creates and inserts new Runes");
context.Add(conqueror);
context.AddRange(new RuneEntity[] { conqueror, thriumph, alacrity, tenacity, laststand, laststand2 });
/*context.Add(conqueror);
context.Add(thriumph);
context.Add(alacrity);
context.Add(tenacity);
context.Add(laststand);
context.Add(laststand2);
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
@ -69,12 +137,13 @@ class Program
{
// Crée des Skins et les insère dans la base
Console.WriteLine("Creates and inserts new Skins");
context.Add(stinger);
context.AddRange(new SkinEntity[] { stinger, infernal, allStar, justicar, mecha, seaHunter });
/*context.Add(stinger);
context.Add(infernal);
context.Add(allStar);
context.Add(justicar);
context.Add(mecha);
context.Add(seaHunter);
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

Loading…
Cancel
Save