123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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, IUserTaskHistoryService taskHistoryService)
- {
- this._userTaskService = userUserTaskService;
- _attachmentService = attachmentService;
- _taskHistoryService = taskHistoryService;
- }
- [HttpGet("GetAll")]
- public async Task<ActionResult<List<UserTaskAllDto>>> GetAll([FromQuery]UserTaskPagingInputDto 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<ActionResult<UserTaskDto>> Update([FromBody] UserTaskDto input)
- {
- return await _userTaskService.Update(input);
- }
- [HttpDelete("Delete")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task Delete([FromQuery] 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);
- }
- [HttpDelete("DeleteAttachment")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task DeleteAttachment([FromQuery] 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);
- }
- [HttpDelete("DeleteTaskHistory")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task DeleteTaskHistory([FromQuery]long id)
- {
- await _taskHistoryService.Delete(id);
- }
- [HttpPost("ChangeStatus")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task ChangeStatus([FromBody] TaskStatusDto input)
- {
- await _userTaskService.ChangeStatus(input.TaskId, input.StatusId);
- }
- #endregion
- }
- }
|