ProjectController.cs 2.0 KB

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