UserTaskController.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 UserTaskController : ControllerBase
  13. {
  14. private readonly IUserTaskService _userTaskService;
  15. private readonly IUserTaskAttachmentService _attachmentService;
  16. private readonly IUserTaskHistoryService _taskHistoryService;
  17. public UserTaskController(IUserTaskService userUserTaskService, IUserTaskAttachmentService attachmentService)
  18. {
  19. this._userTaskService = userUserTaskService;
  20. _attachmentService = attachmentService;
  21. }
  22. [HttpGet("GetAll")]
  23. public async Task<ActionResult<List<UserTaskDto>>> GetAll([FromQuery]PagingInputDto pagingInput)
  24. {
  25. return Ok(await _userTaskService.GetAll(pagingInput));
  26. }
  27. [HttpGet("Get")]
  28. public async Task<ActionResult<UserTaskDto>> Get(long UserTaskId)
  29. {
  30. return Ok(await _userTaskService.GetById(UserTaskId));
  31. }
  32. [HttpPost("Create")]
  33. [ProducesResponseType(StatusCodes.Status200OK)]
  34. public async Task<ActionResult<UserTaskDto>> Create([FromBody] UserTaskDto input)
  35. {
  36. return await _userTaskService.Create(input);
  37. }
  38. [HttpPost("Update")]
  39. [ProducesResponseType(StatusCodes.Status200OK)]
  40. public async Task Update([FromBody] UserTaskDto input)
  41. {
  42. await _userTaskService.Update(input);
  43. }
  44. [HttpPost("Delete")]
  45. [ProducesResponseType(StatusCodes.Status200OK)]
  46. public async Task Delete(long id)
  47. {
  48. await _userTaskService.Delete(id);
  49. }
  50. #region attachments
  51. [HttpPost("CreateAttachment")]
  52. [ProducesResponseType(StatusCodes.Status200OK)]
  53. public async Task<ActionResult<AttachmentDto>> CreateAttachment([FromBody] AttachmentDto input)
  54. {
  55. return await _attachmentService.Create(input);
  56. }
  57. [HttpPost("UpdateAttachment")]
  58. [ProducesResponseType(StatusCodes.Status200OK)]
  59. public async Task UpdateAttachment([FromBody] AttachmentDto input)
  60. {
  61. await _attachmentService.Update(input);
  62. }
  63. [HttpPost("DeleteAttachment")]
  64. [ProducesResponseType(StatusCodes.Status200OK)]
  65. public async Task DeleteAttachment(long id)
  66. {
  67. await _attachmentService.Delete(id);
  68. }
  69. #endregion
  70. #region History
  71. [HttpPost("CreateTaskHistory")]
  72. [ProducesResponseType(StatusCodes.Status200OK)]
  73. public async Task<ActionResult<UserTaskHistoryDto>> CreateTaskHistory([FromBody] UserTaskHistoryDto input)
  74. {
  75. return await _taskHistoryService.Create(input);
  76. }
  77. [HttpPost("UpdateTaskHistory")]
  78. [ProducesResponseType(StatusCodes.Status200OK)]
  79. public async Task UpdateTaskHistory([FromBody] UserTaskHistoryDto input)
  80. {
  81. await _taskHistoryService.Update(input);
  82. }
  83. [HttpPost("DeleteTaskHistory")]
  84. [ProducesResponseType(StatusCodes.Status200OK)]
  85. public async Task DeleteTaskHistory(long id)
  86. {
  87. await _taskHistoryService.Delete(id);
  88. }
  89. #endregion
  90. }
  91. }