CompanyController.cs 1.7 KB

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