OrderRequestController.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using MTWorkHR.Application.Identity;
  5. using MTWorkHR.Application.Models;
  6. using MTWorkHR.Application.Services.Interfaces;
  7. using MTWorkHR.Identity.Services;
  8. namespace MTWorkHR.API.Controllers
  9. {
  10. [Route("api/[controller]")]
  11. [ApiController]
  12. public class OrderRequestController : ControllerBase
  13. {
  14. private readonly IOrderRequestService _LeaveRequestService;
  15. public OrderRequestController(IOrderRequestService UserLeaveRequestService)
  16. {
  17. this._LeaveRequestService = UserLeaveRequestService;
  18. }
  19. [HttpGet("GetAll")]
  20. [ProducesResponseType(StatusCodes.Status200OK)]
  21. public async Task<ActionResult<List<OrderRequestDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
  22. {
  23. return Ok(await _LeaveRequestService.GetAll(pagingInput));
  24. }
  25. [HttpGet("Get")]
  26. [ProducesResponseType(StatusCodes.Status200OK)]
  27. public async Task<ActionResult<OrderRequestDto>> Get(long OrderRequestId)
  28. {
  29. return Ok(await _LeaveRequestService.GetById(OrderRequestId));
  30. }
  31. [HttpPost("Create")]
  32. [ProducesResponseType(StatusCodes.Status200OK)]
  33. public async Task<ActionResult<OrderRequestDto>> Create([FromBody] OrderRequestDto input)
  34. {
  35. return await _LeaveRequestService.Create(input);
  36. }
  37. [HttpPost("Update")]
  38. [ProducesResponseType(StatusCodes.Status200OK)]
  39. public async Task Update([FromBody] OrderRequestDto input)
  40. {
  41. await _LeaveRequestService.Update(input);
  42. }
  43. [HttpPost("Delete")]
  44. [ProducesResponseType(StatusCodes.Status200OK)]
  45. public async Task Delete(long id)
  46. {
  47. await _LeaveRequestService.Delete(id);
  48. }
  49. [HttpPost("ChangeStatus")]
  50. [ProducesResponseType(StatusCodes.Status200OK)]
  51. public async Task ChangeStatus(long id, int statusId)
  52. {
  53. await _LeaveRequestService.ChangeStatus(id, statusId);
  54. }
  55. }
  56. }