|
@@ -3,13 +3,10 @@ using MTWorkHR.Application.Models;
|
|
using MTWorkHR.Core.UnitOfWork;
|
|
using MTWorkHR.Core.UnitOfWork;
|
|
using MTWorkHR.Application.Services.Interfaces;
|
|
using MTWorkHR.Application.Services.Interfaces;
|
|
using MTWorkHR.Core.Entities;
|
|
using MTWorkHR.Core.Entities;
|
|
-using Microsoft.AspNetCore.Identity;
|
|
|
|
using MTWorkHR.Application.Mapper;
|
|
using MTWorkHR.Application.Mapper;
|
|
using MTWorkHR.Core.Global;
|
|
using MTWorkHR.Core.Global;
|
|
-using MTWorkHR.Infrastructure.Entities;
|
|
|
|
-using MTWorkHR.Infrastructure.Repositories;
|
|
|
|
-using MTWorkHR.Infrastructure.UnitOfWorks;
|
|
|
|
-using MTWorkHR.Core.IRepositories.Base;
|
|
|
|
|
|
+using Microsoft.EntityFrameworkCore;
|
|
|
|
+using System.Linq.Dynamic.Core;
|
|
|
|
|
|
namespace MTWorkHR.Application.Services
|
|
namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
@@ -19,11 +16,13 @@ namespace MTWorkHR.Application.Services
|
|
//private readonly AppSettingsConfiguration _configuration;
|
|
//private readonly AppSettingsConfiguration _configuration;
|
|
//private readonly GlobalInfo _globalInfo;
|
|
//private readonly GlobalInfo _globalInfo;
|
|
private readonly IFileService _fileService;
|
|
private readonly IFileService _fileService;
|
|
|
|
+ private readonly GlobalInfo _globalInfo;
|
|
|
|
|
|
- public UserTaskService(IUnitOfWork unitOfWork, IFileService fileService) : base(unitOfWork)
|
|
|
|
|
|
+ public UserTaskService(IUnitOfWork unitOfWork, IFileService fileService, GlobalInfo globalInfo) : base(unitOfWork)
|
|
{
|
|
{
|
|
_unitOfWork = unitOfWork;
|
|
_unitOfWork = unitOfWork;
|
|
_fileService = fileService;
|
|
_fileService = fileService;
|
|
|
|
+ _globalInfo = globalInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -33,20 +32,46 @@ namespace MTWorkHR.Application.Services
|
|
var response = MapperObject.Mapper.Map<UserTaskDto>(entity);
|
|
var response = MapperObject.Mapper.Map<UserTaskDto>(entity);
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
- public async Task<UserTaskDto> GetByUserId(long userId)
|
|
|
|
|
|
+ public async Task<UserTaskDto> GetByUserId(string userId)
|
|
{
|
|
{
|
|
var entity = await _unitOfWork.UserTask.GetByUserIdWithAllChildren(userId);
|
|
var entity = await _unitOfWork.UserTask.GetByUserIdWithAllChildren(userId);
|
|
var response = MapperObject.Mapper.Map<UserTaskDto>(entity);
|
|
var response = MapperObject.Mapper.Map<UserTaskDto>(entity);
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
- //public override async Task<List<ProjectDto>> GetAll()
|
|
|
|
- //{
|
|
|
|
- // var projects = await _unitOfWork.Project.GetAllAsync();
|
|
|
|
- // var response = MapperObject.Mapper.Map<List<ProjectDto>>(projects);
|
|
|
|
- // return response;
|
|
|
|
- //}
|
|
|
|
|
|
+ public override async Task<PagingResultDto<UserTaskDto>> GetAll(PagingInputDto PagingInputDto)
|
|
|
|
+ {
|
|
|
|
+ var res = await _unitOfWork.UserTask.GetAllWithChildrenAsync();
|
|
|
|
+ var query = res.Item1;
|
|
|
|
+
|
|
|
|
+ if (_globalInfo.UserType != UserTypeEnum.Business)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(m => m.AssignedUserId == _globalInfo.UserId);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.Filter != null)
|
|
|
|
+ {
|
|
|
|
+ var filter = PagingInputDto.Filter;
|
|
|
|
+ query = query.Where(u => u.Title.Contains(filter) || u.Description.Contains(filter));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
|
|
|
|
|
|
|
|
+ var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);
|
|
|
|
+
|
|
|
|
+ var total = await query.CountAsync();
|
|
|
|
+
|
|
|
|
+ var list = MapperObject.Mapper
|
|
|
|
+ .Map<IList<UserTaskDto>>(await page.ToListAsync());
|
|
|
|
+
|
|
|
|
+ var response = new PagingResultDto<UserTaskDto>
|
|
|
|
+ {
|
|
|
|
+ Result = list,
|
|
|
|
+ Total = total
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
|
|
public override async Task<UserTaskDto> Create(UserTaskDto input)
|
|
public override async Task<UserTaskDto> Create(UserTaskDto input)
|
|
{
|
|
{
|