ProjectController.cs 1.8 KB

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