diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 6101173..304aebc 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -3,6 +3,7 @@ using BarkMan.DB; var builder = WebApplication.CreateBuilder(args); +builder.Services.AddDbContext(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(c => { diff --git a/barkmanAPI/inventoryModel.cs b/barkmanAPI/inventoryModel.cs index 718c0d7..dfa722e 100644 --- a/barkmanAPI/inventoryModel.cs +++ b/barkmanAPI/inventoryModel.cs @@ -19,7 +19,7 @@ public class InventoryContext : DbContext { var folder = Environment.SpecialFolder.LocalApplicationData; var path = Environment.GetFolderPath(folder); - DbPath = System.IO.Path.Join(path, "blogging.db"); + DbPath = System.IO.Path.Join(path, "inventory.db"); } // The following configures EF to create a Sqlite database file in the @@ -27,42 +27,4 @@ public class InventoryContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseSqlite($"Data Source={DbPath}"); -} - -public class InventoryDb -{ - - public static List GetInventory() - { - return _inventory; - } - - public static InventoryItem ? GetInventory(int id) - { - return _inventory.SingleOrDefault(item => item.Id == id); - } - - public static InventoryItem CreateInventoryItem(InventoryItem item) - { - _inventory.Add(item); - return item; - } - - public static InventoryItem UpdateItem(InventoryItem update) - { - _inventory = _inventory.Select(item => - { - if (item.Id == update.Id) - { - item.Name = update.Name; - } - return item; - }).ToList(); - return update; - } - - public static void RemoveItem(int id) - { - _inventory = _inventory.FindAll(item => item.Id != id).ToList(); - } } \ No newline at end of file