12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using MTWorkHR.Application.Filters;
- using MTWorkHR.Application.Models;
- using MTWorkHR.Application.Services;
- using MTWorkHR.Application.Services.Interfaces;
- namespace MTWorkHR.API.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- [AppAuthorize]
- public class ContractController : ControllerBase
- {
- private readonly IContractService _ContractService;
- public ContractController(IContractService UserContractService)
- {
- this._ContractService = UserContractService;
- }
- [HttpGet("GetAll")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<ActionResult<List<ContractDto>>> GetAll([FromQuery] ContractPagingInputDto pagingInput)
- {
- return Ok(await _ContractService.GetAll(pagingInput));
- }
- [HttpGet("Get")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- // [AppAuthorize(Permissions = "Contract")]
- public async Task<ActionResult<ContractDto>> Get(long ContractId)
- {
- return Ok(await _ContractService.GetById(ContractId));
- }
- [HttpPost("Create")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- // [AppAuthorize(Permissions = "Contract.Create")]
- public async Task<ActionResult<ContractDto>> Create([FromBody] ContractDto input)
- {
- return await _ContractService.Create(input);
- }
- [HttpPost("Update")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- // [AppAuthorize(Permissions = "Contract.Update")]
- public async Task Update([FromBody] ContractDto input)
- {
- await _ContractService.Update(input);
- }
- [HttpDelete("Delete")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- // [AppAuthorize(Permissions = "Contract.Delete")]
- public async Task Delete([FromQuery] long id)
- {
- await _ContractService.Delete(id);
- }
- [HttpPost("ChangeStatus")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<bool> ChangeStatus([FromBody] ContractStatusDto input)
- {
- return await _ContractService.ChangeStatus(input.ContractId, input.StatusId);
- }
- }
- }
|