|
@@ -36,14 +36,14 @@ namespace MTWorkHR.Application.Services
|
|
|
|
|
|
public override async Task<OrderRequestDto> GetById(long id)
|
|
|
{
|
|
|
- var entity = await _unitOfWork.OrderRequest.GetByIdAsync(id);
|
|
|
+ var entity = await _unitOfWork.OrderRequest.GetByIdWithAllChildren(id);
|
|
|
var response = MapperObject.Mapper.Map<OrderRequestDto>(entity);
|
|
|
return response;
|
|
|
}
|
|
|
public override async Task<OrderRequestDto> Create(OrderRequestDto input)
|
|
|
{
|
|
|
var period = DateTime.Now.Year;
|
|
|
- var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId.HasValue?input.LeaveTypeId.Value:0, period);
|
|
|
+ var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId, period);
|
|
|
|
|
|
if (allocation is null)
|
|
|
{
|
|
@@ -93,7 +93,7 @@ namespace MTWorkHR.Application.Services
|
|
|
orderRequest.OrderStatus = (ApprovalStatusEnum)statusId;
|
|
|
if (orderRequest.OrderStatus == ApprovalStatusEnum.Approved)
|
|
|
{
|
|
|
- var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId.HasValue ? orderRequest.LeaveTypeId.Value : 0, DateTime.Now.Year);
|
|
|
+ var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId, DateTime.Now.Year);
|
|
|
int daysRequested = !orderRequest.EndDate.HasValue ? 1 : (int)(orderRequest.EndDate.Value - orderRequest.StartDate).TotalDays;
|
|
|
allocation.NumberOfDays -= daysRequested;
|
|
|
}
|