Files
BeWoPlaner/ReportImp/BeWoAuxilio/Service/CustomHomeContentGenerator.cs

50 lines
2.3 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 BeWoAuxilio.Service
{
public class CustomHomeContentGenerator : HomeContentGenerator
{
public override List<CompactSupportConceptDC> GetSupportConceptsWithConferenceDate(long? employeeOid,
DateTime conferenceDateUntil)
{
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)
{
// Wenn der angemeldete Nutzer alle Hilfepläne sehen darf, dann:
if (user.CheckForRight(UserRightType.SupportConcept_ViewAllSupportConcepts))
{
// Alle auslaufenden Hilfepläne unabhängig vom betroffenen Mitarbeiter
list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
DAOFactory.SearchDAO.FindSupportConceptsToEvaluate(null, DateTime.Now.Date.AddMonths(-7), DateTime.Now.AddMonths(-6).Date));
}
// Wenn der angemeldete Nutzer nicht alle Hilfepläne sehen darf, dann Standard-Homeansicht
else
{
list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
DAOFactory.SearchDAO.FindSupportConceptsToEvaluate(employeeOid, DateTime.Now.Date.AddMonths(-7), DateTime.Now.AddMonths(-6).Date));
}
}
else
{
list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
DAOFactory.SearchDAO.FindSupportConceptsToEvaluate(employeeOid, DateTime.Now.Date.AddMonths(-7), DateTime.Now.AddMonths(-6).Date));
}
return list.Where(s => s.StartDate.HasValue && s.EndDate.HasValue).ToList();
}
}
}