ContractPdfService.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 
  2. using MTWorkHR.Application.Models;
  3. using MTWorkHR.Core.UnitOfWork;
  4. using MTWorkHR.Application.Services.Interfaces;
  5. using MTWorkHR.Core.Entities;
  6. using Microsoft.AspNetCore.Identity;
  7. using MTWorkHR.Application.Mapper;
  8. using MTWorkHR.Core.Global;
  9. using MTWorkHR.Infrastructure.Entities;
  10. using MTWorkHR.Infrastructure.Repositories;
  11. using MTWorkHR.Infrastructure.UnitOfWorks;
  12. using MTWorkHR.Core.IRepositories.Base;
  13. using Microsoft.AspNetCore.Http;
  14. using System.IO;
  15. using MTWorkHR.Infrastructure.Reports;
  16. using MTWorkHR.Core.Entities.Base;
  17. using Microsoft.Extensions.Logging;
  18. using MTWorkHR.Application.Identity;
  19. namespace MTWorkHR.Application.Services
  20. {
  21. public class ContractPdfService
  22. {
  23. // private readonly IContractService _contractService;
  24. // // private readonly IFileService _fileService;
  25. // private readonly IUnitOfWork _unitOfWork;
  26. //// private ILogger _logger;
  27. // private readonly IUserService _userService;
  28. // public ContractPdfService(IUnitOfWork unitOfWork, IContractService contractService, IUserService userService)
  29. // {
  30. // _unitOfWork = unitOfWork;
  31. // _userService = userService;
  32. // _contractService = contractService;
  33. // // _fileService = fileService;
  34. // }
  35. // public async Task GenerateContractPdf(string outputPath, long contractId)
  36. // {
  37. // try
  38. // {
  39. // // var contractData = await _unitOfWork.Contract.GetByIdWithAllChildren(contractId);
  40. // // // var contractData = new Contract { CompanyId = 1, JobTitleName = "SW Developer", ProjectStages = new List<ProjectStage> { new ProjectStage { Title = "Team Project", ScopeOfWork = "testing" } } };
  41. // // var contract = MapperObject.Mapper.Map<ContractDetail>(contractData);
  42. // // var user = await _userService.GetUserById(contractData.UserId);
  43. // // if (user != null)
  44. // // {
  45. // // contract.EmployeeName = user.FirstName + " " + user.LastName;
  46. // // contract.EmployeeEmail = user.Email;
  47. // // contract.EmployeePassport = user.PassportNumber;
  48. // // contract.EmployeePhone = user.PhoneNumber;
  49. // // contract.EmployeeUniversity = user.UniversityName;
  50. // // contract.AcademicQualification = user.QualificationName;
  51. // // contract.EmployeeJobName = user.JobTitleName;
  52. // // }
  53. // var contract = await _contractService.GetByIdReport(contractId);
  54. // var x = await new ContractPdfGenerator().GenerateContractPdf(outputPath, contract);
  55. // }catch(Exception e)
  56. // {
  57. // // _logger.LogError(e, "Failed to generate contract PDF for contractId {ContractId}", contractId);
  58. // var msg = e.Message;
  59. // }
  60. // }
  61. }
  62. }