52 lines
2.2 KiB
C#
52 lines
2.2 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.Configuration;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Mittelpunkt.Service
|
|
{
|
|
public class CustomHomeContentGenerator : HomeContentGenerator
|
|
{
|
|
public override List<CompactSupportConceptDC> GetExpiringSupportConcepts(long? employeeOid,
|
|
DateTime expiredUntil)
|
|
{
|
|
var list = new List<CompactSupportConceptDC>();
|
|
|
|
var emp = MapperFactory.EmployeeDC_Employee.MapToNewDC(DAOFactory.GenericDAO.GetByID<Employee>(employeeOid.Value));
|
|
var user = DAOFactory.GenericDAO.GetAllActive<ApplicationUser>().FirstOrDefault(au => au.Employee.Oid.Value == employeeOid.Value);
|
|
if (user != null && emp != null)
|
|
{
|
|
// Benutzergruppen "BL" und "Hilfeplan" sollen alle auslaufenden HP der eigenen Teams sehen können
|
|
if (user.UserGroups.Any(ug => ug.Name.Trim().ToLower() == "bl" || ug.Name.Trim().ToLower() == "hilfeplan"))
|
|
{
|
|
list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
|
|
DAOFactory.SearchDAO.FindExpiringSupportConcepts(null, DateTime.Now.Date, expiredUntil));
|
|
|
|
var employeeTeams = DAOFactory.SearchDAO.GetAllActiveTeamsForEmployee(employeeOid.Value).Select(t => t.Oid);
|
|
var teamrelatedCustomerOids = DAOFactory.SearchDAO.FindTeamRelatedCustomerOids(employeeOid.Value);
|
|
for (int i = list.Count - 1; i >= 0; i--)
|
|
{
|
|
var sc = list[i];
|
|
if (!teamrelatedCustomerOids.Contains(sc.Customer.CustomerOid) && !sc.Customer.RelatedTeamOids.Any(rt => employeeTeams.Contains(rt)))
|
|
list.Remove(sc);
|
|
}
|
|
}
|
|
else
|
|
return base.GetExpiringSupportConcepts(employeeOid, expiredUntil);
|
|
}
|
|
|
|
return list.Where(s => s.StartDate.HasValue && s.EndDate.HasValue).ToList();
|
|
|
|
}
|
|
}
|
|
}
|