mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-06-13 06:11:55 +00:00
some changes
This commit is contained in:
+16
-6
@@ -1,5 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using BarkMan.DB;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -23,10 +23,20 @@ if (app.Environment.IsDevelopment())
|
||||
|
||||
app.MapGet("/", () => "Hello World!");
|
||||
|
||||
app.MapGet("/inventory/{id}", (int id) => InventoryDb.GetInventory(id));
|
||||
app.MapGet("/inventory", () => InventoryDb.GetInventory());
|
||||
app.MapPost("/inventory", (InventoryItem item) => InventoryDb.CreateInventoryItem(item));
|
||||
app.MapPut("/inventory", (InventoryItem item) => InventoryDb.UpdateItem(item));
|
||||
app.MapDelete("/inventory/{id}", (int id) => InventoryDb.RemoveItem(id));
|
||||
app.MapGet("/inventory", async (InventoryContext dbContext) =>
|
||||
{
|
||||
var inventoryItems = await dbContext.Set<InventoryContext>().ToListAsync();
|
||||
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.MapPut("/inventory", (InventoryItem item) => InventoryDb.UpdateItem(item));
|
||||
//app.MapDelete("/inventory/{id}", (int id) => InventoryDb.RemoveItem(id));
|
||||
|
||||
app.Run();
|
||||
@@ -9,6 +9,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user