Buecherwurm/Lend_Administration.cs

42 lines
1001 B
C#
Raw Normal View History

2020-04-23 12:47:50 +00:00
using System.Collections.Generic;
namespace Bücherwurm
{
class Lend_Administration
{
private List<Lending> Lendings {get; set;}
2020-04-23 13:44:38 +00:00
private List<int> ActiveLendings {get; set;}
private int NextId {get; set;}
2020-04-23 12:47:50 +00:00
public Lend_Administration()
{
Lendings = new List<Lending>();
2020-04-23 13:44:38 +00:00
ActiveLendings = new List<int>();
NextId = 0;
2020-04-23 12:47:50 +00:00
}
2020-04-23 13:44:38 +00:00
public void Lend(int[] ItemIds, string Customer)
2020-04-23 12:47:50 +00:00
{
2020-04-23 13:44:38 +00:00
Lendings.Add(new Lending(NextId, ItemIds, Customer));
ActiveLendings.Add(NextId);
NextId = NextId++;
2020-04-23 12:47:50 +00:00
}
public void Return(int LendID)
{
2020-04-23 13:44:38 +00:00
ActiveLendings.RemoveAll(id => id == LendID);
2020-04-23 12:47:50 +00:00
}
2020-04-24 13:54:17 +00:00
public List<Lending> GetAllLendings()
{
return Lendings;
}
public List<Lending> GetActiveLendings()
{
return Lendings.FindAll(lend => ActiveLendings.Contains(lend.LendId));
}
2020-04-23 12:47:50 +00:00
}
}