Buecherwurm/Inventory.cs

53 lines
1.2 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(Book Book)
{
InventoryList.Add(new Item(NextId, Book.BookId));
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 BookId)
{
InventoryList.RemoveAll(item => item.BookId == BookId);
}
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);
}
}
}