diff --git a/Sources/APILOL/Program.cs b/Sources/APILOL/Program.cs index 48863a6..440cdf0 100644 --- a/Sources/APILOL/Program.cs +++ b/Sources/APILOL/Program.cs @@ -1,7 +1,10 @@ +using Model; +using StubLib; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. - +builder.Services.AddSingleton(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); diff --git a/Sources/ChampionControllerTest.cs b/Sources/ChampionControllerTest.cs new file mode 100644 index 0000000..e69de29 diff --git a/Sources/EntityFrameworkLOL/ChampionContext.cs b/Sources/EntityFrameworkLOL/DBContexts/ChampionContext.cs similarity index 52% rename from Sources/EntityFrameworkLOL/ChampionContext.cs rename to Sources/EntityFrameworkLOL/DBContexts/ChampionContext.cs index 719926b..f7d3a11 100644 --- a/Sources/EntityFrameworkLOL/ChampionContext.cs +++ b/Sources/EntityFrameworkLOL/DBContexts/ChampionContext.cs @@ -1,10 +1,11 @@ -using Microsoft.EntityFrameworkCore; +using EntityFrameworkLOL.Entities; +using Microsoft.EntityFrameworkCore; -namespace EntityFrameworkLOL +namespace EntityFrameworkLOL.DBContexts { class ChampionContext : DbContext { - public DbSet Champions { get; set; } + public DbSet Champion { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseSqlite($"Data Source=DBLOL.db"); diff --git a/Sources/EntityFrameworkLOL/DBContexts/RuneContext.cs b/Sources/EntityFrameworkLOL/DBContexts/RuneContext.cs new file mode 100644 index 0000000..daa69f9 --- /dev/null +++ b/Sources/EntityFrameworkLOL/DBContexts/RuneContext.cs @@ -0,0 +1,13 @@ +using EntityFrameworkLOL.Entities; +using Microsoft.EntityFrameworkCore; + +namespace EntityFrameworkLOL.DBContexts +{ + class RuneContext : DbContext + { + public DbSet Rune { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => options.UseSqlite($"Data Source=DBLOL.db"); + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs new file mode 100644 index 0000000..8c31903 --- /dev/null +++ b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs @@ -0,0 +1,15 @@ +using EntityFrameworkLOL.Entities; +using Microsoft.EntityFrameworkCore; + +namespace EntityFrameworkLOL.DBContexts +{ + class SQLiteContext : DbContext + { + /*public DbSet Champion { get; set; } + public DbSet Skin { get; set; }*/ + public DbSet Rune { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => options.UseSqlite($"Data Source=DBLOL.db"); + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBContexts/SkinContext.cs b/Sources/EntityFrameworkLOL/DBContexts/SkinContext.cs new file mode 100644 index 0000000..5628c53 --- /dev/null +++ b/Sources/EntityFrameworkLOL/DBContexts/SkinContext.cs @@ -0,0 +1,13 @@ +using EntityFrameworkLOL.Entities; +using Microsoft.EntityFrameworkCore; + +namespace EntityFrameworkLOL.DBContexts +{ + class SkinContext : DbContext + { + public DbSet Skin { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => options.UseSqlite($"Data Source=DBLOL.db"); + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBLOL.db b/Sources/EntityFrameworkLOL/DBLOL.db index 6e8e7c5..e1ce9c7 100644 Binary files a/Sources/EntityFrameworkLOL/DBLOL.db and b/Sources/EntityFrameworkLOL/DBLOL.db differ diff --git a/Sources/EntityFrameworkLOL/ChampionEntity.cs b/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs similarity index 85% rename from Sources/EntityFrameworkLOL/ChampionEntity.cs rename to Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs index f693c37..fcc602e 100644 --- a/Sources/EntityFrameworkLOL/ChampionEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs @@ -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 { diff --git a/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs new file mode 100644 index 0000000..7ceb423 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs @@ -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; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs b/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs new file mode 100644 index 0000000..9412f33 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs @@ -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; }*/ + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.DBLOL.db b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.DBLOL.db deleted file mode 100644 index e40710c..0000000 Binary files a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.DBLOL.db and /dev/null differ diff --git a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj index 26d60a1..bb493f8 100644 --- a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj +++ b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj @@ -21,4 +21,8 @@ + + + + \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.Designer.cs b/Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.Designer.cs similarity index 64% rename from Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.Designer.cs rename to Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.Designer.cs index e24c7dc..da7a0e3 100644 --- a/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.Designer.cs +++ b/Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.Designer.cs @@ -1,5 +1,5 @@ // -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 { /// 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("Name") .HasColumnType("TEXT"); - b.Property("Bio") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Icon") + b.Property("Description") .IsRequired() .HasColumnType("TEXT"); b.HasKey("Name"); - b.ToTable("Champions"); + b.ToTable("Rune"); }); #pragma warning restore 612, 618 } diff --git a/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.cs b/Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.cs similarity index 66% rename from Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.cs rename to Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.cs index eb2dfc8..0150ec7 100644 --- a/Sources/EntityFrameworkLOL/Migrations/20230201163336_MigrationWallah.cs +++ b/Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.cs @@ -5,22 +5,21 @@ namespace EntityFrameworkLOL.Migrations { /// - public partial class MigrationWallah : Migration + public partial class MigrationWallah2 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "Champions", + name: "Rune", columns: table => new { Name = table.Column(type: "TEXT", nullable: false), - Bio = table.Column(type: "TEXT", nullable: false), - Icon = table.Column(type: "TEXT", nullable: false) + Description = table.Column(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"); } } } diff --git a/Sources/EntityFrameworkLOL/Migrations/ChampionContextModelSnapshot.cs b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs similarity index 63% rename from Sources/EntityFrameworkLOL/Migrations/ChampionContextModelSnapshot.cs rename to Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs index 351bf79..59fd766 100644 --- a/Sources/EntityFrameworkLOL/Migrations/ChampionContextModelSnapshot.cs +++ b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs @@ -1,5 +1,5 @@ // -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("Name") .HasColumnType("TEXT"); - b.Property("Bio") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Icon") + b.Property("Description") .IsRequired() .HasColumnType("TEXT"); b.HasKey("Name"); - b.ToTable("Champions"); + b.ToTable("Rune"); }); #pragma warning restore 612, 618 } diff --git a/Sources/StubLib/StubData.Champions.cs b/Sources/StubLib/StubData.Champions.cs index ad19275..8df8028 100644 --- a/Sources/StubLib/StubData.Champions.cs +++ b/Sources/StubLib/StubData.Champions.cs @@ -96,5 +96,4 @@ namespace StubLib => parent.champions.UpdateItem(oldItem, newItem); } } -} - +} \ No newline at end of file