Buecherwurm/Lend_Administration.cs

45 lines
1.0 KiB
C#
Raw Permalink 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>();
2020-04-27 09:26:45 +00:00
NextId = 1;
2020-04-23 12:47:50 +00:00
}
2020-04-29 09:30:49 +00:00
public void Lend(
int ItemId,
string Customer,
int timeInDays)
2020-04-23 12:47:50 +00:00
{
2020-04-28 08:54:22 +00:00
Lendings.Add(new Lending(NextId, ItemId, Customer, timeInDays));
2020-04-23 13:44:38 +00:00
ActiveLendings.Add(NextId);
2020-04-27 09:26:45 +00:00
NextId = NextId + 1;
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
}
}