add api เพิ่มเติมระบบลงเวลา

This commit is contained in:
Suphonchai Phoonsawat 2023-11-13 16:56:17 +07:00
parent 8782aec4c3
commit 19bcc6bed2
11 changed files with 291 additions and 11 deletions

View file

@ -7,11 +7,11 @@ using Microsoft.Extensions.Configuration;
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
{
public class DutyTimeRepository : GenericRepository<Guid, DutyTime>
public class DutyTimeRepository : GenericLeaveRepository<Guid, DutyTime>
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly ILeaveDbContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly OrganizationCommonRepository _organizationCommonRepository;
private readonly UserProfileRepository _userProfileRepository;
@ -22,7 +22,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
#region " Constructor and Destuctor "
public DutyTimeRepository(IApplicationDBContext dbContext,
public DutyTimeRepository(ILeaveDbContext dbContext,
IHttpContextAccessor httpContextAccessor,
OrganizationCommonRepository organizationCommonRepository,
UserProfileRepository userProfileRepository,

View file

@ -1,5 +1,6 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Messaging;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
@ -7,11 +8,11 @@ using Microsoft.Extensions.Configuration;
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
{
public class UserTimeStampRepository : GenericRepository<Guid, UserTimeStamp>
public class UserTimeStampRepository : GenericLeaveRepository<Guid, UserTimeStamp>
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly ILeaveDbContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly OrganizationCommonRepository _organizationCommonRepository;
private readonly UserProfileRepository _userProfileRepository;
@ -22,7 +23,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
#region " Constructor and Destuctor "
public UserTimeStampRepository(IApplicationDBContext dbContext,
public UserTimeStampRepository(ILeaveDbContext dbContext,
IHttpContextAccessor httpContextAccessor,
OrganizationCommonRepository organizationCommonRepository,
UserProfileRepository userProfileRepository,
@ -66,6 +67,31 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
public async Task<List<UserTimeStamp>> GetTimeStampHistoryAsync(Guid keycloakId, int year, int page = 1, int pageSize = 10, string keyword = "")
{
var data = await _dbContext.Set<UserTimeStamp>()
.Where(u => u.KeycloakUserId == keycloakId)
.Where(u => u.CheckIn.Year.ToCeYear() == year.ToCeYear())
.OrderBy(u => u.CheckIn)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToListAsync();
return data;
}
public async Task<List<UserTimeStamp>> GetTimeStampHistoryForAdminAsync(DateTime startDate,DateTime endDate, int page = 1, int pageSize = 10, string keyword = "")
{
var data = await _dbContext.Set<UserTimeStamp>()
.Where(u => u.CheckIn >= startDate && u.CheckIn <= endDate)
.OrderBy(u => u.CheckIn)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToListAsync();
return data;
}
#endregion
}
}