1234567891011121314151617181920212223242526272829303132333435363738 |
- 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 AttendanceRepository : Repository<Attendance>, IAttendanceRepository
- {
- private readonly DbSet<Attendance> dbSet;
- public AttendanceRepository(HRDataContext context) : base(context)
- {
- dbSet = context.Set<Attendance>();
- }
-
- public async Task<Attendance> GetAttendanceByUserId(string userId, DateTime attendanceDate)
- {
- var result = await dbSet
- .FirstOrDefaultAsync(x => x.UserId == userId && x.AttendanceDate.Date == attendanceDate.Date && !x.CheckOutTime.HasValue);
- return result;
- }
- public async Task<Tuple<IQueryable<Attendance>, int>> GetAllWithChildrenAsync()
- {
- var query = dbSet.AsQueryable();
- var total = await query.CountAsync();
- return new Tuple<IQueryable<Attendance>, int>(query, total);
- }
- }
- }
|