49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using Marco.Pms.DataAccess.Data;
|
|
using Marco.Pms.Model.Projects;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace MarcoBMS.Services.Helpers
|
|
{
|
|
public class ProjectsHelper
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
|
|
public ProjectsHelper(ApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<List<Project>> GetAllProjectByTanentID(Guid tanentID)
|
|
{
|
|
List<Project> alloc = await _context.Projects.Where(c => c.TenantId == tanentID).ToListAsync();
|
|
return alloc;
|
|
}
|
|
|
|
public async Task<List<ProjectAllocation>> GetProjectByEmployeeID(Guid employeeID)
|
|
{
|
|
List<ProjectAllocation> alloc = await _context.ProjectAllocations.Where(c => c.EmployeeId == employeeID && c.IsActive == true).Include(c => c.Project).ToListAsync();
|
|
return alloc;
|
|
}
|
|
|
|
public async Task<List<ProjectAllocation>> GetTeamByProject(Guid TenantId, Guid ProjectId, bool IncludeInactive)
|
|
{
|
|
if (IncludeInactive)
|
|
{
|
|
|
|
var employees = await _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == ProjectId).Include(e => e.Employee).ToListAsync();
|
|
|
|
return employees;
|
|
}
|
|
else
|
|
{
|
|
var employees = await _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == ProjectId && c.IsActive == true).Include(e => e.Employee).ToListAsync();
|
|
|
|
return employees;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|