|
@@ -8,6 +8,7 @@ using MTWorkHR.Core.Global;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Linq.Dynamic.Core;
|
|
using System.Linq.Dynamic.Core;
|
|
using MTWorkHR.Core.IDto;
|
|
using MTWorkHR.Core.IDto;
|
|
|
|
+using MTWorkHR.Application.Identity;
|
|
|
|
|
|
namespace MTWorkHR.Application.Services
|
|
namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
@@ -18,12 +19,14 @@ namespace MTWorkHR.Application.Services
|
|
//private readonly GlobalInfo _globalInfo;
|
|
//private readonly GlobalInfo _globalInfo;
|
|
private readonly IFileService _fileService;
|
|
private readonly IFileService _fileService;
|
|
private readonly GlobalInfo _globalInfo;
|
|
private readonly GlobalInfo _globalInfo;
|
|
|
|
+ private readonly IUserService _userService;
|
|
|
|
|
|
- public UserTaskService(IUnitOfWork unitOfWork, IFileService fileService, GlobalInfo globalInfo) : base(unitOfWork)
|
|
|
|
|
|
+ public UserTaskService(IUnitOfWork unitOfWork, IFileService fileService, GlobalInfo globalInfo, IUserService userService) : base(unitOfWork)
|
|
{
|
|
{
|
|
_unitOfWork = unitOfWork;
|
|
_unitOfWork = unitOfWork;
|
|
_fileService = fileService;
|
|
_fileService = fileService;
|
|
_globalInfo = globalInfo;
|
|
_globalInfo = globalInfo;
|
|
|
|
+ _userService = userService;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -40,7 +43,7 @@ namespace MTWorkHR.Application.Services
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
- public override async Task<PagingResultDto<UserTaskDto>> GetAll(PagingInputDto PagingInputDto)
|
|
|
|
|
|
+ public async Task<PagingResultDto<UserTaskAllDto>> GetAll(UserTaskPagingInputDto PagingInputDto)
|
|
{
|
|
{
|
|
var res = await _unitOfWork.UserTask.GetAllWithChildrenAsync();
|
|
var res = await _unitOfWork.UserTask.GetAllWithChildrenAsync();
|
|
var query = res.Item1;
|
|
var query = res.Item1;
|
|
@@ -59,7 +62,22 @@ namespace MTWorkHR.Application.Services
|
|
var filter = PagingInputDto.Filter;
|
|
var filter = PagingInputDto.Filter;
|
|
query = query.Where(u => u.Title.Contains(filter) || u.Description.Contains(filter));
|
|
query = query.Where(u => u.Title.Contains(filter) || u.Description.Contains(filter));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if (PagingInputDto.ProjectId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.ProjectId == PagingInputDto.ProjectId);
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.StatusId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.StatusId == PagingInputDto.StatusId);
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.PriorityId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.Priority == (PriorityEnum)PagingInputDto.PriorityId);
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.AssignedUserId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.AssignedUserId == PagingInputDto.AssignedUserId);
|
|
|
|
+ }
|
|
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);
|
|
@@ -67,9 +85,21 @@ namespace MTWorkHR.Application.Services
|
|
var total = await query.CountAsync();
|
|
var total = await query.CountAsync();
|
|
|
|
|
|
var list = MapperObject.Mapper
|
|
var list = MapperObject.Mapper
|
|
- .Map<IList<UserTaskDto>>(await page.ToListAsync());
|
|
|
|
-
|
|
|
|
- var response = new PagingResultDto<UserTaskDto>
|
|
|
|
|
|
+ .Map<IList<UserTaskAllDto>>(await page.ToListAsync());
|
|
|
|
+ foreach (var item in list)
|
|
|
|
+ {
|
|
|
|
+ if (item.AssignedUserId != null)
|
|
|
|
+ {
|
|
|
|
+ var user = await _userService.GetUserWithAttachmentById(item.AssignedUserId);
|
|
|
|
+ if(user != null)
|
|
|
|
+ {
|
|
|
|
+ item.AssignedUserName = user.FirstName + " " + user.LastName;
|
|
|
|
+ var image = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
|
|
|
|
+ item.ProfileImage = image != null ? image.FilePath:"";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var response = new PagingResultDto<UserTaskAllDto>
|
|
{
|
|
{
|
|
Result = list,
|
|
Result = list,
|
|
Total = total
|
|
Total = total
|