82 lines
2.5 KiB
C#
82 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BS.Shared.DataContracts
|
|
{
|
|
[DebuggerDisplay("Z{Zeile} {Date}: {Employee}")]
|
|
public class DienstZeileDC
|
|
{
|
|
public event Action DienstDictUpdated;
|
|
[DataMember]
|
|
public EmployeeDC Employee { get; set; }
|
|
[DataMember]
|
|
public List<ContractDC> Contracts { get; set; }
|
|
[DataMember]
|
|
public int Zeile { get; set; }
|
|
[DataMember]
|
|
public DateTime Date { get; set; }
|
|
[DataMember]
|
|
public Dictionary<int, DienstInfoDC> DienstDict { get; set; }
|
|
[DataMember]
|
|
public List<BesetzungsstatusDC> StatusListe { get; set; }
|
|
|
|
public String DebugInfo { get; set; }
|
|
|
|
|
|
public DienstZeileDC() { }
|
|
public DienstZeileDC(EmployeeDC emp, List<ContractDC> contracts, int zeile, DateTime date, Dictionary<int, DienstInfoDC> dienste)
|
|
{
|
|
Employee = emp;
|
|
Contracts = contracts;
|
|
Zeile = zeile;
|
|
Date = date;
|
|
DienstDict = dienste ?? new Dictionary<int, DienstInfoDC>();
|
|
} //Tag
|
|
public List<DienstInfoDC> GetDienstWoche(int sonntag) => DienstDict.Where(x => x.Key <= sonntag && sonntag - x.Key < 7).Select(x => x.Value).ToList();
|
|
|
|
//public List<DienstInfoDC> GetDienstMonat(int letzterMonatstag) => DienstDict.Where(x => x.Key <= letzterMonatstag && letzterMonatstag - x.Key < 7).Select(x => x.Value).ToList();
|
|
public List<DienstInfoDC> GetDienstMonat()
|
|
{
|
|
var result = new List<DienstInfoDC>();
|
|
|
|
foreach (var dienst in DienstDict)
|
|
{
|
|
result.Add(dienst.Value);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public void AddDienst(int tag, DienstInfoDC dienst)
|
|
{
|
|
if (dienst != null && !DienstDict.ContainsKey(tag))
|
|
{
|
|
DienstDict.Add(tag, dienst);
|
|
DienstDictUpdated?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void UpdateDienst(int tag, DienstInfoDC dienst)
|
|
{
|
|
DienstDict[tag] = dienst;
|
|
DienstDictUpdated?.Invoke();
|
|
}
|
|
|
|
public void RemoveDienst(int tag)
|
|
{
|
|
DienstDict.Remove(tag);
|
|
DienstDictUpdated?.Invoke();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|