🔥 rm useless files
continuous-integration/drone/push Build is failing Details

pull/3/head
Maxence LANONE 2 years ago
parent 9ba8bb4c00
commit 8082ba963b

@ -1,4 +1,5 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Shared;
@ -13,16 +14,22 @@ namespace EntityFrameWorkLib
public int UniqueId { get; set; }
public string Name { get; set; }
[Required]
//[Required]
[MaxLength(256)]
public string Bio { get; set; }
public string Icon { get; set; }
[Required]
//[Required]
public ChampionClass Class { get; set; }
public LargeImageEntity? LargeImageEntity { get; set; }
public Collection<SkinEntity> Skins { get; set; }
public LargeImageEntity? LargeImage { get; set; }
public HashSet<SkillEntity> skills = new HashSet<SkillEntity>();
public Collection<RunePageEntity> ListRunePages { get; set; }
}
}

@ -8,13 +8,13 @@ namespace EntityFrameWorkLib
[Key]
public Guid Id { get; set; }
[Required]
//[Required]
public string Base64 { get; set; }
[Required]
//[Required]
public int championId { get; set; }
[Required]
//[Required]
public ChampionEntity champion { get; set; }
}
}

@ -9,6 +9,9 @@ namespace EntityFrameWorkLib
public DbSet<ChampionEntity> Champions { get; set; }
public DbSet<SkillEntity> Skill { get; set; }
public DbSet<LargeImageEntity> LargeImage { get; set; }
public DbSet<RuneEntity> Runes { get; set; }
public DbSet<RunePageEntity> RunesPage { get; set; }
public DbSet<SkinEntity> Skins { get; set; }
public LolContext() { }
public LolContext(DbContextOptions<LolContext> options)
@ -25,18 +28,28 @@ namespace EntityFrameWorkLib
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
//Définition de la clé primaire de ChampionEntity
modelBuilder.Entity<ChampionEntity>().HasKey(n => n.UniqueId);
//Définition du mode de generation de la clé : génération à l'insertion
modelBuilder.Entity<ChampionEntity>().Property(n => n.UniqueId).ValueGeneratedOnAdd();
modelBuilder.Entity<ChampionEntity>()
.HasOne(c => c.LargeImageEntity)
.HasOne(c => c.LargeImage)
.WithOne(li => li.champion)
.HasForeignKey<LargeImageEntity>(li => li.championId);
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<SkinEntity>()
.Property(s => s.Name)
.ValueGeneratedOnAdd();
modelBuilder.Entity<RunePageEntity>()
.Property(s => s.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<RuneEntity>()
.Property(s => s.Name)
.ValueGeneratedOnAdd();
}
}

@ -0,0 +1,225 @@
// <auto-generated />
using System;
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("20230326210027_MyMigration")]
partial class MyMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Property<int>("UniqueId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SkillEntityName")
.HasColumnType("TEXT");
b.HasKey("UniqueId");
b.HasIndex("SkillEntityName");
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("championId")
.IsUnique();
b.ToTable("LargeImage");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("RuneFamily")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Runes");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("RuneEntityName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ChampionEntityUniqueId");
b.HasIndex("RuneEntityName");
b.ToTable("RunesPage");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("SkillType")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionEntityUniqueId");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.HasOne("EntityFrameWorkLib.SkillEntity", null)
.WithMany("champions")
.HasForeignKey("SkillEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
.WithOne("LargeImage")
.HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("champion");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("ChampionEntityUniqueId");
b.HasOne("EntityFrameWorkLib.RuneEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("RuneEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("Skins")
.HasForeignKey("ChampionEntityUniqueId");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Navigation("LargeImage");
b.Navigation("ListRunePages");
b.Navigation("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Navigation("ListRunePages");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Navigation("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,175 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
/// <inheritdoc />
public partial class MyMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Runes",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
RuneFamily = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Runes", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Skill",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
SkillType = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Skill", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
{
UniqueId = 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", maxLength: 256, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
Class = table.Column<int>(type: "INTEGER", nullable: false),
SkillEntityName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Champions", x => x.UniqueId);
table.ForeignKey(
name: "FK_Champions_Skill_SkillEntityName",
column: x => x.SkillEntityName,
principalTable: "Skill",
principalColumn: "Name");
});
migrationBuilder.CreateTable(
name: "LargeImage",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Base64 = table.Column<string>(type: "TEXT", nullable: false),
championId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LargeImage", x => x.Id);
table.ForeignKey(
name: "FK_LargeImage_Champions_championId",
column: x => x.championId,
principalTable: "Champions",
principalColumn: "UniqueId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RunesPage",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
ChampionEntityUniqueId = table.Column<int>(type: "INTEGER", nullable: true),
RuneEntityName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RunesPage", x => x.Id);
table.ForeignKey(
name: "FK_RunesPage_Champions_ChampionEntityUniqueId",
column: x => x.ChampionEntityUniqueId,
principalTable: "Champions",
principalColumn: "UniqueId");
table.ForeignKey(
name: "FK_RunesPage_Runes_RuneEntityName",
column: x => x.RuneEntityName,
principalTable: "Runes",
principalColumn: "Name");
});
migrationBuilder.CreateTable(
name: "Skins",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
Price = table.Column<float>(type: "REAL", nullable: false),
ChampionEntityUniqueId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Skins", x => x.Name);
table.ForeignKey(
name: "FK_Skins_Champions_ChampionEntityUniqueId",
column: x => x.ChampionEntityUniqueId,
principalTable: "Champions",
principalColumn: "UniqueId");
});
migrationBuilder.CreateIndex(
name: "IX_Champions_SkillEntityName",
table: "Champions",
column: "SkillEntityName");
migrationBuilder.CreateIndex(
name: "IX_LargeImage_championId",
table: "LargeImage",
column: "championId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RunesPage_ChampionEntityUniqueId",
table: "RunesPage",
column: "ChampionEntityUniqueId");
migrationBuilder.CreateIndex(
name: "IX_RunesPage_RuneEntityName",
table: "RunesPage",
column: "RuneEntityName");
migrationBuilder.CreateIndex(
name: "IX_Skins_ChampionEntityUniqueId",
table: "Skins",
column: "ChampionEntityUniqueId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LargeImage");
migrationBuilder.DropTable(
name: "RunesPage");
migrationBuilder.DropTable(
name: "Skins");
migrationBuilder.DropTable(
name: "Runes");
migrationBuilder.DropTable(
name: "Champions");
migrationBuilder.DropTable(
name: "Skill");
}
}
}

