Started on EF DB; going to split from video to branch onto pulling information as was in previous project
This commit is contained in:
parent
27aafdd46e
commit
1918ebbafd
|
@ -16,6 +16,8 @@ namespace Portfolio.Application
|
||||||
services.AddScoped<IArticleService, ArticleService>();
|
services.AddScoped<IArticleService, ArticleService>();
|
||||||
services.AddScoped<IPokemonService, PokemonService>();
|
services.AddScoped<IPokemonService, PokemonService>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,6 @@ namespace Portfolio.Application.Services.PokemonService
|
||||||
{
|
{
|
||||||
public interface IPokemonService
|
public interface IPokemonService
|
||||||
{
|
{
|
||||||
List<Pokemon> GetAllPokemon();
|
Task<List<Pokemon>> GetAllPokemonAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,38 +10,78 @@ namespace Portfolio.Application.Services.PokemonService
|
||||||
{
|
{
|
||||||
public class PokemonService : IPokemonService
|
public class PokemonService : IPokemonService
|
||||||
{
|
{
|
||||||
public List<Pokemon> GetAllPokemon()
|
private readonly IPokemonRepository _pokemonRepository;
|
||||||
|
|
||||||
|
public PokemonService(IPokemonRepository pokemonRepository)
|
||||||
{
|
{
|
||||||
return new List<Pokemon>() {
|
_pokemonRepository = pokemonRepository;
|
||||||
|
}
|
||||||
|
public async Task<List<Pokemon>> GetAllPokemonAsync()
|
||||||
|
{
|
||||||
|
return await _pokemonRepository.GetAllPokemonsAsync();
|
||||||
|
//return new List<Pokemon>() {
|
||||||
|
|
||||||
new Pokemon
|
// new Pokemon
|
||||||
{
|
// {
|
||||||
Id = 1,
|
// PokemonId = 1,
|
||||||
PokemonId = "001",
|
// PokemonName = "Bulbasaur",
|
||||||
PokemonName = "Bulbasaur",
|
// SleepType = "Dozing",
|
||||||
SleepType = "Dozing",
|
// Speciality = "Ingredients"
|
||||||
Speciality = "Ingredients"
|
|
||||||
|
|
||||||
},
|
// },
|
||||||
new Pokemon
|
// new Pokemon
|
||||||
{
|
// {
|
||||||
Id = 2,
|
// PokemonId = 2,
|
||||||
PokemonId = "002",
|
// PokemonName = "Ivysaur",
|
||||||
PokemonName = "Ivysaur",
|
// SleepType = "Dozing",
|
||||||
SleepType = "Dozing",
|
// Speciality = "Ingredients"
|
||||||
Speciality = "Ingredients"
|
|
||||||
|
|
||||||
},
|
// },
|
||||||
new Pokemon
|
// new Pokemon
|
||||||
{
|
// {
|
||||||
Id = 3,
|
// PokemonId = 3,
|
||||||
PokemonId = "003",
|
// PokemonName = "Venasaur",
|
||||||
PokemonName = "Venasaur",
|
// SleepType = "Dozing",
|
||||||
SleepType = "Dozing",
|
// Speciality = "Ingredients"
|
||||||
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"
|
||||||
|
|
||||||
|
// },
|
||||||
|
//};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using Portfolio.Domain.Features.Abstractions;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -6,9 +7,8 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Portfolio.Domain.Features.Articles
|
namespace Portfolio.Domain.Features.Articles
|
||||||
{
|
{
|
||||||
public class Article
|
public class Article : Entity
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
public required string Title { get; set; }
|
public required string Title { get; set; }
|
||||||
public string? Content { get; set; }
|
public string? Content { get; set; }
|
||||||
public DateTime DatePublished { get; set; } = DateTime.Now;
|
public DateTime DatePublished { get; set; } = DateTime.Now;
|
||||||
|
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<List<Pokemon>> GetAllPokemonsAsync();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using Portfolio.Domain.Features.Abstractions;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -6,11 +7,12 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Portfolio.Domain.Features.Pokemon
|
namespace Portfolio.Domain.Features.Pokemon
|
||||||
{
|
{
|
||||||
public class Pokemon
|
public class Pokemon : Entity
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int PokemonId { get; set; }
|
||||||
public required string PokemonId { get; set; }
|
|
||||||
public required string PokemonName { 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 SleepType { get; set; }
|
||||||
public required string Speciality { get; set; }
|
public required string Speciality { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -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<Pokemon> Pokemons { get; set; }
|
||||||
|
public DbSet<PokemonNatures> PokemonNatures { get; set; }
|
||||||
|
public DbSet<PokemonSubskills> PokemonSubskills { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<ApplicationDbContext>(options =>
|
||||||
|
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")
|
||||||
|
));
|
||||||
|
services.AddScoped<IPokemonRepository, PokemonRepository>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
// <auto-generated />
|
||||||
|
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
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
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<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("IsVariation")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<int>("PokemonId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("PokemonName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SleepType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Speciality")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("VariationName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Pokemons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Natures.PokemonNatures", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BerryRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("IngredientRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Nature")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SkillRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PokemonNatures");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Subskills.PokemonSubskills", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BerryRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("IngredientRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SkillRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("SubSkill")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PokemonSubskills");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Portfolio.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Initial : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PokemonNatures",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Nature = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
BerryRating = table.Column<int>(type: "int", nullable: false),
|
||||||
|
IngredientRating = table.Column<int>(type: "int", nullable: false),
|
||||||
|
SkillRating = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PokemonNatures", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Pokemons",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
PokemonId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
PokemonName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
IsVariation = table.Column<bool>(type: "bit", nullable: false),
|
||||||
|
VariationName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
SleepType = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Speciality = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Pokemons", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PokemonSubskills",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
SubSkill = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
BerryRank = table.Column<int>(type: "int", nullable: false),
|
||||||
|
IngredientRank = table.Column<int>(type: "int", nullable: false),
|
||||||
|
SkillRank = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PokemonSubskills", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PokemonNatures");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Pokemons");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PokemonSubskills");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
115
Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.Designer.cs
generated
Normal file
115
Portfolio.Infrastructure/Migrations/20250217212413_UpdatedPokemonClass.Designer.cs
generated
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
// <auto-generated />
|
||||||
|
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
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
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<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("IsVariation")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<int>("PokemonId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("PokemonName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SleepType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Speciality")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("VariationName")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Pokemons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Natures.PokemonNatures", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BerryRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("IngredientRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Nature")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SkillRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PokemonNatures");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Subskills.PokemonSubskills", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BerryRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("IngredientRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SkillRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("SubSkill")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PokemonSubskills");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Portfolio.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class UpdatedPokemonClass : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "VariationName",
|
||||||
|
table: "Pokemons",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "nvarchar(max)");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "VariationName",
|
||||||
|
table: "Pokemons",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "nvarchar(max)",
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
// <auto-generated />
|
||||||
|
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<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("IsVariation")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<int>("PokemonId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("PokemonName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("SleepType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Speciality")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("VariationName")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Pokemons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Natures.PokemonNatures", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BerryRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("IngredientRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Nature")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SkillRating")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PokemonNatures");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Portfolio.Domain.Features.Pokemon_Subskills.PokemonSubskills", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BerryRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("IngredientRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SkillRank")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("SubSkill")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PokemonSubskills");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Portfolio.Application\Portfolio.Application.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -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<List<Pokemon>> GetAllPokemonsAsync()
|
||||||
|
{
|
||||||
|
return await _context.Pokemons.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,14 +74,14 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Pokemon> pokemons;
|
private List<Pokemon> pokemons = new List<Pokemon>();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
// Simulate asynchronous loading to demonstrate streaming rendering
|
// Simulate asynchronous loading to demonstrate streaming rendering
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
|
|
||||||
var result = PokemonService.GetAllPokemon();
|
var result = await PokemonService.GetAllPokemonAsync();
|
||||||
if (result is not null)
|
if (result is not null)
|
||||||
{
|
{
|
||||||
pokemons = result;
|
pokemons = result;
|
||||||
|
|
|
@ -7,7 +7,14 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Portfolio.Application\Portfolio.Application.csproj" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Portfolio.Infrastructure\Portfolio.Infrastructure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Portfolio.WebUI.Server.Components;
|
using Portfolio.WebUI.Server.Components;
|
||||||
using Portfolio.Application;
|
using Portfolio.Application;
|
||||||
|
using Portfolio.Infrastructure;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
@ -7,6 +8,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddRazorComponents();
|
builder.Services.AddRazorComponents();
|
||||||
|
|
||||||
builder.Services.AddApplication();
|
builder.Services.AddApplication();
|
||||||
|
builder.Services.AddInfrastructure(builder.Configuration);
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"DefaultConnection": "Server=(localdb)\\MSSQLFishbowlDB;Database=Profile;Trusted_Connection=True;TrustServerCertificate=True"
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
|
|
|
@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portfolio.Domain", "Portfol
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portfolio.Application", "Portfolio.Application\Portfolio.Application.csproj", "{24C9C19A-22CE-4E7B-A393-7423A471513E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portfolio.Application", "Portfolio.Application\Portfolio.Application.csproj", "{24C9C19A-22CE-4E7B-A393-7423A471513E}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portfolio.Infrastructure", "Portfolio.Infrastructure\Portfolio.Infrastructure.csproj", "{3B017B4C-B917-40DA-8429-3DBD1300FC06}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{24C9C19A-22CE-4E7B-A393-7423A471513E}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -37,6 +43,7 @@ Global
|
||||||
{334A4A79-9DF9-4FAD-9B06-B2FA02443620} = {491A0B76-7D94-42C5-BD6B-F90036F33A04}
|
{334A4A79-9DF9-4FAD-9B06-B2FA02443620} = {491A0B76-7D94-42C5-BD6B-F90036F33A04}
|
||||||
{48065C06-C40E-4A69-B013-8DF2D266D7CF} = {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}
|
{24C9C19A-22CE-4E7B-A393-7423A471513E} = {491A0B76-7D94-42C5-BD6B-F90036F33A04}
|
||||||
|
{3B017B4C-B917-40DA-8429-3DBD1300FC06} = {491A0B76-7D94-42C5-BD6B-F90036F33A04}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {9BE77343-6369-422B-B64A-32CF27B8D257}
|
SolutionGuid = {9BE77343-6369-422B-B64A-32CF27B8D257}
|
||||||
|
|
Loading…
Reference in New Issue