123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 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;
- 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());
- }
- [HttpGet("GetById")]
- public async Task<ActionResult<CompanyDto>> GetById(long companyId)
- {
- return Ok(await _companyService.GetById(companyId));
- }
- [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);
- }
- [HttpDelete("Delete")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task Delete([FromQuery] long id)
- {
- await _companyService.Delete(id);
- }
- [HttpDelete("Suspend")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task Suspend([FromQuery] long id)
- {
- await _companyService.Suspend(id);
- }
- }
- }
|