123456789101112131415161718192021222324252627282930313233343536373839 |
- using Microsoft.EntityFrameworkCore;
- using MTWorkHR.Core.Entities;
- using MTWorkHR.Core.IDto;
- using MTWorkHR.Core.IRepositories;
- using MTWorkHR.Infrastructure.Entities;
- using MTWorkHR.Infrastructure.DBContext;
- namespace MTWorkHR.Infrastructure.Repositories
- {
- public class ContractRepository : Repository<Contract>, IContractRepository
- {
- private readonly DbSet<Contract> dbSet;
- public ContractRepository(HRDataContext context) : base(context)
- {
- dbSet = context.Set<Contract>();
- }
- public async Task<Contract> GetByIdWithAllChildren(long id)
- {
- return await dbSet
- .Include(x => x.ContractTasks)
- .Include(x => x.FixedAllowances)
- .Include(x => x.ProjectStages)
- .Include(x => x.WorkingDays)
- .FirstOrDefaultAsync(x => x.Id == id);
- }
- public async Task<Tuple<IQueryable<Contract>, int>> GetAllWithChildrenAsync()
- {
- var query = dbSet//.Include(x => x.ContractUsers)
- .AsQueryable();
- var total = await query.CountAsync();
- return new Tuple<IQueryable<Contract>, int>(query, total);
- }
- }
- }
|