ContractController.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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("CreateTaskAttachment")]
  65. //[ProducesResponseType(StatusCodes.Status200OK)]
  66. //[Consumes("multipart/form-data")]
  67. //public async Task<ActionResult<AttachmentDto>> CreateTaskAttachment([FromForm] AttachmentDto input)
  68. //{
  69. // return await _ContractTaskAttachmentService.Create(input);
  70. //}
  71. //[HttpPost("CreateProjectAttachment")]
  72. //[ProducesResponseType(StatusCodes.Status200OK)]
  73. //[Consumes("multipart/form-data")]
  74. //public async Task<ActionResult<AttachmentDto>> CreateProjectAttachment([FromForm] AttachmentDto input)
  75. //{
  76. // return await _ProjectStageAttachmentService.Create(input);
  77. //}
  78. }
  79. }