Buecherwurm/Inventory.cs

53 lines
1.2 KiB
C#
Raw Normal View History

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
}
public void Add(Book Book)
{
2020-04-23 13:44:38 +00:00
InventoryList.Add(new Item(NextId, Book.BookId));
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
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);
}
2020-04-23 12:47:50 +00:00
}
}