|
@@ -15,6 +15,7 @@ using MTWorkHR.Core.Entities;
|
|
using MTWorkHR.Infrastructure.UnitOfWorks;
|
|
using MTWorkHR.Infrastructure.UnitOfWorks;
|
|
using MTWorkHR.Core.Entities.User;
|
|
using MTWorkHR.Core.Entities.User;
|
|
using System.Linq.Dynamic.Core;
|
|
using System.Linq.Dynamic.Core;
|
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
namespace MTWorkHR.Application.Services
|
|
namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
@@ -44,7 +45,7 @@ namespace MTWorkHR.Application.Services
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
- public override async Task<PagingResultDto<OrderRequestDto>> GetAll(PagingInputDto PagingInputDto)
|
|
|
|
|
|
+ public async Task<PagingResultDto<OrderRequestDto>> GetAll(OrderPagingInputDto PagingInputDto)
|
|
{
|
|
{
|
|
var res = await _unitOfWork.OrderRequest.GetAllWithChildrenAsync();
|
|
var res = await _unitOfWork.OrderRequest.GetAllWithChildrenAsync();
|
|
var query = res.Item1;
|
|
var query = res.Item1;
|
|
@@ -53,7 +54,31 @@ namespace MTWorkHR.Application.Services
|
|
query = query.Where(m => m.RequestingEmployeeId != null && m.RequestingEmployeeId == _globalInfo.UserId);
|
|
query = query.Where(m => m.RequestingEmployeeId != null && m.RequestingEmployeeId == _globalInfo.UserId);
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if (PagingInputDto.Filter != null)
|
|
|
|
+ {
|
|
|
|
+ var filter = PagingInputDto.Filter;
|
|
|
|
+ query = query.Where(u => u.RequestComments!.Contains(filter)
|
|
|
|
+ || u.OrderType.NameEn!.Contains(filter)
|
|
|
|
+ || u.OrderType.NameAr!.Contains(filter)
|
|
|
|
+ || u.LeaveType!.NameEn!.Contains(filter)
|
|
|
|
+ || u.LeaveType!.NameAr!.Contains(filter));
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.SearchDate != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.StartDate.Date <= PagingInputDto.SearchDate.Value.Date && u.EndDate!.Value.Date >= PagingInputDto.SearchDate.Value.Date) ;
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.OrderTypeId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.OrderTypeId == PagingInputDto.OrderTypeId);
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.LeaveTypeId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.LeaveTypeId == PagingInputDto.LeaveTypeId);
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.StatusId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => (long?)u.OrderStatus == PagingInputDto.StatusId);
|
|
|
|
+ }
|
|
var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
|
|
var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
|
|
|
|
|
|
var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);
|
|
var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);
|
|
@@ -62,7 +87,34 @@ namespace MTWorkHR.Application.Services
|
|
|
|
|
|
var list = MapperObject.Mapper
|
|
var list = MapperObject.Mapper
|
|
.Map<IList<OrderRequestDto>>(await page.ToListAsync());
|
|
.Map<IList<OrderRequestDto>>(await page.ToListAsync());
|
|
-
|
|
|
|
|
|
+ foreach (var item in list)
|
|
|
|
+ {
|
|
|
|
+ if (item.RequestingEmployeeId != null)
|
|
|
|
+ {
|
|
|
|
+ var user = await _userService.GetUserWithAttachmentById(item.RequestingEmployeeId);
|
|
|
|
+ if (user != null)
|
|
|
|
+ {
|
|
|
|
+ item.Employee = user;
|
|
|
|
+ var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
|
|
|
|
+ if(attach != null)
|
|
|
|
+ using (var stream = new MemoryStream(attach.Content))
|
|
|
|
+ {
|
|
|
|
+ var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
|
|
|
|
+ {
|
|
|
|
+ Headers = new HeaderDictionary(),
|
|
|
|
+ ContentType = attach.ContentType,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
|
|
|
|
+ {
|
|
|
|
+ FileName = file.FileName
|
|
|
|
+ };
|
|
|
|
+ file.ContentDisposition = cd.ToString();
|
|
|
|
+ item.Employee.ProfileImage = file;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
var response = new PagingResultDto<OrderRequestDto>
|
|
var response = new PagingResultDto<OrderRequestDto>
|
|
{
|
|
{
|
|
Result = list,
|
|
Result = list,
|
|
@@ -117,7 +169,31 @@ namespace MTWorkHR.Application.Services
|
|
//// Log or handle error, but don't throw...
|
|
//// Log or handle error, but don't throw...
|
|
}
|
|
}
|
|
var response = MapperObject.Mapper.Map<OrderRequestDto>(orderRequest);
|
|
var response = MapperObject.Mapper.Map<OrderRequestDto>(orderRequest);
|
|
-
|
|
|
|
|
|
+ if (response.RequestingEmployeeId != null)
|
|
|
|
+ {
|
|
|
|
+ var user = await _userService.GetUserWithAttachmentById(response.RequestingEmployeeId);
|
|
|
|
+ if (user != null)
|
|
|
|
+ {
|
|
|
|
+ response.Employee = user;
|
|
|
|
+ var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
|
|
|
|
+ if (attach != null)
|
|
|
|
+ using (var stream = new MemoryStream(attach.Content))
|
|
|
|
+ {
|
|
|
|
+ var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
|
|
|
|
+ {
|
|
|
|
+ Headers = new HeaderDictionary(),
|
|
|
|
+ ContentType = attach.ContentType,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
|
|
|
|
+ {
|
|
|
|
+ FileName = file.FileName
|
|
|
|
+ };
|
|
|
|
+ file.ContentDisposition = cd.ToString();
|
|
|
|
+ response.Employee.ProfileImage = file;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|