CompanyController.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. [Consumes("multipart/form-data")]
  31. public async Task<ActionResult<CompanyDto>> Create([FromForm] CompanyDto input)
  32. {
  33. return await _companyService.Create(input);
  34. }
  35. [HttpPost("Update")]
  36. [ProducesResponseType(StatusCodes.Status200OK)]
  37. public async Task Update([FromBody] CompanyDto input)
  38. {
  39. await _companyService.Update(input);
  40. }
  41. [HttpPost("Delete")]
  42. [ProducesResponseType(StatusCodes.Status200OK)]
  43. public async Task Delete(long id)
  44. {
  45. await _companyService.Delete(id);
  46. }
  47. }
  48. }