mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-06-12 22:11:54 +00:00
more status
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using barkmanapi;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace barkmanapi.Migrations
|
||||
{
|
||||
[DbContext(typeof(BarkContext))]
|
||||
[Migration("20250124005211_statuspt2")]
|
||||
partial class statuspt2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.1")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("barkmanapi.InventoryItems", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Brand")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("brand");
|
||||
|
||||
b.Property<string>("ItemStatusId")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("item_status_id");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.Property<string>("Notes")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("notes");
|
||||
|
||||
b.Property<float?>("RentalPrice")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("rental_price");
|
||||
|
||||
b.Property<float?>("ReplacementCost")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("replacement_cost");
|
||||
|
||||
b.Property<string>("SerialNumber")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("serial_number");
|
||||
|
||||
b.Property<string>("StatusId")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("status_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_inventory");
|
||||
|
||||
b.HasIndex("ItemStatusId")
|
||||
.HasDatabaseName("ix_inventory_item_status_id");
|
||||
|
||||
b.ToTable("inventory", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("barkmanapi.ItemStatus", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_item_status");
|
||||
|
||||
b.ToTable("item_status", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("barkmanapi.InventoryItems", b =>
|
||||
{
|
||||
b.HasOne("barkmanapi.ItemStatus", null)
|
||||
.WithMany("Items")
|
||||
.HasForeignKey("ItemStatusId")
|
||||
.HasConstraintName("fk_inventory_item_status_item_status_id");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("barkmanapi.ItemStatus", b =>
|
||||
{
|
||||
b.Navigation("Items");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace barkmanapi.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class statuspt2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "status",
|
||||
table: "inventory",
|
||||
newName: "status_id");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "item_status_id",
|
||||
table: "inventory",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_inventory_item_status_id",
|
||||
table: "inventory",
|
||||
column: "item_status_id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_inventory_item_status_item_status_id",
|
||||
table: "inventory",
|
||||
column: "item_status_id",
|
||||
principalTable: "item_status",
|
||||
principalColumn: "id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_inventory_item_status_item_status_id",
|
||||
table: "inventory");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_inventory_item_status_id",
|
||||
table: "inventory");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "item_status_id",
|
||||
table: "inventory");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "status_id",
|
||||
table: "inventory",
|
||||
newName: "status");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,10 @@ namespace barkmanapi.Migrations
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("brand");
|
||||
|
||||
b.Property<string>("ItemStatusId")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("item_status_id");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
@@ -56,13 +60,16 @@ namespace barkmanapi.Migrations
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("serial_number");
|
||||
|
||||
b.Property<string>("Status")
|
||||
b.Property<string>("StatusId")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("status");
|
||||
.HasColumnName("status_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_inventory");
|
||||
|
||||
b.HasIndex("ItemStatusId")
|
||||
.HasDatabaseName("ix_inventory_item_status_id");
|
||||
|
||||
b.ToTable("inventory", (string)null);
|
||||
});
|
||||
|
||||
@@ -82,6 +89,19 @@ namespace barkmanapi.Migrations
|
||||
|
||||
b.ToTable("item_status", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("barkmanapi.InventoryItems", b =>
|
||||
{
|
||||
b.HasOne("barkmanapi.ItemStatus", null)
|
||||
.WithMany("Items")
|
||||
.HasForeignKey("ItemStatusId")
|
||||
.HasConstraintName("fk_inventory_item_status_item_status_id");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("barkmanapi.ItemStatus", b =>
|
||||
{
|
||||
b.Navigation("Items");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1",
|
||||
new OpenApiInfo { Title = "BarkMan API", Description = "BARK BARK WOOF WOOF", Version = "v1" });
|
||||
|
||||
});
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
@@ -30,12 +31,14 @@ var app = builder.Build();
|
||||
|
||||
if (!app.Environment.IsProduction())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.MapOpenApi();
|
||||
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Bark Productions API V1"); });
|
||||
}
|
||||
|
||||
app.MapGet("/", () => "Hello World!");
|
||||
|
||||
|
||||
|
||||
app.MapGet("/inventory", async (BarkContext db) =>
|
||||
await db.Inventory.OrderBy(item => item.Id).ToListAsync());
|
||||
|
||||
@@ -61,7 +64,7 @@ app.MapPut("/inventory/{id}", async (int id, InventoryItems updatedItem, BarkCon
|
||||
existingItem.Name = updatedItem.Name;
|
||||
existingItem.Brand = updatedItem.Brand;
|
||||
existingItem.SerialNumber = updatedItem.SerialNumber;
|
||||
existingItem.Status = updatedItem.Status;
|
||||
existingItem.StatusId = updatedItem.StatusId;
|
||||
existingItem.RentalPrice = updatedItem.RentalPrice;
|
||||
existingItem.ReplacementCost = updatedItem.ReplacementCost;
|
||||
existingItem.Notes = updatedItem.Notes;
|
||||
@@ -140,6 +143,10 @@ app.MapDelete("/itemstatus/{id}", async (string id, BarkContext db) =>
|
||||
return Results.Ok(new { Message = "Item status deleted successfully" });
|
||||
});
|
||||
|
||||
var inventoryGroup = app.MapGroup(prefix: "/inventory")
|
||||
.WithTags("Inventory")
|
||||
.WithDescription("Endpoints for managing inventory items");
|
||||
|
||||
using (var serviceScope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = serviceScope.ServiceProvider.GetRequiredService<BarkContext>();
|
||||
|
||||
@@ -14,7 +14,7 @@ public class InventoryItems
|
||||
public string Name { get; set; }
|
||||
public string Brand { get; set; }
|
||||
public string? SerialNumber { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public string? StatusId { get; set; }
|
||||
public float? RentalPrice { get; set; }
|
||||
public float? ReplacementCost { get; set; }
|
||||
public string? Notes { get; set; }
|
||||
@@ -24,4 +24,5 @@ public class ItemStatus
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public ICollection<InventoryItems> Items { get; } = new List<InventoryItems>();
|
||||
}
|
||||
Reference in New Issue
Block a user