diff --git a/IMS.CoreBusiness/IMS.CoreBusiness.csproj b/IMS.CoreBusiness/IMS.CoreBusiness.csproj new file mode 100644 index 0000000..cfadb03 --- /dev/null +++ b/IMS.CoreBusiness/IMS.CoreBusiness.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/IMS.CoreBusiness/Inventory.cs b/IMS.CoreBusiness/Inventory.cs new file mode 100644 index 0000000..affa4d8 --- /dev/null +++ b/IMS.CoreBusiness/Inventory.cs @@ -0,0 +1,10 @@ +namespace IMS.CoreBusiness +{ + public class Inventory + { + public int InventoryId { get; set; } + public string InventoryName { get; set; } = string.Empty; + public int Quantity { get; set; } + public double Price { get; set; } + } +} \ No newline at end of file diff --git a/IMS.Plugins/IMS.Plugins.InMemory/IMS.Plugins.InMemory.csproj b/IMS.Plugins/IMS.Plugins.InMemory/IMS.Plugins.InMemory.csproj new file mode 100644 index 0000000..92c96c5 --- /dev/null +++ b/IMS.Plugins/IMS.Plugins.InMemory/IMS.Plugins.InMemory.csproj @@ -0,0 +1,13 @@ + + + + net7.0 + enable + enable + + + + + + + diff --git a/IMS.Plugins/IMS.Plugins.InMemory/InventoryRepository.cs b/IMS.Plugins/IMS.Plugins.InMemory/InventoryRepository.cs new file mode 100644 index 0000000..ce98a98 --- /dev/null +++ b/IMS.Plugins/IMS.Plugins.InMemory/InventoryRepository.cs @@ -0,0 +1,31 @@ +using IMS.CoreBusiness; +using IMS.UseCases.PluginInterfaces; + +namespace IMS.Plugins.InMemory +{ + public class InventoryRepository : IInventoryRepository + { + private List _inventories; + + public InventoryRepository() + { + _inventories= new List() + { + new Inventory { InventoryId = 1, InventoryName = "Nail Clippers", Quantity = 8, Price = 5}, + new Inventory { InventoryId = 2, InventoryName = "Nail File", Quantity = 10, Price = 1}, + new Inventory { InventoryId = 3, InventoryName = "Glass File", Quantity = 3, Price = 8}, + new Inventory { InventoryId = 4, InventoryName = "Nail Scissors", Quantity = 5, Price = 4}, + new Inventory { InventoryId = 5, InventoryName = "Nail Base Coat", Quantity = 10, Price = 6}, + new Inventory { InventoryId = 6, InventoryName = "Nail Polish", Quantity = 20, Price = 7}, + new Inventory { InventoryId = 7, InventoryName = "Nail Top Coat", Quantity = 15, Price = 6} + }; + } + + public async Task> GetInventoriesByNameAsync(string name) + { + if (string.IsNullOrWhiteSpace(name)) return await Task.FromResult(_inventories); + + return _inventories.Where(x => x.InventoryName.Contains(name, StringComparison.OrdinalIgnoreCase)); + } + } +} \ No newline at end of file diff --git a/IMS.UseCases/IMS.UseCases.csproj b/IMS.UseCases/IMS.UseCases.csproj new file mode 100644 index 0000000..92b8446 --- /dev/null +++ b/IMS.UseCases/IMS.UseCases.csproj @@ -0,0 +1,13 @@ + + + + net7.0 + enable + enable + + + + + + + diff --git a/IMS.UseCases/Inventories/Interfaces/IViewInventoriesByNameUC.cs b/IMS.UseCases/Inventories/Interfaces/IViewInventoriesByNameUC.cs new file mode 100644 index 0000000..4067818 --- /dev/null +++ b/IMS.UseCases/Inventories/Interfaces/IViewInventoriesByNameUC.cs @@ -0,0 +1,9 @@ +using IMS.CoreBusiness; + +namespace IMS.UseCases.Inventories.Interfaces +{ + public interface IViewInventoriesByNameUC + { + Task> ExecuteAsync(string name = ""); + } +} \ No newline at end of file diff --git a/IMS.UseCases/Inventories/ViewInventoriesByNameUC.cs b/IMS.UseCases/Inventories/ViewInventoriesByNameUC.cs new file mode 100644 index 0000000..3a5d20f --- /dev/null +++ b/IMS.UseCases/Inventories/ViewInventoriesByNameUC.cs @@ -0,0 +1,25 @@ +using IMS.CoreBusiness; +using IMS.UseCases.Inventories.Interfaces; +using IMS.UseCases.PluginInterfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IMS.UseCases.Inventories +{ + public class ViewInventoriesByNameUC : IViewInventoriesByNameUC + { + private readonly IInventoryRepository inventoryRepository; + + public ViewInventoriesByNameUC(IInventoryRepository inventoryRepository) + { + this.inventoryRepository = inventoryRepository; + } + public async Task> ExecuteAsync(string name = "") + { + return await inventoryRepository.GetInventoriesByNameAsync(name); + } + } +} diff --git a/IMS.UseCases/PluginInterfaces/IInventoryRepository.cs b/IMS.UseCases/PluginInterfaces/IInventoryRepository.cs new file mode 100644 index 0000000..74e005b --- /dev/null +++ b/IMS.UseCases/PluginInterfaces/IInventoryRepository.cs @@ -0,0 +1,14 @@ +using IMS.CoreBusiness; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IMS.UseCases.PluginInterfaces +{ + public interface IInventoryRepository + { + Task> GetInventoriesByNameAsync(string name); + } +} diff --git a/IMS.WebApp/IMS.WebApp.csproj b/IMS.WebApp/IMS.WebApp.csproj index 4c2bb77..7c363b5 100644 --- a/IMS.WebApp/IMS.WebApp.csproj +++ b/IMS.WebApp/IMS.WebApp.csproj @@ -6,4 +6,10 @@ enable + + + + + + diff --git a/IMS.WebApp/Pages/Index.razor b/IMS.WebApp/Pages/Index.razor index 6085c4a..84aaef2 100644 --- a/IMS.WebApp/Pages/Index.razor +++ b/IMS.WebApp/Pages/Index.razor @@ -1,9 +1,27 @@ @page "/" +@using IMS.CoreBusiness; +@using IMS.UseCases.Inventories.Interfaces; -Index +@inject IViewInventoriesByNameUC ViewInventoriesByNameUC -

