add table duty time
This commit is contained in:
parent
d06e1af217
commit
22d9210416
17 changed files with 2459 additions and 10 deletions
|
|
@ -0,0 +1,122 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||
{
|
||||
public class ProcessUserTimeStampRepository : GenericLeaveRepository<Guid, ProcessUserTimeStamp>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ILeaveDbContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly EmailSenderService _emailSenderService;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
||||
public ProcessUserTimeStampRepository(ILeaveDbContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
OrganizationCommonRepository organizationCommonRepository,
|
||||
UserProfileRepository userProfileRepository,
|
||||
IConfiguration configuration,
|
||||
EmailSenderService emailSenderService) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_organizationCommonRepository = organizationCommonRepository;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_configuration = configuration;
|
||||
_emailSenderService = emailSenderService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Properties "
|
||||
|
||||
protected Guid UserOrganizationId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<int> CountRecordAsync()
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>().CountAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<ProcessUserTimeStamp?> GetTimestampByDateAsync(Guid keycloakId, DateTime date)
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
.Where(u => u.KeycloakUserId == keycloakId)
|
||||
.Where(u => u.CheckIn.Date == date.Date)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<ProcessUserTimeStamp?> GetLastRecord(Guid keycloakId)
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
.Where(u => u.KeycloakUserId == keycloakId)
|
||||
.OrderByDescending(u => u.CheckIn)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<List<ProcessUserTimeStamp>> GetTimeStampHistoryAsync(Guid keycloakId, int year, int page = 1, int pageSize = 10, string keyword = "")
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
.Where(u => u.KeycloakUserId == keycloakId)
|
||||
.Where(u => u.CheckIn.Year == year)
|
||||
.OrderBy(u => u.CheckIn)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<List<ProcessUserTimeStamp>> GetTimeStampHistoryForAdminAsync(DateTime startDate, DateTime endDate, int page = 1, int pageSize = 10, string keyword = "")
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
.Where(u => u.CheckIn.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
|
||||
.OrderBy(u => u.CheckIn)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<ProcessUserTimeStamp?> GetTimeStampById(Guid id)
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
.Where(u => u.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -57,7 +57,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<UserTimeStamp?> GetTimestampByDateAsync(Guid keycloakId,DateTime date)
|
||||
public async Task<int> CountRecordAsync()
|
||||
{
|
||||
var data = await _dbContext.Set<UserTimeStamp>().CountAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<UserTimeStamp?> GetTimestampByDateAsync(Guid keycloakId, DateTime date)
|
||||
{
|
||||
var data = await _dbContext.Set<UserTimeStamp>()
|
||||
.Where(u => u.KeycloakUserId == keycloakId)
|
||||
|
|
@ -90,7 +97,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
return data;
|
||||
}
|
||||
|
||||
public async Task<List<UserTimeStamp>> GetTimeStampHistoryForAdminAsync(DateTime startDate,DateTime endDate, int page = 1, int pageSize = 10, string keyword = "")
|
||||
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.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue