ContractController.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.Interfaces;
  7. namespace MTWorkHR.API.Controllers
  8. {
  9. [Route("api/[controller]")]
  10. [ApiController]
  11. [AppAuthorize]
  12. public class ContractController : ControllerBase
  13. {
  14. private readonly IContractService _ContractService;
  15. public ContractController(IContractService UserContractService)
  16. {
  17. this._ContractService = UserContractService;
  18. }
  19. [HttpGet("GetAll")]
  20. [ProducesResponseType(StatusCodes.Status200OK)]
  21. public async Task<ActionResult<List<ContractDto>>> GetAll([FromQuery] ContractPagingInputDto pagingInput)
  22. {
  23. return Ok(await _ContractService.GetAll(pagingInput));
  24. }
  25. [HttpGet("Get")]
  26. [ProducesResponseType(StatusCodes.Status200OK)]
  27. // [AppAuthorize(Permissions = "Contract")]
  28. public async Task<ActionResult<ContractDto>> Get(long ContractId)
  29. {
  30. return Ok(await _ContractService.GetById(ContractId));
  31. }
  32. [HttpPost("Create")]
  33. [ProducesResponseType(StatusCodes.Status200OK)]
  34. // [AppAuthorize(Permissions = "Contract.Create")]
  35. public async Task<ActionResult<ContractDto>> Create([FromBody] ContractDto input)
  36. {
  37. return await _ContractService.Create(input);
  38. }
  39. [HttpPost("Update")]
  40. [ProducesResponseType(StatusCodes.Status200OK)]
  41. // [AppAuthorize(Permissions = "Contract.Update")]
  42. public async Task Update([FromBody] ContractDto input)
  43. {
  44. await _ContractService.Update(input);
  45. }
  46. [HttpDelete("Delete")]
  47. [ProducesResponseType(StatusCodes.Status200OK)]
  48. // [AppAuthorize(Permissions = "Contract.Delete")]
  49. public async Task Delete([FromQuery] long id)
  50. {
  51. await _ContractService.Delete(id);
  52. }
  53. }
  54. }