UserController.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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<UserDto>>> GetAll()
  20. {
  21. return Ok( await _userService.GetAll());
  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. public async Task<ActionResult<UserDto>> Create([FromBody] UserDto input)
  31. {
  32. return await _userService.Create(input);
  33. }
  34. [HttpPost("Update")]
  35. [ProducesResponseType(StatusCodes.Status200OK)]
  36. public async Task Update([FromBody] UserDto input)
  37. {
  38. await _userService.Update(input);
  39. }
  40. [HttpPost("Delete")]
  41. [ProducesResponseType(StatusCodes.Status200OK)]
  42. public async Task Delete(string id)
  43. {
  44. await _userService.Delete(id);
  45. }
  46. [HttpPost("ResetPassword")]
  47. [ProducesResponseType(StatusCodes.Status200OK)]
  48. public async Task<bool> ResetPassword([FromBody] ResetPasswordDto input)
  49. {
  50. return await _userService.ResetPassword(input);
  51. }
  52. [HttpPost("ForgetPassword")]
  53. [ProducesResponseType(StatusCodes.Status200OK)]
  54. public async Task ForgetPassword(string input)
  55. {
  56. await _userService.ForgetPassword(input);
  57. }
  58. }
  59. }