diff --git a/barkmanAPI/Migrations/20250109192017_InitialCreate.Designer.cs b/barkmanAPI/Migrations/20250109192017_InitialCreate.Designer.cs
deleted file mode 100644
index 8317692..0000000
--- a/barkmanAPI/Migrations/20250109192017_InitialCreate.Designer.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace barkmanapi.Migrations
-{
- [DbContext(typeof(BarkContext))]
- [Migration("20250109192017_InitialCreate")]
- partial class InitialCreate
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
-
- modelBuilder.Entity("InventoryItems", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Brand")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Notes")
- .HasColumnType("TEXT");
-
- b.Property("RentalPrice")
- .HasColumnType("REAL");
-
- b.Property("ReplacementCost")
- .HasColumnType("REAL");
-
- b.Property("SerialNumber")
- .HasColumnType("TEXT");
-
- b.Property("Status")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Inventory");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/barkmanAPI/Migrations/20250109192017_InitialCreate.cs b/barkmanAPI/Migrations/20250109192017_InitialCreate.cs
deleted file mode 100644
index eac0eca..0000000
--- a/barkmanAPI/Migrations/20250109192017_InitialCreate.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace barkmanapi.Migrations
-{
- ///
- public partial class InitialCreate : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Inventory",
- columns: table => new
- {
- Id = table.Column(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Name = table.Column(type: "TEXT", nullable: false),
- Brand = table.Column(type: "TEXT", nullable: false),
- SerialNumber = table.Column(type: "TEXT", nullable: true),
- Status = table.Column(type: "TEXT", nullable: true),
- RentalPrice = table.Column(type: "REAL", nullable: true),
- ReplacementCost = table.Column(type: "REAL", nullable: true),
- Notes = table.Column(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Inventory", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Inventory");
- }
- }
-}
diff --git a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs b/barkmanAPI/Migrations/BarkContextModelSnapshot.cs
deleted file mode 100644
index cdf858a..0000000
--- a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-//
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace barkmanapi.Migrations
-{
- [DbContext(typeof(BarkContext))]
- partial class BarkContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
-
- modelBuilder.Entity("InventoryItems", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Brand")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Notes")
- .HasColumnType("TEXT");
-
- b.Property("RentalPrice")
- .HasColumnType("REAL");
-
- b.Property("ReplacementCost")
- .HasColumnType("REAL");
-
- b.Property("SerialNumber")
- .HasColumnType("TEXT");
-
- b.Property("Status")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Inventory");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs
index ebf25cd..6c46e45 100644
--- a/barkmanAPI/Program.cs
+++ b/barkmanAPI/Program.cs
@@ -1,3 +1,4 @@
+using barkmanapi;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
@@ -20,6 +21,9 @@ builder.Services.AddCors(options =>
policy.WithOrigins("https://barkdev.ts.drewr.io", "http://localhost:5173").AllowAnyMethod().AllowAnyHeader();
});
});
+builder.Services.AddDbContext(opt =>
+ opt.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")).UseSnakeCaseNamingConvention());
+
var app = builder.Build();
if (!app.Environment.IsProduction())
@@ -34,7 +38,7 @@ if (!app.Environment.IsProduction())
app.MapGet("/", () => "Hello World!");
app.MapGet("/inventory", async (BarkContext db) =>
- await db.Inventory.ToListAsync());
+ await db.Inventory.OrderBy(item=>item.Id).ToListAsync());
app.MapGet("/inventory/{id}", async (int id, BarkContext db) =>
{
diff --git a/barkmanAPI/barkDbModel.cs b/barkmanAPI/barkDbModel.cs
index 84799d7..88b538c 100644
--- a/barkmanAPI/barkDbModel.cs
+++ b/barkmanAPI/barkDbModel.cs
@@ -1,24 +1,10 @@
using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-public class BarkContext : DbContext
+namespace barkmanapi;
+
+public class BarkContext(DbContextOptions options) : DbContext(options)
{
public DbSet Inventory { get; set; }
-
- public string DbPath { get; }
-
- public BarkContext()
- {
- var folder = Environment.SpecialFolder.LocalApplicationData;
- var path = Environment.GetFolderPath(folder);
- DbPath = "./database/app.db";
- }
-
- // The following configures EF to create a Sqlite database file in the
- // special "local" folder for your platform.
- protected override void OnConfiguring(DbContextOptionsBuilder options)
- => options.UseSqlite($"Data Source={DbPath}");
}
public class InventoryItems
@@ -31,5 +17,4 @@ public class InventoryItems
public float? RentalPrice { get; set; }
public float? ReplacementCost { get; set; }
public string? Notes { get; set; }
-}
-
+}
\ No newline at end of file
diff --git a/barkmanAPI/barkmanapi.csproj b/barkmanAPI/barkmanapi.csproj
index 7b95621..fa775f1 100644
--- a/barkmanAPI/barkmanapi.csproj
+++ b/barkmanAPI/barkmanapi.csproj
@@ -5,15 +5,17 @@
enable
enable
Linux
+ a965d65f-8c78-4549-9c7c-8c4d221a8a02
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
diff --git a/barkmanui/.env b/barkmanui/.env
index 29a2dbd..c62e21a 100644
--- a/barkmanui/.env
+++ b/barkmanui/.env
@@ -1 +1 @@
-VITE_API_URL=https://barkdev.ts.drewr.io
\ No newline at end of file
+VITE_API_URL=http://localhost:5145
\ No newline at end of file