123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using MTWorkHR.Application.Filters;
- using MTWorkHR.Application.Identity;
- using MTWorkHR.Application.Models;
- using MTWorkHR.Application.Services.Interfaces;
- namespace MTWorkHR.API.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- [AppAuthorize]
- public class CompanyController : ControllerBase
- {
- private readonly ICompanyService _companyService;
- public CompanyController(ICompanyService CompanyService)
- {
- this._companyService = CompanyService;
- }
- [HttpGet("GetAll")]
- public async Task<ActionResult<List<CompanyDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
- {
- return Ok( await _companyService.GetAll(pagingInput));
- }
- [HttpGet("Get")]
- public async Task<ActionResult<CompanyDto>> Get()
- {
- return Ok(await _companyService.GetById());
- }
- [HttpPost("Create")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [Consumes("multipart/form-data")]
- [AllowAnonymous]
- public async Task<ActionResult<CompanyDto>> Create([FromForm] CompanyDto input)
- {
- return await _companyService.Create(input);
- }
- [HttpPost("Update")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [Consumes("multipart/form-data")]
- public async Task<ActionResult<CompanyDto>> Update([FromForm] CompanyDto input)
- {
- return await _companyService.Update(input);
- }
- [HttpPost("Delete")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task Delete([FromQuery] long id)
- {
- await _companyService.Delete(id);
- }
-
- }
- }
|