OrderRequestController.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. public async Task<ActionResult<List<OrderRequestDto>>> GetAll([FromQuery] OrderPagingInputDto pagingInput)
  24. {
  25. return Ok(await _LeaveRequestService.GetAll(pagingInput));
  26. }
  27. [HttpGet("Get")]
  28. [ProducesResponseType(StatusCodes.Status200OK)]
  29. public async Task<ActionResult<OrderRequestDto>> Get(long OrderRequestId)
  30. {
  31. return Ok(await _LeaveRequestService.GetById(OrderRequestId));
  32. }
  33. [HttpPost("Create")]
  34. [ProducesResponseType(StatusCodes.Status200OK)]
  35. public async Task<ActionResult<OrderRequestDto>> Create([FromBody] OrderRequestDto input)
  36. {
  37. return await _LeaveRequestService.Create(input);
  38. }
  39. [HttpPost("Update")]
  40. [ProducesResponseType(StatusCodes.Status200OK)]
  41. public async Task<ActionResult<OrderRequestDto>> Update([FromBody] OrderRequestDto input)
  42. {
  43. return await _LeaveRequestService.Update(input);
  44. }
  45. [HttpDelete("Delete")]
  46. [ProducesResponseType(StatusCodes.Status200OK)]
  47. public async Task Delete([FromQuery]long id)
  48. {
  49. await _LeaveRequestService.Delete(id);
  50. }
  51. [HttpPost("ChangeStatus")]
  52. [ProducesResponseType(StatusCodes.Status200OK)]
  53. public async Task ChangeStatus([FromBody] OrderStatusDto input)
  54. {
  55. await _LeaveRequestService.ChangeStatus(input.OrderId, input.StatusId);
  56. }
  57. }
  58. }