Question
Assignment Instructions: Simple Final Project Application Name: Inventory Pro Brief Description: Inventory Pro is an application made for retail stores to manage their inventory better. Our system allows our users to track inventory items, including their quantities, prices, and descriptions. They can add new items, update existing items, delete items, and view a full report/list of all items. It will have a user- friendly and accessible front-end interface. Screens: • Homescreen: Overview of inventory items and some easy actions on a menu (Crud Operations: Create, Read, Update, Delete) New Item Screen: Form to make a new inventory entry. Users can fill out the information necessary for their items. (Crud Operations: Create) • View Item Screen: Users can view their item information. (Crud Operations: Update, Delete) • Inventory List Screen: Full Inventory view page. (Crud Operations: Read) Audit Log: Will display any changes and timestamp them for correction and security purposes. (Crud Operations: None) Other Information Information Database Entities: Items, Categories, Suppliers, Users, Transactions, etc... • Relationship Examples: Items-Categories, Items-Suppliers, Transactions-Items NOTE: Front end will use React but only needs the backend stuff completed. all I need is the backend code and help on how to implement it so my group members can complete the front end. /n ALREADY DONE CODE (need to add backend function in this) public class Item { public int ItemId { get; set; } public string Name { get; set; } public string Description { get; set; } public decimal Price { get; set; } public int Quantity { get; set; } public int CategoryId { get; set; } public Category Category { get; set; } } public class Category { public int CategoryId { get; set; } public string Name { get; set; } public ICollection Items { get; set; } } public class InventoryContext: DbContext { public InventoryContext(DbContextOptions options): base(options) { } public DbSet Items { get; set; } public DbSet Categories { get; set; } } 3. Configure Database and Minimal API Endpoints In the Program.cs, configure the database context and define your Minimal API endpoints. csharp Copy code var builder = WebApplication.CreateBuilder(args); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("In ventoryDb"))); var app = builder.Build(); app.MapGet("/items", async (InventoryContext db) => await db.Items.ToListAsync()); app.MapPost("/items", async (InventoryContext db, Item item) => { db.Items.Add(item); await db.SaveChangesAsync(); return Results.Created($"/items/{item.ItemId}", item); }); app.MapGet("/items/{id}", async (InventoryContext db, int id) => await db.Items.FindAsync(id) is Item item? Results.Ok(item): Results.NotFound()); app.MapPut("/items/{id}", async (InventoryContext db, int id, Item updateItem) => { var item = await db.Items.FindAsync(id); if (item null) return Results.NotFound(); == item.Name = updateItem.Name; item.Description = updateItem.Description; item.Price = updateItem.Price; item.Quantity = updateItem.Quantity; item.CategoryId = updateItem.CategoryId; await db.SaveChangesAsync(); return Results.NoContent(); }); app.MapDelete("/items/{id}", async (InventoryContext db, int id): { if (await db.Items.FindAsync(id) is Item item) { db.Items.Remove(item); await db.SaveChangesAsync(); return Results.Ok(item); } return Results.NotFound(); }); app.Run();