71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
|
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
using GozareshgirProgramManager.Infrastructure.Persistence._Common;
|
|
using GozareshgirProgramManager.Infrastructure.Persistence.Context;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories;
|
|
|
|
public class ProjectRepository : RepositoryBase<Guid, Project>, IProjectRepository
|
|
{
|
|
private readonly ProgramManagerDbContext _context;
|
|
|
|
public ProjectRepository(ProgramManagerDbContext context) : base(context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public Task<Project?> GetWithFullHierarchyAsync(Guid projectId)
|
|
{
|
|
return _context.Projects
|
|
.Include(p => p.Phases)
|
|
.ThenInclude(ph => ph.Tasks)
|
|
.ThenInclude(t => t.Sections)
|
|
.ThenInclude(s => s.Skill)
|
|
.Include(p => p.Phases)
|
|
.ThenInclude(ph => ph.Tasks)
|
|
.ThenInclude(t => t.Sections)
|
|
.ThenInclude(s => s.Activities)
|
|
.Include(p => p.Phases)
|
|
.ThenInclude(ph => ph.Tasks)
|
|
.ThenInclude(t => t.Sections)
|
|
.ThenInclude(s => s.AdditionalTimes)
|
|
.FirstOrDefaultAsync(p => p.Id == projectId);
|
|
}
|
|
|
|
public Task<Project?> GetWithPhasesAsync(Guid projectId)
|
|
{
|
|
return _context.Projects
|
|
.Include(p => p.Phases)
|
|
.FirstOrDefaultAsync(p => p.Id == projectId);
|
|
}
|
|
|
|
public Task<List<Project>> GetByStatusAsync(ProjectStatus status)
|
|
{
|
|
return _context.Projects
|
|
.Where(p => p.Status == status)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public Task<List<Project>> GetProjectsWithAssignmentOverridesAsync()
|
|
{
|
|
return _context.Projects
|
|
.Where(p => p.HasAssignmentOverride)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public Task<List<Project>> SearchByNameAsync(string searchTerm)
|
|
{
|
|
return _context.Projects
|
|
.Where(p => p.Name.Contains(searchTerm))
|
|
.ToListAsync();
|
|
}
|
|
|
|
public void Remove(Project project)
|
|
{
|
|
_context.Projects.Remove(project);
|
|
}
|
|
}
|