Reusable db stuff??

This commit is contained in:
Lani Aung
2024-09-15 21:59:05 -06:00
parent 009efc4643
commit c805414cab
28 changed files with 71 additions and 32 deletions
@@ -1,6 +1,6 @@
@page "/"
<PageTitle>Home</PageTitle>
<PageTitle>Kisekae</PageTitle>
<h1>Hello, world!</h1>
+3
View File
@@ -1,10 +1,13 @@
using fxl.codes.kisekae.blazor.Components;
using fxl.codes.kisekae.data;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddDbContextFactory<KisekaeContext>(options => { options.UseNpgsql(builder.Configuration.GetConnectionString("kisekae")); });
var app = builder.Build();
+4 -1
View File
@@ -5,5 +5,8 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
"kisekae": ""
}
}
@@ -6,4 +6,18 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Npgsql" Version="8.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\fxl.codes.kisekae.data\fxl.codes.kisekae.data.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
</Project>
@@ -1,4 +1,4 @@
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class Action
{
@@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class Cel
{
@@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class CelConfig
{
@@ -1,4 +1,4 @@
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class CelPosition
{
@@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class Configuration
{
@@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class Kisekae
{
@@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class Palette
{
@@ -1,4 +1,4 @@
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class PaletteColor
{
@@ -1,4 +1,4 @@
namespace fxl.codes.kisekae.Entities
namespace fxl.codes.kisekae.data.Entities
{
public class Render
{
@@ -1,7 +1,7 @@
using fxl.codes.kisekae.Entities;
using fxl.codes.kisekae.data.Entities;
using Microsoft.EntityFrameworkCore;
namespace fxl.codes.kisekae
namespace fxl.codes.kisekae.data
{
public class KisekaeContext : DbContext
{
@@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using fxl.codes.kisekae;
using fxl.codes.kisekae.data;
#nullable disable
@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using fxl.codes.kisekae;
using fxl.codes.kisekae.data;
#nullable disable
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Npgsql" Version="8.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
</ItemGroup>
</Project>
+6
View File
@@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fxl.codes.kisekae", "fxl.co
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fxl.codes.kisekae.blazor", "fxl.codes.kisekae.blazor\fxl.codes.kisekae.blazor.csproj", "{57F7E699-41A9-4312-9877-DEAC8C2E1F2E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fxl.codes.kisekae.data", "fxl.codes.kisekae.data\fxl.codes.kisekae.data.csproj", "{A977AF77-5A7F-4DDA-8113-3367EE9920BB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
{57F7E699-41A9-4312-9877-DEAC8C2E1F2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57F7E699-41A9-4312-9877-DEAC8C2E1F2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57F7E699-41A9-4312-9877-DEAC8C2E1F2E}.Release|Any CPU.Build.0 = Release|Any CPU
{A977AF77-5A7F-4DDA-8113-3367EE9920BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A977AF77-5A7F-4DDA-8113-3367EE9920BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A977AF77-5A7F-4DDA-8113-3367EE9920BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A977AF77-5A7F-4DDA-8113-3367EE9920BB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+1 -1
View File
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using fxl.codes.kisekae.Entities;
using fxl.codes.kisekae.data.Entities;
namespace fxl.codes.kisekae.Models
{
+1 -1
View File
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using fxl.codes.kisekae.Entities;
using fxl.codes.kisekae.data.Entities;
namespace fxl.codes.kisekae.Models
{
+1 -1
View File
@@ -1,6 +1,6 @@
using System.Linq;
using System.Text.Json.Serialization;
using fxl.codes.kisekae.Entities;
using fxl.codes.kisekae.data.Entities;
namespace fxl.codes.kisekae.Models;
+1 -1
View File
@@ -1,4 +1,4 @@
using fxl.codes.kisekae;
using fxl.codes.kisekae.data;
using fxl.codes.kisekae.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using fxl.codes.kisekae.Entities;
using fxl.codes.kisekae.data.Entities;
using Microsoft.Extensions.Logging;
namespace fxl.codes.kisekae.Services;
@@ -6,12 +6,13 @@ using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using fxl.codes.kisekae.Entities;
using fxl.codes.kisekae.data;
using fxl.codes.kisekae.data.Entities;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using SixLabors.ImageSharp;
using Configuration = fxl.codes.kisekae.Entities.Configuration;
using Configuration = fxl.codes.kisekae.data.Entities.Configuration;
namespace fxl.codes.kisekae.Services;
@@ -6,7 +6,7 @@ using System.IO.IsolatedStorage;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using fxl.codes.kisekae.Entities;
using fxl.codes.kisekae.data.Entities;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using SixLabors.ImageSharp;
+2 -1
View File
@@ -1,4 +1,5 @@
@model IEnumerable<KisekaeModel>
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model IEnumerable<KisekaeModel>
@{
ViewData["Title"] = "Select";
@@ -30,4 +30,8 @@
<ItemGroup>
<None Remove="Scripts\fabric.min.js"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\fxl.codes.kisekae.data\fxl.codes.kisekae.data.csproj" />
</ItemGroup>
</Project>