UserController.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using MTWorkHR.Application.Identity;
  5. using MTWorkHR.Application.Models;
  6. using MTWorkHR.Identity.Services;
  7. namespace MTWorkHR.API.Controllers
  8. {
  9. [Route("api/[controller]")]
  10. [ApiController]
  11. public class UserController : ControllerBase
  12. {
  13. private readonly IUserService _userService;
  14. public UserController(IUserService userService)
  15. {
  16. this._userService = userService;
  17. }
  18. [HttpGet("GetAll")]
  19. public async Task<ActionResult<List<UserAllDto>>> GetAll([FromQuery] UserPagingInputDto pagingInput)
  20. {
  21. return Ok( await _userService.GetAll(pagingInput));
  22. }
  23. [HttpGet("Get")]
  24. public async Task<ActionResult<UserDto>> Get(string userId)
  25. {
  26. return Ok(await _userService.GetById(userId));
  27. }
  28. [HttpPost("Create")]
  29. [ProducesResponseType(StatusCodes.Status200OK)]
  30. [Consumes("multipart/form-data")]
  31. public async Task<ActionResult<UserDto>> Create([FromForm] UserDto input)
  32. {
  33. return await _userService.Create(input);
  34. }
  35. [HttpPost("Update")]
  36. [Consumes("multipart/form-data")]
  37. [ProducesResponseType(StatusCodes.Status200OK)]
  38. public async Task Update([FromForm] UserDto input)
  39. {
  40. await _userService.Update(input);
  41. }
  42. [HttpPost("Delete")]
  43. [ProducesResponseType(StatusCodes.Status200OK)]
  44. public async Task Delete(string id)
  45. {
  46. await _userService.Delete(id);
  47. }
  48. [HttpPost("ResetPassword")]
  49. [ProducesResponseType(StatusCodes.Status200OK)]
  50. public async Task<bool> ResetPassword([FromBody] ResetPasswordDto input)
  51. {
  52. return await _userService.ResetPassword(input);
  53. }
  54. }
  55. }