111 lines
3.7 KiB
C#
111 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared.DataContracts.Compact;
|
|
|
|
namespace SozialeDiensteNiederrhein
|
|
{
|
|
class SDNHomeContentGenerator : HomeContentGenerator
|
|
{
|
|
public override List<CompactSupportConceptDC> GetExpiringSupportConcepts(long? employeeOid, DateTime expiredUntil)
|
|
{
|
|
bool showAll = false;
|
|
bool showTeam = false;
|
|
ApplicationUser user = null;
|
|
Employee emp = null;
|
|
|
|
if (employeeOid.HasValue)
|
|
{
|
|
emp = DAOFactory.GenericDAO.LoadByID<Employee>(employeeOid.Value);
|
|
|
|
user = DAOFactory.SearchDAO.FindUserForEmployee(emp);
|
|
|
|
if (user != null)
|
|
{
|
|
foreach (var ug in user.UserGroups)
|
|
{
|
|
if (ug.Name == "Administratoren")
|
|
{
|
|
showAll = true;
|
|
}
|
|
else if (ug.Name == "Teamleitung")
|
|
{
|
|
showTeam = true;
|
|
}
|
|
else if (ug.Name == "BeWo-Leitung")
|
|
{
|
|
showAll = true;
|
|
}
|
|
else if (ug.Name == "UNA Leitung")
|
|
{
|
|
showTeam = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
IEnumerable<SupportConcept> result = null;
|
|
|
|
if (showAll)
|
|
{
|
|
result = DAOFactory.SearchDAO.FindExpiringSupportConcepts(null, DateTime.Now.AddYears(-1), expiredUntil);
|
|
}
|
|
else if (showTeam)
|
|
{
|
|
Dictionary<long, long> teamEmployeeDict = new Dictionary<long, long>();
|
|
teamEmployeeDict.Add(employeeOid.Value, employeeOid.Value);
|
|
foreach (var team in emp.LeadingTeams)
|
|
{
|
|
foreach (var member in team.MemberList)
|
|
{
|
|
if (!teamEmployeeDict.ContainsKey(member.Oid.Value))
|
|
{
|
|
teamEmployeeDict.Add(member.Oid.Value, member.Oid.Value);
|
|
}
|
|
}
|
|
}
|
|
result = DAOFactory.SearchDAO.FindExpiringSupportConcepts(null, DateTime.Now.AddYears(-1), expiredUntil);
|
|
List<SupportConcept> listeTemp = new List<SupportConcept>();
|
|
foreach (var sc in result)
|
|
{
|
|
bool add = false;
|
|
foreach (var e2c in sc.Customer.Employee2CustomerList)
|
|
{
|
|
if (teamEmployeeDict.ContainsKey(e2c.EmployeeOid.Value))
|
|
{
|
|
add = true;
|
|
}
|
|
}
|
|
|
|
if (add)
|
|
{
|
|
listeTemp.Add(sc);
|
|
}
|
|
}
|
|
|
|
result = listeTemp;
|
|
}
|
|
else
|
|
{
|
|
result = DAOFactory.SearchDAO.FindExpiringSupportConcepts(employeeOid, DateTime.Now.AddYears(-1), expiredUntil);
|
|
}
|
|
|
|
List<SupportConcept> liste = new List<SupportConcept>();
|
|
foreach (var sc in result)
|
|
{
|
|
if (!sc.RenewalSendDate.HasValue)
|
|
{
|
|
liste.Add(sc);
|
|
}
|
|
}
|
|
|
|
|
|
return MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(liste);
|
|
}
|
|
}
|
|
}
|