Files
BeWoPlaner/Service/Plugins/EmployeeService.cs
2019-08-01 11:27:28 +02:00

59 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.MessageContracts;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using BS.Shared.Services;
using Utils = BeWo.Service.Core.Utils;
namespace BeWo.Service.Plugins
{
public class EmployeeService : AbstractIDSpecificDefaultClass<EmployeeService>
{
public virtual long InsertNewEmployee(EmployeeDC pEmployeeDC)
{
Employee lEmployee = MapperFactory.EmployeeDC_Employee.MapToNewEntity(pEmployeeDC);
DAOFactory.GenericDAO.Insert(lEmployee);
return lEmployee.Oid.Value;
}
public virtual List<CompactEmployeeDC> GetAllActiveEmployeesCompact()
{
return MapperFactory.CompactEmployeeDC_Employee.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<Employee>());
}
public virtual List<CompactEmployeeDC> GetAllActiveAndArchivedEmployeesCompact()
{
return MapperFactory.CompactEmployeeDC_Employee.MapToNewDCs(DAOFactory.GenericDAO.GetAllActiveAndArchived<Employee>());
}
public virtual List<CompactTeamDC> GetAllTeamsCompact()
{
if (Utils.UserHasRight(LoggedInUserOperationContextExt.Current.User, UserRightType.TeamView_ViewAll))
{
return MapperFactory.CompactTeamDC_Team.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<Team>());
}
if (Utils.UserHasRight(LoggedInUserOperationContextExt.Current.User, UserRightType.TeamView_ViewMyTeams))
{
var teams = DAOFactory.SearchDAO.FindAllActiveTeamsOfEmployee(LoggedInUserOperationContextExt.Current.User.Employee.Oid.Value);
return MapperFactory.CompactTeamDC_Team.MapToNewDCs(teams);
}
return new List<CompactTeamDC>();
}
}
}