Files
barkman/barkmanAPI/Program.cs
T
2025-01-08 16:57:51 -06:00

37 lines
1.0 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<InventoryContext>();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "BarkMan API", Description = "BARK BARK WOOF WOOF", Version = "v1" });
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Bark Inventory API V1");
});
}
app.MapGet("/", () => "Hello World!");
app.MapGet("/inventory", async (InventoryContext dbContext) =>
{
var inventoryItems = await dbContext.Set<InventoryContext>().ToListAsync();
return Results.Ok(inventoryItems);
});
//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();