1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using Microsoft.EntityFrameworkCore;
- using MTWorkHR.Core.Entities;
- using MTWorkHR.Core.IDto;
- using MTWorkHR.Infrastructure.Entities;
- using MTWorkHR.Infrastructure.DBContext;
- using MTWorkHR.Core.IRepositories;
- namespace MTWorkHR.Infrastructure.Repositories
- {
- public class UserTaskRepository : Repository<UserTask>, IUserTaskRepository
- {
- private readonly DbSet<UserTask> dbSet;
- public UserTaskRepository(HRDataContext context) : base(context)
- {
- dbSet = context.Set<UserTask>();
- }
- public async Task<UserTask> GetByIdWithAllChildren(long id)
- {
- return await dbSet
- .Include(x => x.TaskAttachments).ThenInclude(a => a.AttachmentType)
- .Include(x => x.UserTaskHistories)
- .Include(x => x.TaskStatus)
- .Include(x => x.Project)
- .FirstOrDefaultAsync(x => x.Id == id);
- }
- public async Task<UserTask> GetByUserIdWithAllChildren(long userId)
- {
- return await dbSet
- .Include(x => x.TaskAttachments).ThenInclude(a => a.AttachmentType)
- .Include(x => x.UserTaskHistories)
- .Include(x => x.TaskStatus)
- .Include(x => x.Project)
- .FirstOrDefaultAsync(x => x.AssignedUserId == userId);
- }
- }
- }
|