CompanyController.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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()
  27. {
  28. return Ok(await _companyService.GetById());
  29. }
  30. [HttpPost("Create")]
  31. [ProducesResponseType(StatusCodes.Status200OK)]
  32. [Consumes("multipart/form-data")]
  33. [AllowAnonymous]
  34. public async Task<ActionResult<CompanyDto>> Create([FromForm] CompanyDto input)
  35. {
  36. return await _companyService.Create(input);
  37. }
  38. [HttpPost("Update")]
  39. [ProducesResponseType(StatusCodes.Status200OK)]
  40. [Consumes("multipart/form-data")]
  41. public async Task<ActionResult<CompanyDto>> Update([FromForm] CompanyDto input)
  42. {
  43. return await _companyService.Update(input);
  44. }
  45. [HttpDelete("Delete")]
  46. [ProducesResponseType(StatusCodes.Status200OK)]
  47. public async Task Delete([FromQuery] long id)
  48. {
  49. await _companyService.Delete(id);
  50. }
  51. }
  52. }