OrderAllocationController.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 OrderAllocationController : ControllerBase
  15. {
  16. private readonly IOrderAllocationService _OrderAllocationService;
  17. public OrderAllocationController(IOrderAllocationService UserOrderAllocationService)
  18. {
  19. this._OrderAllocationService = UserOrderAllocationService;
  20. }
  21. [HttpGet("GetAll")]
  22. [ProducesResponseType(StatusCodes.Status200OK)]
  23. [AppAuthorize(Permissions = "OrderAllocation")]
  24. public async Task<ActionResult<List<OrderAllocationDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
  25. {
  26. return Ok(await _OrderAllocationService.GetAll(pagingInput));
  27. }
  28. [HttpGet("Get")]
  29. [ProducesResponseType(StatusCodes.Status200OK)]
  30. [AppAuthorize(Permissions = "OrderAllocation")]
  31. public async Task<ActionResult<OrderAllocationDto>> Get(long OrderAllocationId)
  32. {
  33. return Ok(await _OrderAllocationService.GetById(OrderAllocationId));
  34. }
  35. [HttpPost("Create")]
  36. [ProducesResponseType(StatusCodes.Status200OK)]
  37. [AppAuthorize(Permissions = "OrderAllocation.Create")]
  38. public async Task<ActionResult<OrderAllocationDto>> Create([FromBody] OrderAllocationDto input)
  39. {
  40. return await _OrderAllocationService.Create(input);
  41. }
  42. [HttpPost("Update")]
  43. [ProducesResponseType(StatusCodes.Status200OK)]
  44. [AppAuthorize(Permissions = "OrderAllocation.Update")]
  45. public async Task Update([FromBody] OrderAllocationDto input)
  46. {
  47. await _OrderAllocationService.Update(input);
  48. }
  49. [HttpDelete("Delete")]
  50. [ProducesResponseType(StatusCodes.Status200OK)]
  51. [AppAuthorize(Permissions = "OrderAllocation.Delete")]
  52. public async Task Delete([FromQuery]long id)
  53. {
  54. await _OrderAllocationService.Delete(id);
  55. }
  56. }
  57. }