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> GetAllProjectByTanentID(int tanentID) { List alloc = await _context.Projects.Where(c => c.TenantId == tanentID).ToListAsync(); return alloc; } public async Task> GetProjectByEmployeeID(int employeeID) { List alloc = await _context.ProjectAllocations.Where(c => c.EmployeeId ==employeeID && c.IsActive == true).Include(c=>c.Project).ToListAsync(); return alloc; } public async Task> GetTeamByProject(int TenantId, int 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; } } } }