12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
-
- 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 ContractTaskAttachmentService : BaseService<ContractTaskAttachment, ContractTaskAttachmentDto, ContractTaskAttachmentDto>, IContractTaskAttachmentService
- {
- private readonly IUnitOfWork _unitOfWork;
-
-
- private readonly IFileService _fileService;
- public ContractTaskAttachmentService(IUnitOfWork unitOfWork, IFileService fileService) : base(unitOfWork)
- {
- _unitOfWork = unitOfWork;
- _fileService = fileService;
- }
- public override async Task<ContractTaskAttachmentDto> GetById(long id)
- {
- var entity = await _unitOfWork.ContractTaskAttachment.GetByIdAsync(id);
- var response = MapperObject.Mapper.Map<ContractTaskAttachmentDto>(entity);
- return response;
- }
- public override async Task<ContractTaskAttachmentDto> Create(ContractTaskAttachmentDto 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<ContractTaskAttachmentDto>(task);
-
-
-
-
-
-
-
-
-
-
-
-
-
- return response;
- }
-
-
-
-
-
-
-
-
-
- }
- }
|