add
- LV2_004 - รายละเอียดการลา (USER) - LV2_010 - รายการลา (ADMIN)
This commit is contained in:
parent
dd4a409855
commit
0109cc5d6d
5 changed files with 349 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ using BMA.EHR.Domain.Models.Leave.Commons;
|
|||
using BMA.EHR.Domain.Models.Leave.Requests;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||
|
|
@ -58,6 +59,21 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
#region " Methods "
|
||||
|
||||
#region " Overrides "
|
||||
|
||||
public override async Task<LeaveRequest?> GetByIdAsync(Guid id)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
.Include(x => x.LeaveDocument)
|
||||
.Include(x => x.LeaveDraftDocument)
|
||||
.Include(x => x.Type)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestByYearAsync(int year)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
|
|
@ -68,7 +84,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return data;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestByUserIdAsync(Guid keycloakUserId, int year, Guid type, string status)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
|
|
@ -87,6 +102,24 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestForAdminAsync(int year, Guid type, string status)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
.Include(x => x.Type);
|
||||
|
||||
|
||||
if (year != 0)
|
||||
rawData = (IIncludableQueryable<LeaveRequest, LeaveType>)rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
|
||||
if (type != Guid.Empty)
|
||||
rawData = (IIncludableQueryable<LeaveRequest, LeaveType>)rawData.Where(x => x.Type.Id == type);
|
||||
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
rawData = (IIncludableQueryable<LeaveRequest, LeaveType>)rawData.Where(x => x.LeaveStatus == status);
|
||||
|
||||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> GetRestDayTotalByYearForUserAsync(Guid keycloakUserId, int year)
|
||||
{
|
||||
var leaveType = await _dbContext.Set<LeaveType>().AsQueryable().FirstOrDefaultAsync(l => l.Code.Trim().ToUpper() == "LV-005");
|
||||
|
|
@ -131,6 +164,18 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return data;
|
||||
}
|
||||
|
||||
public async Task<LeaveRequest?> GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||
.Where(x => x.Type.Id == leaveTypeId)
|
||||
.OrderByDescending(x => x.LeaveStartDate.Date)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue