OrderRequestController.cs 2.6 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.Identity;
  6. using MTWorkHR.Application.Models;
  7. using MTWorkHR.Application.Services.Interfaces;
  8. using MTWorkHR.Identity.Services;
  9. namespace MTWorkHR.API.Controllers
  10. {
  11. [Route("api/[controller]")]
  12. [ApiController]
  13. [AppAuthorize]
  14. public class OrderRequestController : ControllerBase
  15. {
  16. private readonly IOrderRequestService _LeaveRequestService;
  17. public OrderRequestController(IOrderRequestService UserLeaveRequestService)
  18. {
  19. this._LeaveRequestService = UserLeaveRequestService;
  20. }
  21. [HttpGet("GetAll")]
  22. [ProducesResponseType(StatusCodes.Status200OK)]
  23. [AppAuthorize(Permissions = "OrderRequest")]
  24. public async Task<ActionResult<List<OrderRequestDto>>> GetAll([FromQuery] OrderPagingInputDto pagingInput)
  25. {
  26. return Ok(await _LeaveRequestService.GetAll(pagingInput));
  27. }
  28. [HttpGet("Get")]
  29. [ProducesResponseType(StatusCodes.Status200OK)]
  30. [AppAuthorize(Permissions = "OrderRequest")]
  31. public async Task<ActionResult<OrderRequestDto>> Get(long OrderRequestId)
  32. {
  33. return Ok(await _LeaveRequestService.GetById(OrderRequestId));
  34. }
  35. [HttpPost("Create")]
  36. [ProducesResponseType(StatusCodes.Status200OK)]
  37. [AppAuthorize(Permissions = "OrderRequest.Create")]
  38. public async Task<ActionResult<OrderRequestDto>> Create([FromBody] OrderRequestDto input)
  39. {
  40. return await _LeaveRequestService.Create(input);
  41. }
  42. [HttpPost("Update")]
  43. [ProducesResponseType(StatusCodes.Status200OK)]
  44. [AppAuthorize(Permissions = "OrderRequest.Update")]
  45. public async Task<ActionResult<OrderRequestDto>> Update([FromBody] OrderRequestDto input)
  46. {
  47. return await _LeaveRequestService.Update(input);
  48. }
  49. [HttpDelete("Delete")]
  50. [ProducesResponseType(StatusCodes.Status200OK)]
  51. [AppAuthorize(Permissions = "OrderRequest.Delete")]
  52. public async Task Delete([FromQuery]long id)
  53. {
  54. await _LeaveRequestService.Delete(id);
  55. }
  56. [HttpPost("ChangeStatus")]
  57. [ProducesResponseType(StatusCodes.Status200OK)]
  58. [AppAuthorize(Permissions = "OrderRequest.Update")]
  59. public async Task ChangeStatus([FromBody] OrderStatusDto input)
  60. {
  61. await _LeaveRequestService.ChangeStatus(input.OrderId, input.StatusId);
  62. }
  63. }
  64. }