Buecherwurm/Inventory.cs
2020-04-28 10:54:22 +02:00

58 lines
No EOL
1.4 KiB
C#

using System.Collections.Generic;
namespace Bücherwurm
{
class Inventory
{
private List<Item> InventoryList {get; set;}
private int NextId {get; set;}
public Inventory(){
InventoryList = new List<Item>();
NextId = 1;
}
public void Add(IProduct Book)
{
InventoryList.Add(new Item(NextId, Book.ProductId));
NextId = NextId + 1;
}
public void Add(int BookId)
{
InventoryList.Add(new Item(NextId, BookId));
NextId = NextId + 1;
}
public void Remove(int Id)
{
InventoryList.RemoveAll(item => item.ItemId == Id);
}
public void BookRemove(int ProdId)
{
InventoryList.RemoveAll(item => item.ProdId == ProdId);
}
public List<Item> GetInventory()
{
return InventoryList;
}
public bool IsInInventory(int Id)
{
return (InventoryList.Find(item => item.ItemId == Id) != null);
}
public bool isAvailable(int Id)
{
return (InventoryList.Find(item => item.ItemId == Id && item.Status == StatusEnum.Available) != null);
}
public Item LookupItem(int ItemId)
{
return InventoryList.Find(item => ItemId == item.ItemId);
}
}
}