12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
-
- 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;
- namespace MTWorkHR.Application.Services
- {
- public class UserTaskAttachmentService : BaseService<UserTaskAttachment, AttachmentDto, AttachmentDto>, IUserTaskAttachmentService
- {
- private readonly IUnitOfWork _unitOfWork;
- //private readonly AppSettingsConfiguration _configuration;
- //private readonly GlobalInfo _globalInfo;
- private readonly IFileService _fileService;
- public UserTaskAttachmentService(IUnitOfWork unitOfWork, IFileService fileService) : base(unitOfWork)
- {
- _unitOfWork = unitOfWork;
- _fileService = fileService;
- }
- public override async Task<AttachmentDto> GetById(long id)
- {
- var entity = await _unitOfWork.UserTaskAttachment.GetByIdAsync(id);
- var response = MapperObject.Mapper.Map<AttachmentDto>(entity);
- return response;
- }
- public override async Task<AttachmentDto> Create(AttachmentDto input)
- {
- if (input.FileData != null)
- input.FileName = await _fileService.UploadFile(input.FileData);
- var entity = MapperObject.Mapper.Map<UserTaskAttachment>(input);
- if (entity is null)
- {
- throw new AppException(ExceptionEnum.MapperIssue);
- }
- var task = await _unitOfWork.UserTaskAttachment.AddAsync(entity);
- await _unitOfWork.CompleteAsync();
- var response = MapperObject.Mapper.Map<AttachmentDto>(task);
- return response;
- }
- //public override async Task<AttachmentDto> Update(AttachmentDto input)
- //{
- // var entitiy = await _unitOfWork.UserTaskAttachment.GetByIdAsync(input.Id);
- // if (entitiy == null)
- // throw new AppException(ExceptionEnum.RecordNotExist);
- // MapperObject.Mapper.Map(input, entitiy, typeof(AttachmentDto), typeof(UserTaskAttachment));
- // await _unitOfWork.CompleteAsync();
- // return input;
- //}
- }
- }
|