80 lines
2.5 KiB
C#
80 lines
2.5 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;
|
|
using TaskStatus = GozareshgirProgramManager.Domain.ProjectAgg.Enums.TaskStatus;
|
|
|
|
namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories;
|
|
|
|
public class ProjectTaskRepository : RepositoryBase<Guid, ProjectTask>, IProjectTaskRepository
|
|
{
|
|
private readonly ProgramManagerDbContext _context;
|
|
|
|
public ProjectTaskRepository(ProgramManagerDbContext context) : base(context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public Task<ProjectTask?> GetWithSectionsAsync(Guid taskId)
|
|
{
|
|
return _context.ProjectTasks
|
|
.Include(t => t.Sections)
|
|
.ThenInclude(s => s.Skill)
|
|
.Include(t => t.Sections)
|
|
.ThenInclude(s => s.Activities)
|
|
.Include(t => t.Sections)
|
|
.ThenInclude(s => s.AdditionalTimes)
|
|
.FirstOrDefaultAsync(t => t.Id == taskId);
|
|
}
|
|
|
|
public Task<List<ProjectTask>> GetByPhaseIdAsync(Guid phaseId)
|
|
{
|
|
return _context.ProjectTasks
|
|
.Where(t => t.PhaseId == phaseId)
|
|
.OrderBy(t => t.OrderIndex)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public Task<List<ProjectTask>> GetTasksWithTimeOverridesAsync()
|
|
{
|
|
return _context.ProjectTasks
|
|
.Where(t => t.HasTimeOverride)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public Task<List<ProjectTask>> GetTasksWithAssignmentOverridesAsync()
|
|
{
|
|
return _context.ProjectTasks
|
|
.Where(t => t.HasAssignmentOverride)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public Task<List<ProjectTask>> GetByStatusAsync(TaskStatus status)
|
|
{
|
|
return _context.ProjectTasks
|
|
.Where(t => t.Status == status)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public Task<List<ProjectTask>> GetByPriorityAsync(ProjectTaskPriority priority)
|
|
{
|
|
return _context.ProjectTasks
|
|
.Where(t => t.Priority == priority)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public Task<List<ProjectTask>> GetAssignedToUserAsync(long userId)
|
|
{
|
|
return _context.ProjectTasks
|
|
.Where(t => t.Sections.Any(s => s.CurrentAssignedUserId == userId))
|
|
.ToListAsync();
|
|
}
|
|
|
|
public void Remove(ProjectTask task)
|
|
{
|
|
_context.ProjectTasks.Remove(task);
|
|
}
|
|
}
|