@ -0,0 +1,222 @@
// <auto-generated />
using System;
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
[DbContext(typeof(LolContext))]
partial class LolContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Property<int>("UniqueId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SkillEntityName")
.HasColumnType("TEXT");
b.HasKey("UniqueId");
b.HasIndex("SkillEntityName");
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("championId")
.IsUnique();
b.ToTable("LargeImage");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("RuneFamily")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Runes");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("RuneEntityName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ChampionEntityUniqueId");
b.HasIndex("RuneEntityName");
b.ToTable("RunesPage");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("SkillType")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionEntityUniqueId");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.HasOne("EntityFrameWorkLib.SkillEntity", null)
.WithMany("champions")
.HasForeignKey("SkillEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
.WithOne("LargeImage")
.HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("champion");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("ChampionEntityUniqueId");
b.HasOne("EntityFrameWorkLib.RuneEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("RuneEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("Skins")
.HasForeignKey("ChampionEntityUniqueId");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Navigation("LargeImage");
b.Navigation("ListRunePages");
b.Navigation("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Navigation("ListRunePages");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Navigation("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -1,4 +1,5 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using Shared;
@ -8,15 +9,17 @@ namespace EntityFrameWorkLib
public class RuneEntity
{
[Key]
[MaxLength(256)]
//[MaxLength(256)]
public string Name { get; set; }
[Required]
//[Required]
[MaxLength(500)]
public string Description { get; set; }
[Required]
//[Required]
public RuneFamily RuneFamily { get; set; }
public Collection<RunePageEntity> ListRunePages { get; set; }
}
}

@ -10,12 +10,14 @@ namespace EntityFrameWorkLib
[MaxLength(256)]
public string Name { get; set; }
[Required]
//[Required]
[MaxLength(500)]
public string Description { get; set; }
[Required]
//[Required]
public SkillType SkillType { get; set; }
public HashSet<ChampionEntity> champions { get; set; }
}
}

@ -9,13 +9,13 @@ namespace EntityFrameWorkLib
[MaxLength(256)]
public string Name { get; set; }
[Required]
//[Required]
[MaxLength(500)]
public string Description { get; set; }
public string Icon { get; set; }
[Required]
//[Required]
public float Price { get; set; }
}
}

@ -22,7 +22,7 @@ ChampionEntity jax = new ChampionEntity
Icon = "icon jax",
Bio = "test bio jax",
Class = ChampionClass.Fighter,
LargeImageEntity = largeImage
LargeImage = largeImage
};
ChampionEntity darius = new ChampionEntity
{

@ -3,7 +3,6 @@ namespace WebApiLol
{
public class ChampionDTO
{
public int UniqueId { get; set; }
public string Name { get; set; }

@ -0,0 +1,15 @@
using System;
namespace WebApiLol
{
public class ChampionPageDTO
{
public IEnumerable<ChampionDTO> Data { get; set; }
public int Index { get; set; }
public int Count { get; set; }
public int TotalCount { get; set; }
}
}

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
using WebApiLol.Converter;
@ -14,18 +17,35 @@ public class ChampionController : ControllerBase
{
private StubData.ChampionsManager ChampionsManager { get; set; } = new StubData.ChampionsManager(new StubData());
private IChampionsManager _dataManager;
private readonly ILogger<ChampionController> _logger;
public ChampionController(ILogger<ChampionController> logger)
public ChampionController(IDataManager manager,ILogger<ChampionController> logger)
{
_dataManager = manager.ChampionsMgr;
_logger = logger;
}
[HttpGet]
public async Task<IActionResult> Get()
[ProducesResponseType(typeof(ChampionPageDTO), 200)]
public async Task<IActionResult> Get([FromQuery] int index = 0, int count = 10, string? name = "")
{
var list = await ChampionsManager.GetItems(0, await ChampionsManager.GetNbItems());
return Ok(list.Select(champion => champion?.toDTO()));
_logger.LogInformation($"methode Get de ControllerChampions appelée");
int nbChampions = await _dataManager.GetNbItems();
_logger.LogInformation($"Nombre de champions : {nbChampions}");
var champs = (await _dataManager.GetItemsByName(name, index, int.MaxValue))
.Where(champ => string.IsNullOrEmpty(name) || champ.Name.Contains(name, StringComparison.InvariantCultureIgnoreCase))
.Take(count)
.Select(Model => Model.toDTO());
var page = new ChampionPageDTO
{
Data = champs,
Index = index,
Count = champs.Count(),
TotalCount = nbChampions
};
return Ok(page);
}
[HttpGet("name")]

@ -1,33 +0,0 @@
//using Microsoft.AspNetCore.Mvc;
//namespace WebApiLol.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<> Get()
// {
// return Enumerable.Range(1, 5).Select(index => new WeatherForecast
// {
// Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
// TemperatureC = Random.Shared.Next(-20, 55),
// Summary = Summaries[Random.Shared.Next(Summaries.Length)]
// })
// .ToArray();
// }
//}
Loading…
Cancel
Save