Serving locally stored inventories
This commit is contained in:
parent
72ba8e9cc8
commit
f71cbb74b1
|
@ -0,0 +1,9 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\IMS.UseCases\IMS.UseCases.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,31 @@
|
||||||
|
using IMS.CoreBusiness;
|
||||||
|
using IMS.UseCases.PluginInterfaces;
|
||||||
|
|
||||||
|
namespace IMS.Plugins.InMemory
|
||||||
|
{
|
||||||
|
public class InventoryRepository : IInventoryRepository
|
||||||
|
{
|
||||||
|
private List<Inventory> _inventories;
|
||||||
|
|
||||||
|
public InventoryRepository()
|
||||||
|
{
|
||||||
|
_inventories= new List<Inventory>()
|
||||||
|
{
|
||||||
|
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<IEnumerable<Inventory>> GetInventoriesByNameAsync(string name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(name)) return await Task.FromResult(_inventories);
|
||||||
|
|
||||||
|
return _inventories.Where(x => x.InventoryName.Contains(name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\IMS.CoreBusiness\IMS.CoreBusiness.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
using IMS.CoreBusiness;
|
||||||
|
|
||||||
|
namespace IMS.UseCases.Inventories.Interfaces
|
||||||
|
{
|
||||||
|
public interface IViewInventoriesByNameUC
|
||||||
|
{
|
||||||
|
Task<IEnumerable<Inventory>> ExecuteAsync(string name = "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<IEnumerable<Inventory>> ExecuteAsync(string name = "")
|
||||||
|
{
|
||||||
|
return await inventoryRepository.GetInventoriesByNameAsync(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<IEnumerable<Inventory>> GetInventoriesByNameAsync(string name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,4 +6,10 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\IMS.CoreBusiness\IMS.CoreBusiness.csproj" />
|
||||||
|
<ProjectReference Include="..\IMS.Plugins\IMS.Plugins.InMemory\IMS.Plugins.InMemory.csproj" />
|
||||||
|
<ProjectReference Include="..\IMS.UseCases\IMS.UseCases.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,9 +1,27 @@
|
||||||
@page "/"
|
@page "/"
|
||||||
|
@using IMS.CoreBusiness;
|
||||||
|
@using IMS.UseCases.Inventories.Interfaces;
|
||||||
|
|
||||||
<PageTitle>Index</PageTitle>
|
@inject IViewInventoriesByNameUC ViewInventoriesByNameUC
|
||||||
|
|
||||||
<h1>Hello, world!</h1>
|
<PageTitle>Test</PageTitle>
|
||||||
|
|
||||||
Welcome to your new app.
|
<br/>
|
||||||
|
|
||||||
<SurveyPrompt Title="How is Blazor working for you?" />
|
<ul>
|
||||||
|
@foreach(var inv in _inventories)
|
||||||
|
{
|
||||||
|
<li>@inv.InventoryName -- Quantity: @inv.Quantity -- Price: @inv.Price</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Inventory> _inventories = new List<Inventory>();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_inventories = (await ViewInventoriesByNameUC.ExecuteAsync()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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 IMS.WebApp.Data;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
|
@ -9,6 +13,11 @@ builder.Services.AddRazorPages();
|
||||||
builder.Services.AddServerSideBlazor();
|
builder.Services.AddServerSideBlazor();
|
||||||
builder.Services.AddSingleton<WeatherForecastService>();
|
builder.Services.AddSingleton<WeatherForecastService>();
|
||||||
|
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<IInventoryRepository, InventoryRepository>();
|
||||||
|
builder.Services.AddTransient<IViewInventoriesByNameUC, ViewInventoriesByNameUC>();
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
|
|
@ -17,3 +17,4 @@
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,6 +5,14 @@ VisualStudioVersion = 17.4.33213.308
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMS.WebApp", "IMS.WebApp\IMS.WebApp.csproj", "{8C085BDD-6A29-41B3-9141-25FDB92F2547}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMS.WebApp", "IMS.WebApp\IMS.WebApp.csproj", "{8C085BDD-6A29-41B3-9141-25FDB92F2547}"
|
||||||
EndProject
|
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
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{8C085BDD-6A29-41B3-9141-25FDB92F2547}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{9C4387B1-BDD6-4F6B-9F50-546DDF366CAF} = {2D1BECDD-3AA3-40AE-A1CD-5E833D7E25BD}
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {8D8D4049-4C2F-4BCE-94D5-56E7C0EFE649}
|
SolutionGuid = {8D8D4049-4C2F-4BCE-94D5-56E7C0EFE649}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|
Loading…
Reference in New Issue