|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Dto;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Shared;
|
|
|
|
|
|
|
|
|
@ -21,6 +22,8 @@ namespace API.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("users/{page}/{number}")]
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 204)]
|
|
|
|
|
public IActionResult GetUsers(int page, int number)
|
|
|
|
|
{
|
|
|
|
|
var getUsers = new InClassName(page, number);
|
|
|
|
@ -38,6 +41,8 @@ namespace API.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("user/id/{id}")]
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
|
public IActionResult GetUserById(int id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -52,6 +57,8 @@ namespace API.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("user/username/{username}")]
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
|
public IActionResult GetUserByUsername(string username)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -67,6 +74,8 @@ namespace API.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpDelete]
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
|
public IActionResult DeleteUser(int id)
|
|
|
|
|
{
|
|
|
|
|
var success = _userUserService.DeleteUser(id);
|
|
|
|
@ -83,6 +92,8 @@ namespace API.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 201)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 400)]
|
|
|
|
|
public IActionResult CreateUser([FromBody]UserDTO dto)
|
|
|
|
|
{
|
|
|
|
|
if (dto.Username == null || dto.Password == null || dto.Email == null)
|
|
|
|
@ -95,6 +106,10 @@ namespace API.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPut]
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 200)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 400)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
|
|
|
|
|
|
public IActionResult UpdateUser(int id, [FromBody] UserDTO userDTO)
|
|
|
|
|
{
|
|
|
|
|
if(id != userDTO.Id)
|
|
|
|
|