UserTaskRepository.cs 938 B

123456789101112131415161718192021222324252627282930
  1. using Microsoft.EntityFrameworkCore;
  2. using MTWorkHR.Core.Entities;
  3. using MTWorkHR.Core.IDto;
  4. using MTWorkHR.Core.IRepositories;
  5. using MTWorkHR.Infrastructure.Entities;
  6. using MTWorkHR.Infrastructure.DBContext;
  7. namespace MTWorkHR.Infrastructure.Repositories
  8. {
  9. public class UserTaskRepository : Repository<UserTask>, IUserTaskRepository
  10. {
  11. private readonly DbSet<UserTask> dbSet;
  12. public UserTaskRepository(HRDataContext context) : base(context)
  13. {
  14. dbSet = context.Set<UserTask>();
  15. }
  16. public async Task<UserTask> GetByIdWithAllChildren(long id)
  17. {
  18. return await dbSet
  19. .Include(x => x.TaskAttachments).ThenInclude(a => a.AttachmentType)
  20. .Include(x => x.UserTaskHistories)
  21. .Include(x => x.TaskStatus)
  22. .Include(x => x.Project)
  23. .FirstOrDefaultAsync(x => x.Id == id);
  24. }
  25. }
  26. }