|
@@ -0,0 +1,91 @@
|
|
|
+
|
|
|
+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.Infrastructure.Entities;
|
|
|
+using MTWorkHR.Infrastructure.Repositories;
|
|
|
+using MTWorkHR.Infrastructure.UnitOfWorks;
|
|
|
+using MTWorkHR.Core.IRepositories.Base;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using System.IO;
|
|
|
+
|
|
|
+namespace MTWorkHR.Application.Services
|
|
|
+{
|
|
|
+ public class ProjectStageAttachmentService : BaseService<ProjectStageAttachment, ProjectStageAttachmentDto, ProjectStageAttachmentDto>, IProjectStageAttachmentService
|
|
|
+ {
|
|
|
+ private readonly IUnitOfWork _unitOfWork;
|
|
|
+ private readonly IFileService _fileService;
|
|
|
+
|
|
|
+ public ProjectStageAttachmentService(IUnitOfWork unitOfWork, IFileService fileService) : base(unitOfWork)
|
|
|
+ {
|
|
|
+ _unitOfWork = unitOfWork;
|
|
|
+ _fileService = fileService;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public override async Task<ProjectStageAttachmentDto> GetById(long id)
|
|
|
+ {
|
|
|
+ var entity = await _unitOfWork.ContractTaskAttachment.GetByIdAsync(id);
|
|
|
+ var response = MapperObject.Mapper.Map<ProjectStageAttachmentDto>(entity);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override async Task<ProjectStageAttachmentDto> Create(ProjectStageAttachmentDto input)
|
|
|
+ {
|
|
|
+ if (input.FileData != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ input.OriginalName = input.FileData.FileName;
|
|
|
+ List<AttachmentDto> attachs = new List<AttachmentDto>();
|
|
|
+ attachs.Add(new AttachmentDto { FileData = input.FileData, OriginalName = input.OriginalName, FileName = input.FileData.FileName });
|
|
|
+ _fileService.CopyFileToCloud(ref attachs);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var entity = MapperObject.Mapper.Map<ContractTaskAttachment>(input);
|
|
|
+ if (entity is null)
|
|
|
+ {
|
|
|
+ throw new AppException(ExceptionEnum.MapperIssue);
|
|
|
+ }
|
|
|
+
|
|
|
+ var task = await _unitOfWork.ContractTaskAttachment.AddAsync(entity);
|
|
|
+ await _unitOfWork.CompleteAsync();
|
|
|
+
|
|
|
+ var response = MapperObject.Mapper.Map<ProjectStageAttachmentDto>(task);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|