ContractController.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using MTWorkHR.Application.Filters;
  5. using MTWorkHR.Application.Models;
  6. using MTWorkHR.Application.Services;
  7. using MTWorkHR.Application.Services.Interfaces;
  8. namespace MTWorkHR.API.Controllers
  9. {
  10. [Route("api/[controller]")]
  11. [ApiController]
  12. [AppAuthorize]
  13. public class ContractController : ControllerBase
  14. {
  15. private readonly IContractService _ContractService;
  16. private readonly IContractTaskAttachmentService _ContractTaskAttachmentService;
  17. private readonly IProjectStageAttachmentService _ProjectStageAttachmentService;
  18. private readonly IFileService _fileService;
  19. public ContractController(IContractService UserContractService, IFileService fileService)
  20. {
  21. _ContractService = UserContractService;
  22. _fileService = fileService;
  23. }
  24. [HttpGet("GetAll")]
  25. [ProducesResponseType(StatusCodes.Status200OK)]
  26. public async Task<ActionResult<List<ContractDto>>> GetAll([FromQuery] ContractPagingInputDto pagingInput)
  27. {
  28. return Ok(await _ContractService.GetAll(pagingInput));
  29. }
  30. [HttpGet("Get")]
  31. [ProducesResponseType(StatusCodes.Status200OK)]
  32. // [AppAuthorize(Permissions = "Contract")]
  33. public async Task<ActionResult<ContractDto>> Get(long ContractId)
  34. {
  35. return Ok(await _ContractService.GetById(ContractId));
  36. }
  37. [HttpPost("Create")]
  38. [ProducesResponseType(StatusCodes.Status200OK)]
  39. // [AppAuthorize(Permissions = "Contract.Create")]
  40. public async Task<ActionResult<ContractDto>> Create([FromBody] ContractDto input)
  41. {
  42. return await _ContractService.Create(input);
  43. }
  44. [HttpPost("Update")]
  45. [ProducesResponseType(StatusCodes.Status200OK)]
  46. // [AppAuthorize(Permissions = "Contract.Update")]
  47. public async Task Update([FromBody] ContractDto input)
  48. {
  49. await _ContractService.Update(input);
  50. }
  51. [HttpDelete("Delete")]
  52. [ProducesResponseType(StatusCodes.Status200OK)]
  53. // [AppAuthorize(Permissions = "Contract.Delete")]
  54. public async Task Delete([FromQuery] long id)
  55. {
  56. await _ContractService.Delete(id);
  57. }
  58. [HttpPost("ChangeStatus")]
  59. [ProducesResponseType(StatusCodes.Status200OK)]
  60. public async Task<bool> ChangeStatus([FromBody] ContractStatusDto input)
  61. {
  62. return await _ContractService.ChangeStatus(input.ContractId, input.StatusId);
  63. }
  64. [HttpPost("UploadAttachment")]
  65. [ProducesResponseType(StatusCodes.Status200OK)]
  66. [Consumes("multipart/form-data")]
  67. public async Task<ActionResult<string>> UploadAttachment(IFormFile input)
  68. {
  69. return await _fileService.UploadFile(input);
  70. }
  71. //[HttpPost("CreateTaskAttachment")]
  72. //[ProducesResponseType(StatusCodes.Status200OK)]
  73. //[Consumes("multipart/form-data")]
  74. //public async Task<ActionResult<AttachmentDto>> CreateTaskAttachment([FromForm] AttachmentDto input)
  75. //{
  76. // return await _ContractTaskAttachmentService.Create(input);
  77. //}
  78. //[HttpPost("CreateProjectAttachment")]
  79. //[ProducesResponseType(StatusCodes.Status200OK)]
  80. //[Consumes("multipart/form-data")]
  81. //public async Task<ActionResult<AttachmentDto>> CreateProjectAttachment([FromForm] AttachmentDto input)
  82. //{
  83. // return await _ProjectStageAttachmentService.Create(input);
  84. //}
  85. }
  86. }