This commit is contained in:
2025-01-08 16:57:51 -06:00
parent 0bc0c9e76f
commit c3e567494c
+1 -6
View File
@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<InventoryContext>(); builder.Services.AddDbContext<InventoryContext>();
@@ -29,12 +30,6 @@ app.MapGet("/inventory", async (InventoryContext dbContext) =>
return Results.Ok(inventoryItems); return Results.Ok(inventoryItems);
}); });
app.MapPost("/inventory", async (InventoryContext dbContext, InventoryContext newItem) =>
{
dbContext.Add(newItem);
await dbContext.SaveChangesAsync();
return Results.Created($"/inventory/{newItem.Id}", newItem);
});
//app.MapGet("/inventory/{id}", (int id) => InventoryDb.GetInventory(id)); //app.MapGet("/inventory/{id}", (int id) => InventoryDb.GetInventory(id));
//app.MapPut("/inventory", (InventoryItem item) => InventoryDb.UpdateItem(item)); //app.MapPut("/inventory", (InventoryItem item) => InventoryDb.UpdateItem(item));
//app.MapDelete("/inventory/{id}", (int id) => InventoryDb.RemoveItem(id)); //app.MapDelete("/inventory/{id}", (int id) => InventoryDb.RemoveItem(id));