CompanyController.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. namespace MTWorkHR.API.Controllers
  8. {
  9. [Route("api/[controller]")]
  10. [ApiController]
  11. public class CompanyController : ControllerBase
  12. {
  13. private readonly ICompanyService _companyService;
  14. public CompanyController(ICompanyService CompanyService)
  15. {
  16. this._companyService = CompanyService;
  17. }
  18. [HttpGet("GetAll")]
  19. public async Task<ActionResult<List<CompanyDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
  20. {
  21. return Ok( await _companyService.GetAll(pagingInput));
  22. }
  23. [HttpGet("Get")]
  24. public async Task<ActionResult<CompanyDto>> Get(long CompanyId)
  25. {
  26. return Ok(await _companyService.GetById(CompanyId));
  27. }
  28. [HttpPost("Create")]
  29. [ProducesResponseType(StatusCodes.Status200OK)]
  30. public async Task<ActionResult<CompanyDto>> Create([FromBody] CompanyDto input)
  31. {
  32. return await _companyService.Create(input);
  33. }
  34. [HttpPost("Update")]
  35. [ProducesResponseType(StatusCodes.Status200OK)]
  36. public async Task Update([FromBody] CompanyDto input)
  37. {
  38. await _companyService.Update(input);
  39. }
  40. [HttpPost("Delete")]
  41. [ProducesResponseType(StatusCodes.Status200OK)]
  42. public async Task Delete(long id)
  43. {
  44. await _companyService.Delete(id);
  45. }
  46. }
  47. }