diff --git a/Portfolio.Application/DependencyInjection.cs b/Portfolio.Application/DependencyInjection.cs index c64e9fa..8de8a9d 100644 --- a/Portfolio.Application/DependencyInjection.cs +++ b/Portfolio.Application/DependencyInjection.cs @@ -16,6 +16,8 @@ namespace Portfolio.Application services.AddScoped(); services.AddScoped(); + + return services; } } diff --git a/Portfolio.Application/Services/PokemonService/IPokemonNatureService.cs b/Portfolio.Application/Services/PokemonService/IPokemonNatureService.cs new file mode 100644 index 0000000..320f0b3 --- /dev/null +++ b/Portfolio.Application/Services/PokemonService/IPokemonNatureService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Application.Services.PokemonService +{ + public interface IPokemonNatureService + { + } +} diff --git a/Portfolio.Application/Services/PokemonService/IPokemonService.cs b/Portfolio.Application/Services/PokemonService/IPokemonService.cs index 9480cea..1cb4a16 100644 --- a/Portfolio.Application/Services/PokemonService/IPokemonService.cs +++ b/Portfolio.Application/Services/PokemonService/IPokemonService.cs @@ -9,6 +9,6 @@ namespace Portfolio.Application.Services.PokemonService { public interface IPokemonService { - List GetAllPokemon(); + Task> GetAllPokemonAsync(); } } diff --git a/Portfolio.Application/Services/PokemonService/IPokemonSubskillService.cs b/Portfolio.Application/Services/PokemonService/IPokemonSubskillService.cs new file mode 100644 index 0000000..09a73b9 --- /dev/null +++ b/Portfolio.Application/Services/PokemonService/IPokemonSubskillService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Application.Services.PokemonService +{ + public interface IPokemonSubskillService + { + } +} diff --git a/Portfolio.Application/Services/PokemonService/PokemonNatureService.cs b/Portfolio.Application/Services/PokemonService/PokemonNatureService.cs new file mode 100644 index 0000000..c4ee82b --- /dev/null +++ b/Portfolio.Application/Services/PokemonService/PokemonNatureService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Application.Services.PokemonService +{ + public class PokemonNatureService : IPokemonNatureService + { + } +} diff --git a/Portfolio.Application/Services/PokemonService/PokemonService.cs b/Portfolio.Application/Services/PokemonService/PokemonService.cs index a9a52ea..7258bec 100644 --- a/Portfolio.Application/Services/PokemonService/PokemonService.cs +++ b/Portfolio.Application/Services/PokemonService/PokemonService.cs @@ -10,38 +10,78 @@ namespace Portfolio.Application.Services.PokemonService { public class PokemonService : IPokemonService { - public List GetAllPokemon() + private readonly IPokemonRepository _pokemonRepository; + + public PokemonService(IPokemonRepository pokemonRepository) { - return new List() { + _pokemonRepository = pokemonRepository; + } + public async Task> GetAllPokemonAsync() + { + return await _pokemonRepository.GetAllPokemonsAsync(); + //return new List() { - new Pokemon - { - Id = 1, - PokemonId = "001", - PokemonName = "Bulbasaur", - SleepType = "Dozing", - Speciality = "Ingredients" + // new Pokemon + // { + // PokemonId = 1, + // PokemonName = "Bulbasaur", + // SleepType = "Dozing", + // Speciality = "Ingredients" - }, - new Pokemon - { - Id = 2, - PokemonId = "002", - PokemonName = "Ivysaur", - SleepType = "Dozing", - Speciality = "Ingredients" + // }, + // new Pokemon + // { + // PokemonId = 2, + // PokemonName = "Ivysaur", + // SleepType = "Dozing", + // Speciality = "Ingredients" - }, - new Pokemon - { - Id = 3, - PokemonId = "003", - PokemonName = "Venasaur", - SleepType = "Dozing", - Speciality = "Ingredients" + // }, + // new Pokemon + // { + // PokemonId = 3, + // PokemonName = "Venasaur", + // SleepType = "Dozing", + // Speciality = "Ingredients" - }, - }; + // }, + // new Pokemon + // { + // PokemonId = 37, + // PokemonName = "Vulpix", + // SleepType = "Snoozing", + // Speciality = "Berries" + + // }, + // new Pokemon + // { + // PokemonId = 38, + // PokemonName = "Ninetails", + // SleepType = "Snoozing", + // Speciality = "Berries" + + // }, + // new Pokemon + // { + // PokemonId = 37, + // PokemonName = "Vulpix", + // IsVariation = true, + // VariationName = "Alolan", + // SleepType = "Slumbering", + // Speciality = "Berries" + + // }, + // new Pokemon + // { + // PokemonId = 38, + // PokemonName = "Ninetails", + // IsVariation = true, + // VariationName = "Alolan", + // SleepType = "Slumbering", + // Speciality = "Berries" + + // }, + //}; } } } diff --git a/Portfolio.Application/Services/PokemonService/PokemonSubskillService.cs b/Portfolio.Application/Services/PokemonService/PokemonSubskillService.cs new file mode 100644 index 0000000..7af8653 --- /dev/null +++ b/Portfolio.Application/Services/PokemonService/PokemonSubskillService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Application.Services.PokemonService +{ + public class PokemonSubskillService : IPokemonSubskillService + { + } +} diff --git a/Portfolio.Domain/Features/Abstractions/Entity.cs b/Portfolio.Domain/Features/Abstractions/Entity.cs new file mode 100644 index 0000000..942e10c --- /dev/null +++ b/Portfolio.Domain/Features/Abstractions/Entity.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Domain.Features.Abstractions +{ + public abstract class Entity + { + public int Id { get; set; } + } +} diff --git a/Portfolio.Domain/Features/Articles/Article.cs b/Portfolio.Domain/Features/Articles/Article.cs index 8f8cf76..0587ed4 100644 --- a/Portfolio.Domain/Features/Articles/Article.cs +++ b/Portfolio.Domain/Features/Articles/Article.cs @@ -1,4 +1,5 @@ -using System; +using Portfolio.Domain.Features.Abstractions; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,9 +7,8 @@ using System.Threading.Tasks; namespace Portfolio.Domain.Features.Articles { - public class Article + public class Article : Entity { - public int Id { get; set; } public required string Title { get; set; } public string? Content { get; set; } public DateTime DatePublished { get; set; } = DateTime.Now; diff --git a/Portfolio.Domain/Features/Pokemon Natures/PokemonNatures.cs b/Portfolio.Domain/Features/Pokemon Natures/PokemonNatures.cs new file mode 100644 index 0000000..6b2f4c9 --- /dev/null +++ b/Portfolio.Domain/Features/Pokemon Natures/PokemonNatures.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Domain.Features.Pokemon_Natures +{ + public class PokemonNatures + { + public int Id { get; set; } + public string Nature { get; set; } + public int BerryRating { get; set; } + public int IngredientRating { get; set; } + public int SkillRating { get; set; } + } +} diff --git a/Portfolio.Domain/Features/Pokemon Subskills/PokemonSubskills.cs b/Portfolio.Domain/Features/Pokemon Subskills/PokemonSubskills.cs new file mode 100644 index 0000000..b0ac3cb --- /dev/null +++ b/Portfolio.Domain/Features/Pokemon Subskills/PokemonSubskills.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Domain.Features.Pokemon_Subskills +{ + public class PokemonSubskills + { + public int Id { get; set; } + public string SubSkill { get; set; } + public int BerryRank { get; set; } + public int IngredientRank { get; set; } + public int SkillRank { get; set; } + } +} diff --git a/Portfolio.Domain/Features/Pokemon/IPokemonRepository.cs b/Portfolio.Domain/Features/Pokemon/IPokemonRepository.cs new file mode 100644 index 0000000..48c89af --- /dev/null +++ b/Portfolio.Domain/Features/Pokemon/IPokemonRepository.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Domain.Features.Pokemon +{ + public interface IPokemonRepository + { + Task> GetAllPokemonsAsync(); + } +} diff --git a/Portfolio.Domain/Features/Pokemon/Pokemon.cs b/Portfolio.Domain/Features/Pokemon/Pokemon.cs index ed0ab65..3d64e51 100644 --- a/Portfolio.Domain/Features/Pokemon/Pokemon.cs +++ b/Portfolio.Domain/Features/Pokemon/Pokemon.cs @@ -1,4 +1,5 @@ -using System; +using Portfolio.Domain.Features.Abstractions; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,11 +7,12 @@ using System.Threading.Tasks; namespace Portfolio.Domain.Features.Pokemon { - public class Pokemon + public class Pokemon : Entity { - public int Id { get; set; } - public required string PokemonId { get; set; } + public int PokemonId { get; set; } public required string PokemonName { get; set; } + public bool IsVariation { get; set; } = false; + public string? VariationName { get; set; } public required string SleepType { get; set; } public required string Speciality { get; set; } diff --git a/Portfolio.Infrastructure/ApplicationDbContext.cs b/Portfolio.Infrastructure/ApplicationDbContext.cs new file mode 100644 index 0000000..ea6d221 --- /dev/null +++ b/Portfolio.Infrastructure/ApplicationDbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Portfolio.Domain.Features.Articles; +using Portfolio.Domain.Features.Pokemon; +using Portfolio.Domain.Features.Pokemon_Natures; +using Portfolio.Domain.Features.Pokemon_Subskills; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Infrastructure +{ + public class ApplicationDbContext : DbContext + { + public ApplicationDbContext(DbContextOptions options) :base(options) + { + + } + public DbSet Pokemons { get; set; } + public DbSet PokemonNatures { get; set; } + public DbSet PokemonSubskills { get; set; } + + } +} diff --git a/Portfolio.Infrastructure/DependencyInjection.cs b/Portfolio.Infrastructure/DependencyInjection.cs new file mode 100644 index 0000000..c109a9e --- /dev/null +++ b/Portfolio.Infrastructure/DependencyInjection.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Portfolio.Application.Services.Articles; +using Portfolio.Application.Services.PokemonService; +using Portfolio.Domain.Features.Pokemon; +using Portfolio.Infrastructure.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Infrastructure +{ + public static class DependencyInjection + { + public static IServiceCollection AddInfrastructure( this IServiceCollection services, IConfiguration configuration) + { + services.AddDbContext(options => + options.UseSqlServer(configuration.GetConnectionString("DefaultConnection") + )); + services.AddScoped(); + + return services; + } + } +} diff --git a/Portfolio.Infrastructure/Migrations/20250217210310_Initial.Designer.cs b/Portfolio.Infrastructure/Migrations/20250217210310_Initial.Designer.cs new file mode 100644 index 0000000..aa5e02d --- /dev/null +++ b/Portfolio.Infrastructure/Migrations/20250217210310_Initial.Designer.cs @@ -0,0 +1,116 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Portfolio.Infrastructure; + +#nullable disable + +namespace Portfolio.Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20250217210310_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon.Pokemon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsVariation") + .HasColumnType("bit"); + + b.Property("PokemonId") + .HasColumnType("int"); + + b.Property("PokemonName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SleepType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Speciality") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VariationName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Pokemons"); + }); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Natures.PokemonNatures", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BerryRating") + .HasColumnType("int"); + + b.Property("IngredientRating") + .HasColumnType("int"); + + b.Property("Nature") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SkillRating") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("PokemonNatures"); + }); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Subskills.PokemonSubskills", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BerryRank") + .HasColumnType("int"); + + b.Property("IngredientRank") + .HasColumnType("int"); + + b.Property("SkillRank") + .HasColumnType("int"); + + b.Property("SubSkill") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PokemonSubskills"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Portfolio.Infrastructure/Migrations/20250217210310_Initial.cs b/Portfolio.Infrastructure/Migrations/20250217210310_Initial.cs new file mode 100644 index 0000000..1a4e7f8 --- /dev/null +++ b/Portfolio.Infrastructure/Migrations/20250217210310_Initial.cs @@ -0,0 +1,77 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Portfolio.Infrastructure.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "PokemonNatures", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Nature = table.Column(type: "nvarchar(max)", nullable: false), + BerryRating = table.Column(type: "int", nullable: false), + IngredientRating = table.Column(type: "int", nullable: false), + SkillRating = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PokemonNatures", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Pokemons", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PokemonId = table.Column(type: "int", nullable: false), + PokemonName = table.Column(type: "nvarchar(max)", nullable: false), + IsVariation = table.Column(type: "bit", nullable: false), + VariationName = table.Column(type: "nvarchar(max)", nullable: false), + SleepType = table.Column(type: "nvarchar(max)", nullable: false), + Speciality = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Pokemons", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "PokemonSubskills", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SubSkill = table.Column(type: "nvarchar(max)", nullable: false), + BerryRank = table.Column(type: "int", nullable: false), + IngredientRank = table.Column(type: "int", nullable: false), + SkillRank = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PokemonSubskills", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PokemonNatures"); + + migrationBuilder.DropTable( + name: "Pokemons"); + + migrationBuilder.DropTable( + name: "PokemonSubskills"); + } + } +} diff --git a/Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.Designer.cs b/Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.Designer.cs new file mode 100644 index 0000000..908d585 --- /dev/null +++ b/Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.Designer.cs @@ -0,0 +1,115 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Portfolio.Infrastructure; + +#nullable disable + +namespace Portfolio.Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20250217212413_UpdatedPokemonClass")] + partial class UpdatedPokemonClass + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon.Pokemon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsVariation") + .HasColumnType("bit"); + + b.Property("PokemonId") + .HasColumnType("int"); + + b.Property("PokemonName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SleepType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Speciality") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VariationName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Pokemons"); + }); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Natures.PokemonNatures", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BerryRating") + .HasColumnType("int"); + + b.Property("IngredientRating") + .HasColumnType("int"); + + b.Property("Nature") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SkillRating") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("PokemonNatures"); + }); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Subskills.PokemonSubskills", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BerryRank") + .HasColumnType("int"); + + b.Property("IngredientRank") + .HasColumnType("int"); + + b.Property("SkillRank") + .HasColumnType("int"); + + b.Property("SubSkill") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PokemonSubskills"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.cs b/Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.cs new file mode 100644 index 0000000..d036ac4 --- /dev/null +++ b/Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Portfolio.Infrastructure.Migrations +{ + /// + public partial class UpdatedPokemonClass : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "VariationName", + table: "Pokemons", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "VariationName", + table: "Pokemons", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + } + } +} diff --git a/Portfolio.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs b/Portfolio.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs new file mode 100644 index 0000000..93ef60a --- /dev/null +++ b/Portfolio.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs @@ -0,0 +1,112 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Portfolio.Infrastructure; + +#nullable disable + +namespace Portfolio.Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + partial class ApplicationDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon.Pokemon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsVariation") + .HasColumnType("bit"); + + b.Property("PokemonId") + .HasColumnType("int"); + + b.Property("PokemonName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SleepType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Speciality") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VariationName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Pokemons"); + }); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Natures.PokemonNatures", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BerryRating") + .HasColumnType("int"); + + b.Property("IngredientRating") + .HasColumnType("int"); + + b.Property("Nature") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SkillRating") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("PokemonNatures"); + }); + + modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Subskills.PokemonSubskills", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BerryRank") + .HasColumnType("int"); + + b.Property("IngredientRank") + .HasColumnType("int"); + + b.Property("SkillRank") + .HasColumnType("int"); + + b.Property("SubSkill") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("PokemonSubskills"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Portfolio.Infrastructure/Portfolio.Infrastructure.csproj b/Portfolio.Infrastructure/Portfolio.Infrastructure.csproj new file mode 100644 index 0000000..20ed18b --- /dev/null +++ b/Portfolio.Infrastructure/Portfolio.Infrastructure.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/Portfolio.Infrastructure/Repositories/PokemonRepository.cs b/Portfolio.Infrastructure/Repositories/PokemonRepository.cs new file mode 100644 index 0000000..ac893cf --- /dev/null +++ b/Portfolio.Infrastructure/Repositories/PokemonRepository.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Portfolio.Domain.Features.Pokemon; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Portfolio.Infrastructure.Repositories +{ + public class PokemonRepository : IPokemonRepository + { + private readonly ApplicationDbContext _context; + + public PokemonRepository(ApplicationDbContext context) + { + _context = context; + } + + public async Task> GetAllPokemonsAsync() + { + return await _context.Pokemons.ToListAsync(); + } + } +} diff --git a/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor b/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor index d24bcca..80d5e73 100644 --- a/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor +++ b/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor @@ -74,14 +74,14 @@ else } @code { - private List pokemons; + private List pokemons = new List(); protected override async Task OnInitializedAsync() { // Simulate asynchronous loading to demonstrate streaming rendering await Task.Delay(500); - var result = PokemonService.GetAllPokemon(); + var result = await PokemonService.GetAllPokemonAsync(); if (result is not null) { pokemons = result; diff --git a/Portfolio.WebUI.Server/Portfolio.WebUI.Server.csproj b/Portfolio.WebUI.Server/Portfolio.WebUI.Server.csproj index d61bb2c..d5ebdac 100644 --- a/Portfolio.WebUI.Server/Portfolio.WebUI.Server.csproj +++ b/Portfolio.WebUI.Server/Portfolio.WebUI.Server.csproj @@ -7,7 +7,14 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/Portfolio.WebUI.Server/Program.cs b/Portfolio.WebUI.Server/Program.cs index c7f2c82..0369665 100644 --- a/Portfolio.WebUI.Server/Program.cs +++ b/Portfolio.WebUI.Server/Program.cs @@ -1,5 +1,6 @@ using Portfolio.WebUI.Server.Components; using Portfolio.Application; +using Portfolio.Infrastructure; var builder = WebApplication.CreateBuilder(args); @@ -7,6 +8,7 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorComponents(); builder.Services.AddApplication(); +builder.Services.AddInfrastructure(builder.Configuration); var app = builder.Build(); diff --git a/Portfolio.WebUI.Server/appsettings.json b/Portfolio.WebUI.Server/appsettings.json index 10f68b8..c779e73 100644 --- a/Portfolio.WebUI.Server/appsettings.json +++ b/Portfolio.WebUI.Server/appsettings.json @@ -1,4 +1,7 @@ { + "ConnectionStrings": { + "DefaultConnection": "Server=(localdb)\\MSSQLFishbowlDB;Database=Profile;Trusted_Connection=True;TrustServerCertificate=True" + }, "Logging": { "LogLevel": { "Default": "Information", diff --git a/Portfolio.sln b/Portfolio.sln index bfb8575..c25cc9b 100644 --- a/Portfolio.sln +++ b/Portfolio.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portfolio.Domain", "Portfol EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portfolio.Application", "Portfolio.Application\Portfolio.Application.csproj", "{24C9C19A-22CE-4E7B-A393-7423A471513E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portfolio.Infrastructure", "Portfolio.Infrastructure\Portfolio.Infrastructure.csproj", "{3B017B4C-B917-40DA-8429-3DBD1300FC06}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,6 +31,10 @@ Global {24C9C19A-22CE-4E7B-A393-7423A471513E}.Debug|Any CPU.Build.0 = Debug|Any CPU {24C9C19A-22CE-4E7B-A393-7423A471513E}.Release|Any CPU.ActiveCfg = Release|Any CPU {24C9C19A-22CE-4E7B-A393-7423A471513E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B017B4C-B917-40DA-8429-3DBD1300FC06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B017B4C-B917-40DA-8429-3DBD1300FC06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B017B4C-B917-40DA-8429-3DBD1300FC06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B017B4C-B917-40DA-8429-3DBD1300FC06}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -37,6 +43,7 @@ Global {334A4A79-9DF9-4FAD-9B06-B2FA02443620} = {491A0B76-7D94-42C5-BD6B-F90036F33A04} {48065C06-C40E-4A69-B013-8DF2D266D7CF} = {491A0B76-7D94-42C5-BD6B-F90036F33A04} {24C9C19A-22CE-4E7B-A393-7423A471513E} = {491A0B76-7D94-42C5-BD6B-F90036F33A04} + {3B017B4C-B917-40DA-8429-3DBD1300FC06} = {491A0B76-7D94-42C5-BD6B-F90036F33A04} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9BE77343-6369-422B-B64A-32CF27B8D257}