TeamController.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 TeamController : ControllerBase
  15. {
  16. private readonly ITeamService _TeamService;
  17. public TeamController(ITeamService UserTeamService)
  18. {
  19. this._TeamService = UserTeamService;
  20. }
  21. [HttpGet("GetAll")]
  22. [ProducesResponseType(StatusCodes.Status200OK)]
  23. public async Task<ActionResult<List<TeamDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
  24. {
  25. return Ok(await _TeamService.GetAll(pagingInput));
  26. }
  27. [HttpGet("Get")]
  28. [ProducesResponseType(StatusCodes.Status200OK)]
  29. // [AppAuthorize(Permissions = "Team")]
  30. public async Task<ActionResult<TeamDto>> Get(long TeamId)
  31. {
  32. return Ok(await _TeamService.GetById(TeamId));
  33. }
  34. [HttpPost("Create")]
  35. [ProducesResponseType(StatusCodes.Status200OK)]
  36. // [AppAuthorize(Permissions = "Team.Create")]
  37. public async Task<ActionResult<TeamDto>> Create([FromBody] TeamDto input)
  38. {
  39. return await _TeamService.Create(input);
  40. }
  41. [HttpPost("Update")]
  42. [ProducesResponseType(StatusCodes.Status200OK)]
  43. // [AppAuthorize(Permissions = "Team.Update")]
  44. public async Task<ActionResult<TeamDto>> Update([FromBody] TeamDto input)
  45. {
  46. return await _TeamService.Update(input);
  47. }
  48. [HttpPost("Delete")]
  49. [ProducesResponseType(StatusCodes.Status200OK)]
  50. // [AppAuthorize(Permissions = "Team.Delete")]
  51. public async Task Delete([FromQuery] long id)
  52. {
  53. await _TeamService.Delete(id);
  54. }
  55. [HttpPost("AssignAdminManager")]
  56. [ProducesResponseType(StatusCodes.Status200OK)]
  57. public async Task<bool> AssignAdminManager([FromBody] TeamUserDto teamUser)
  58. {
  59. return await _TeamService.AssignAdminManager(teamUser);
  60. }
  61. }
  62. }