1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using Countries.NET.Database;
- 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.Identity.Services;
- namespace MTWorkHR.API.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- [AppAuthorize]
- public class UserController : ControllerBase
- {
- private readonly IUserService _userService;
- public UserController(IUserService userService)
- {
- this._userService = userService;
- }
- [HttpPost("GetAll")]
- public async Task<ActionResult<List<UserAllDto>>> GetAll([FromBody] UserPagingInputDto pagingInput)
- {
- return Ok( await _userService.GetAll(pagingInput));
- }
- [HttpGet("GetAllCompanyEmployees")]
- public async Task<ActionResult<List<UserDto>>> GetAllCompanyEmployees()
- {
- return Ok(await _userService.GetAllCompanyEmployees());
- }
- [HttpGet("Get")]
- public async Task<ActionResult<UserDto>> Get()
- {
- return Ok(await _userService.GetById());
- }
- [HttpGet("GetById")]
- public async Task<ActionResult<UserDto>> GetById(string userId)
- {
- return Ok(await _userService.GetById(userId));
- }
- [HttpGet("GetByEmail")]
- public async Task<ActionResult<UserDto>> GetByEmail(string userId)
- {
- return Ok(await _userService.GetByEmail(userId));
- }
- [HttpPost("Create")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [Consumes("multipart/form-data")]
- public async Task<ActionResult<UserDto>> Create([FromForm] UserDto input)
- {
- return await _userService.Create(input);
- }
- [HttpPost("Update")]
- [Consumes("multipart/form-data")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<ActionResult<UserDto>> Update([FromForm] UserUpdateDto input)
- {
- return Ok(await _userService.Update(input));
- }
- [HttpDelete("Delete")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task Delete([FromQuery] string id)
- {
- await _userService.Delete(id);
- }
- [HttpPost("ResetPassword")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<bool> ResetPassword([FromBody] ResetPasswordDto input)
- {
- return await _userService.ResetPassword(input);
- }
- [HttpGet("GetBlobFile")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<ActionResult> GetBlobFile([FromQuery] string filePath)
- {
- var res = await _userService.Download(filePath);
- return File(res.Content, res.ContentType);
- }
- }
- }
|