Hello, world!

+Test -Welcome to your new app. +
- +
    + @foreach(var inv in _inventories) + { +
  • @inv.InventoryName -- Quantity: @inv.Quantity -- Price: @inv.Price
  • + } +
+ + +@code { + private List _inventories = new List(); + + protected override async Task OnInitializedAsync() + { + _inventories = (await ViewInventoriesByNameUC.ExecuteAsync()).ToList(); + } + +} \ No newline at end of file diff --git a/IMS.WebApp/Program.cs b/IMS.WebApp/Program.cs index 0559a97..1a8a6d7 100644 --- a/IMS.WebApp/Program.cs +++ b/IMS.WebApp/Program.cs @@ -1,3 +1,7 @@ +using IMS.Plugins.InMemory; +using IMS.UseCases.Inventories; +using IMS.UseCases.Inventories.Interfaces; +using IMS.UseCases.PluginInterfaces; using IMS.WebApp.Data; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; @@ -9,6 +13,11 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); + +builder.Services.AddSingleton(); +builder.Services.AddTransient(); + + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/IMS.WebApp/Shared/MainLayout.razor b/IMS.WebApp/Shared/MainLayout.razor index 88adfa3..8e1c73b 100644 --- a/IMS.WebApp/Shared/MainLayout.razor +++ b/IMS.WebApp/Shared/MainLayout.razor @@ -17,3 +17,4 @@ + \ No newline at end of file diff --git a/InventoryManagementSystem.sln b/InventoryManagementSystem.sln index f828962..f777544 100644 --- a/InventoryManagementSystem.sln +++ b/InventoryManagementSystem.sln @@ -5,6 +5,14 @@ VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMS.WebApp", "IMS.WebApp\IMS.WebApp.csproj", "{8C085BDD-6A29-41B3-9141-25FDB92F2547}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMS.UseCases", "IMS.UseCases\IMS.UseCases.csproj", "{FF6F732A-60FE-43D0-B916-074117C0959F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMS.CoreBusiness", "IMS.CoreBusiness\IMS.CoreBusiness.csproj", "{B65ED444-D31B-48A9-A1B6-7C99772E30D6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IMS.Plugins", "IMS.Plugins", "{2D1BECDD-3AA3-40AE-A1CD-5E833D7E25BD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMS.Plugins.InMemory", "IMS.Plugins\IMS.Plugins.InMemory\IMS.Plugins.InMemory.csproj", "{9C4387B1-BDD6-4F6B-9F50-546DDF366CAF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,10 +23,25 @@ Global {8C085BDD-6A29-41B3-9141-25FDB92F2547}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C085BDD-6A29-41B3-9141-25FDB92F2547}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C085BDD-6A29-41B3-9141-25FDB92F2547}.Release|Any CPU.Build.0 = Release|Any CPU + {FF6F732A-60FE-43D0-B916-074117C0959F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF6F732A-60FE-43D0-B916-074117C0959F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF6F732A-60FE-43D0-B916-074117C0959F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF6F732A-60FE-43D0-B916-074117C0959F}.Release|Any CPU.Build.0 = Release|Any CPU + {B65ED444-D31B-48A9-A1B6-7C99772E30D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B65ED444-D31B-48A9-A1B6-7C99772E30D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B65ED444-D31B-48A9-A1B6-7C99772E30D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B65ED444-D31B-48A9-A1B6-7C99772E30D6}.Release|Any CPU.Build.0 = Release|Any CPU + {9C4387B1-BDD6-4F6B-9F50-546DDF366CAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C4387B1-BDD6-4F6B-9F50-546DDF366CAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C4387B1-BDD6-4F6B-9F50-546DDF366CAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C4387B1-BDD6-4F6B-9F50-546DDF366CAF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {9C4387B1-BDD6-4F6B-9F50-546DDF366CAF} = {2D1BECDD-3AA3-40AE-A1CD-5E833D7E25BD} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8D8D4049-4C2F-4BCE-94D5-56E7C0EFE649} EndGlobalSection