Blazor_IMS/IMS.Plugins/IMS.Plugins.InMemory/InventoryRepository.cs

31 lines
1.4 KiB
C#

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));
}
}
}