123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using MTWorkHR.Application.Filters;
- using MTWorkHR.Application.Identity;
- using MTWorkHR.Application.Models;
- using MTWorkHR.Application.Services.Interfaces;
- using MTWorkHR.Identity.Services;
- namespace MTWorkHR.API.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- [AppAuthorize]
- public class UserTaskController : ControllerBase
- {
- private readonly IUserTaskService _userTaskService;
- private readonly IUserTaskAttachmentService _attachmentService;
- private readonly IUserTaskHistoryService _taskHistoryService;
- public UserTaskController(IUserTaskService userUserTaskService, IUserTaskAttachmentService attachmentService)
- {
- this._userTaskService = userUserTaskService;
- _attachmentService = attachmentService;
- }
- [HttpGet("GetAll")]
- public async Task<ActionResult<List<UserTaskDto>>> GetAll([FromQuery]PagingInputDto pagingInput)
- {
- return Ok(await _userTaskService.GetAll(pagingInput));
- }
- [HttpGet("Get")]
- public async Task<ActionResult<UserTaskDto>> Get(long UserTaskId)
- {
- return Ok(await _userTaskService.GetById(UserTaskId));
- }
- [HttpPost("Create")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<ActionResult<UserTaskDto>> Create([FromBody] UserTaskDto input)
- {
- return await _userTaskService.Create(input);
- }
- [HttpPost("Update")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task Update([FromBody] UserTaskDto input)
- {
- await _userTaskService.Update(input);
- }
- [HttpPost("Delete")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task Delete(long id)
- {
- await _userTaskService.Delete(id);
- }
- #region attachments
- [HttpPost("CreateAttachment")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [Consumes("multipart/form-data")]
- public async Task<ActionResult<AttachmentDto>> CreateAttachment([FromForm] AttachmentDto input)
- {
- return await _attachmentService.Create(input);
- }
- [HttpPost("UpdateAttachment")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [Consumes("multipart/form-data")]
- public async Task UpdateAttachment([FromForm] AttachmentDto input)
- {
- await _attachmentService.Update(input);
- }
- [HttpPost("DeleteAttachment")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task DeleteAttachment(long id)
- {
- await _attachmentService.Delete(id);
- }
- #endregion
- #region History
- [HttpPost("CreateTaskHistory")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<ActionResult<UserTaskHistoryDto>> CreateTaskHistory([FromBody] UserTaskHistoryDto input)
- {
- return await _taskHistoryService.Create(input);
- }
- [HttpPost("UpdateTaskHistory")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task UpdateTaskHistory([FromBody] UserTaskHistoryDto input)
- {
- await _taskHistoryService.Update(input);
- }
- [HttpPost("DeleteTaskHistory")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task DeleteTaskHistory(long id)
- {
- await _taskHistoryService.Delete(id);
- }
- #endregion
- }
- }
|