ContractController.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. public ContractController(IContractService UserContractService)
  17. {
  18. this._ContractService = UserContractService;
  19. }
  20. [HttpGet("GetAll")]
  21. [ProducesResponseType(StatusCodes.Status200OK)]
  22. public async Task<ActionResult<List<ContractDto>>> GetAll([FromQuery] ContractPagingInputDto pagingInput)
  23. {
  24. return Ok(await _ContractService.GetAll(pagingInput));
  25. }
  26. [HttpGet("Get")]
  27. [ProducesResponseType(StatusCodes.Status200OK)]
  28. // [AppAuthorize(Permissions = "Contract")]
  29. public async Task<ActionResult<ContractDto>> Get(long ContractId)
  30. {
  31. return Ok(await _ContractService.GetById(ContractId));
  32. }
  33. [HttpPost("Create")]
  34. [ProducesResponseType(StatusCodes.Status200OK)]
  35. // [AppAuthorize(Permissions = "Contract.Create")]
  36. public async Task<ActionResult<ContractDto>> Create([FromBody] ContractDto input)
  37. {
  38. return await _ContractService.Create(input);
  39. }
  40. [HttpPost("Update")]
  41. [ProducesResponseType(StatusCodes.Status200OK)]
  42. // [AppAuthorize(Permissions = "Contract.Update")]
  43. public async Task Update([FromBody] ContractDto input)
  44. {
  45. await _ContractService.Update(input);
  46. }
  47. [HttpDelete("Delete")]
  48. [ProducesResponseType(StatusCodes.Status200OK)]
  49. // [AppAuthorize(Permissions = "Contract.Delete")]
  50. public async Task Delete([FromQuery] long id)
  51. {
  52. await _ContractService.Delete(id);
  53. }
  54. [HttpPost("ChangeStatus")]
  55. [ProducesResponseType(StatusCodes.Status200OK)]
  56. public async Task<bool> ChangeStatus([FromBody] ContractStatusDto input)
  57. {
  58. return await _ContractService.ChangeStatus(input.ContractId, input.StatusId);
  59. }
  60. }
  61. }