2020-04-23 12:47:50 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Bücherwurm
|
|
|
|
{
|
|
|
|
class Inventory
|
|
|
|
{
|
|
|
|
private List<Item> InventoryList {get; set;}
|
|
|
|
|
2020-04-23 13:44:38 +00:00
|
|
|
private int NextId {get; set;}
|
|
|
|
|
2020-04-23 12:47:50 +00:00
|
|
|
public Inventory(){
|
|
|
|
InventoryList = new List<Item>();
|
2020-04-27 09:26:45 +00:00
|
|
|
NextId = 1;
|
2020-04-23 12:47:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-27 14:14:20 +00:00
|
|
|
public void Add(IProduct Book)
|
2020-04-23 12:47:50 +00:00
|
|
|
{
|
2020-04-27 14:14:20 +00:00
|
|
|
InventoryList.Add(new Item(NextId, Book.ProductId));
|
2020-04-27 09:26:45 +00:00
|
|
|
NextId = NextId + 1;
|
2020-04-23 12:47:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 13:54:17 +00:00
|
|
|
public void Add(int BookId)
|
|
|
|
{
|
|
|
|
InventoryList.Add(new Item(NextId, BookId));
|
2020-04-27 09:26:45 +00:00
|
|
|
NextId = NextId + 1;
|
2020-04-24 13:54:17 +00:00
|
|
|
}
|
|
|
|
|
2020-04-23 12:47:50 +00:00
|
|
|
public void Remove(int Id)
|
|
|
|
{
|
2020-04-23 13:44:38 +00:00
|
|
|
InventoryList.RemoveAll(item => item.ItemId == Id);
|
2020-04-23 12:47:50 +00:00
|
|
|
}
|
2020-04-24 13:54:17 +00:00
|
|
|
|
2020-04-28 08:54:22 +00:00
|
|
|
public void BookRemove(int ProdId)
|
2020-04-24 13:54:17 +00:00
|
|
|
{
|
2020-04-28 08:54:22 +00:00
|
|
|
InventoryList.RemoveAll(item => item.ProdId == ProdId);
|
2020-04-24 13:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2020-04-28 08:54:22 +00:00
|
|
|
|
|
|
|
public Item LookupItem(int ItemId)
|
|
|
|
{
|
|
|
|
return InventoryList.Find(item => ItemId == item.ItemId);
|
|
|
|
}
|
2020-04-23 12:47:50 +00:00
|
|
|
}
|
|
|
|
}
|