73 lines
3.0 KiB
C#
73 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace BeWo.SchulbegleitenderDienst.SBDUtils
|
|
{
|
|
public static class SBDUtils
|
|
{
|
|
public static SubstitutionListObject GetListType(List<TagesansichtVM> viewModels)
|
|
{
|
|
var unwantedSubstitutionList = new List<TagesansichtVM>();
|
|
var employeeSubstitutionList = new List<TagesansichtVM>();
|
|
var customerSubstitutionList = new List<TagesansichtVM>();
|
|
|
|
foreach (var viewModel in viewModels)
|
|
{
|
|
if(viewModel.VertretungsStatus != VertretungsStatus.KlientKrank)
|
|
{
|
|
var substitutionStartingDayCountCondition = false;
|
|
|
|
if (viewModel.Customer != null)
|
|
{
|
|
if (viewModel.Absencetime?.Start.HasValue ?? false)
|
|
{
|
|
var substitutionNeededStartDate = viewModel.Absencetime?.Start.Value.AddDays(viewModel.Customer.SubstitutionStartingDayCount - 1);
|
|
|
|
substitutionStartingDayCountCondition = viewModel.Customer.SubstitutionNeed != SubstitutionNeed.NoSubstitutionWanted && viewModel.Datum < substitutionNeededStartDate;
|
|
}
|
|
}
|
|
|
|
if (substitutionStartingDayCountCondition || viewModel.Vertretung?.VertretenderMitarbeiterOid != null || viewModel.Customer != null && viewModel.Customer.SubstitutionNeed == SubstitutionNeed.NoSubstitutionWanted)
|
|
{
|
|
unwantedSubstitutionList.AddIfNotIn(viewModel);
|
|
}
|
|
else
|
|
{
|
|
employeeSubstitutionList.AddIfNotIn(viewModel);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//if(viewModel.Customer.SubstitutionNeed == SubstitutionNeed.SubstitutionNeeded || viewModel.Customer.SubstitutionNeed == SubstitutionNeed.SubstitutionWanted)
|
|
//{
|
|
|
|
customerSubstitutionList.Add(viewModel);
|
|
//}
|
|
//else
|
|
//{
|
|
// unwantedSubstitutionList.Add(viewModel);
|
|
//}
|
|
}
|
|
}
|
|
|
|
return new SubstitutionListObject(employeeSubstitutionList, customerSubstitutionList, unwantedSubstitutionList);
|
|
}
|
|
}
|
|
|
|
public struct SubstitutionListObject
|
|
{
|
|
public List<TagesansichtVM> AbsentEmployeesList { get; set; }
|
|
public List<TagesansichtVM> AbsentCustomersList { get; set; }
|
|
public List<TagesansichtVM> SubstitutionUnwantedList { get; set; }
|
|
|
|
public SubstitutionListObject(List<TagesansichtVM> absentEmployees, List<TagesansichtVM> absentCustomers, List<TagesansichtVM> substitutionUnwanted)
|
|
{
|
|
AbsentEmployeesList = absentEmployees;
|
|
AbsentCustomersList = absentCustomers;
|
|
SubstitutionUnwantedList = substitutionUnwanted;
|
|
}
|
|
}
|
|
}
|