|
@@ -3,6 +3,12 @@ using MTWorkHR.Application.Models;
|
|
|
using MTWorkHR.Core.UnitOfWork;
|
|
|
using MTWorkHR.Application.Services.Interfaces;
|
|
|
using MTWorkHR.Core.Entities;
|
|
|
+using Microsoft.AspNetCore.Identity;
|
|
|
+using MTWorkHR.Application.Mapper;
|
|
|
+using MTWorkHR.Core.Global;
|
|
|
+using MTWorkHR.Identity.Entities;
|
|
|
+using MTWorkHR.Infrastructure.Repositories;
|
|
|
+using MTWorkHR.Infrastructure.UnitOfWorks;
|
|
|
|
|
|
namespace MTWorkHR.Application.Services
|
|
|
{
|
|
@@ -11,10 +17,12 @@ namespace MTWorkHR.Application.Services
|
|
|
private readonly IUnitOfWork _unitOfWork;
|
|
|
//private readonly AppSettingsConfiguration _configuration;
|
|
|
//private readonly GlobalInfo _globalInfo;
|
|
|
+ private readonly IFileService _fileService;
|
|
|
|
|
|
- public UserTaskService(IUnitOfWork unitOfWork):base(unitOfWork)
|
|
|
+ public UserTaskService(IUnitOfWork unitOfWork, IFileService fileService) : base(unitOfWork)
|
|
|
{
|
|
|
_unitOfWork = unitOfWork;
|
|
|
+ _fileService = fileService;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -32,13 +40,23 @@ namespace MTWorkHR.Application.Services
|
|
|
// return response;
|
|
|
//}
|
|
|
|
|
|
- //public override async Task Delete(long id)
|
|
|
- //{
|
|
|
- // var entity = await _unitOfWork.Project.GetByIdAsync(id);
|
|
|
- // await _unitOfWork.Project.DeleteAsync(entity);
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
+ public override async Task<UserTaskDto> Create(UserTaskDto input)
|
|
|
+ {
|
|
|
+ if(input.TaskAttachments?.Count > 0)
|
|
|
+ if ( !await _fileService.CopyFileToActualFolder(input.TaskAttachments.ToList()))
|
|
|
+ throw new AppException(ExceptionEnum.CouldNotMoveFiles);
|
|
|
+ var entity = Mapper.MapperObject.Mapper.Map<UserTask>(input);
|
|
|
+ if (entity is null)
|
|
|
+ {
|
|
|
+ throw new AppException(ExceptionEnum.MapperIssue);
|
|
|
+ }
|
|
|
+
|
|
|
+ var task = await _unitOfWork.UserTask.AddAsync(entity);
|
|
|
+ await _unitOfWork.CompleteAsync();
|
|
|
+
|
|
|
+ var response = Mapper.MapperObject.Mapper.Map<UserTaskDto>(task);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
}
|
|
|
}
|