|
|
@ -12,7 +12,9 @@ namespace API.Controllers
|
|
|
|
public class UserController(ILogger<InquiriesController> logger, IUserService<UserDTO> userService) : ControllerBase, IUserService<UserDTO>
|
|
|
|
public class UserController(ILogger<InquiriesController> logger, IUserService<UserDTO> userService) : ControllerBase, IUserService<UserDTO>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[HttpGet("users/{page}/{number}")]
|
|
|
|
[HttpGet("users/{page}/{number}")]
|
|
|
|
public IActionResult GetUsers(int page, int number)
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(string), 204)]
|
|
|
|
|
|
|
|
public IActionResult GetUsers(int page, int number)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var users = userService.GetUsers(page, number).ToList();
|
|
|
|
var users = userService.GetUsers(page, number).ToList();
|
|
|
|
if (users.Count == 0)
|
|
|
|
if (users.Count == 0)
|
|
|
@ -26,6 +28,8 @@ namespace API.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("user/id/{id}")]
|
|
|
|
[HttpGet("user/id/{id}")]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
public IActionResult GetUserById(int id)
|
|
|
|
public IActionResult GetUserById(int id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -41,6 +45,8 @@ namespace API.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("user/username/{username}")]
|
|
|
|
[HttpGet("user/username/{username}")]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
public IActionResult GetUserByUsername(string username)
|
|
|
|
public IActionResult GetUserByUsername(string username)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -56,6 +62,8 @@ namespace API.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpDelete]
|
|
|
|
[HttpDelete]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
public IActionResult DeleteUser(int id)
|
|
|
|
public IActionResult DeleteUser(int id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var success = userService.DeleteUser(id);
|
|
|
|
var success = userService.DeleteUser(id);
|
|
|
@ -72,7 +80,9 @@ namespace API.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
public IActionResult CreateUser([FromBody] UserDTO dto)
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 201)]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(string), 400)]
|
|
|
|
|
|
|
|
public IActionResult CreateUser([FromBody]UserDTO dto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (dto.Username == null || dto.Password == null || dto.Email == null)
|
|
|
|
if (dto.Username == null || dto.Password == null || dto.Email == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -88,7 +98,10 @@ namespace API.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPut]
|
|
|
|
[HttpPut]
|
|
|
|
public IActionResult UpdateUser(int id, [FromBody] UserDTO userDto)
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(string), 400)]
|
|
|
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
|
|
|
|
public IActionResult UpdateUser(int id, [FromBody] UserDTO userDTO)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (id != userDto.Id)
|
|
|
|
if (id != userDto.Id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|