Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using GatewayAPI.Clients.UserService;
using GatewayAPI.Models;
using Microsoft.AspNetCore.Mvc;
using System.Text;
namespace GatewayAPI.Controllers
{
[ApiController]
[Route("api/[Controller]")]
public class UserController : ControllerBase
{
private readonly IUserServiceClient userServiceClient;
public UserController(IUserServiceClient userServiceClient)
{
this.userServiceClient = userServiceClient;
}
[HttpPost("register")]
public async Task<IActionResult> Register([FromBody] UserRegistration userRegistration)
{
HttpResponseMessage response = await userServiceClient.RegisterUserAsync(userRegistration);
return new HttpResponseMessageResult(response);
}
[HttpPost("authorize")]
public async Task<IActionResult> Authorize()
{
HttpResponseMessage response = await userServiceClient.AuthorizeUserAsync();
return new HttpResponseMessageResult(response);
}
[HttpPost("login")]
public async Task<IActionResult> Login([FromBody] UserLogin userLogin)
{
HttpResponseMessage response = await userServiceClient.LoginUserAsync(userLogin);
return new HttpResponseMessageResult(response);
}
[HttpPost("logout")]
public async Task<IActionResult> Logout()
{
HttpResponseMessage response = await userServiceClient.LogoutUserAsync();
return new HttpResponseMessageResult(response);
}
[HttpGet()]
public async Task<IActionResult> GetUsers()
{
HttpResponseMessage response = await userServiceClient.GetUsersAsync();
return new HttpResponseMessageResult(response);
}
[HttpGet("{id}")]
public async Task<IActionResult> GetUser(int id)
{
HttpResponseMessage response = await userServiceClient.GetUserAsync(id);
return new HttpResponseMessageResult(response);
}
[HttpPatch("{id}")]
public async Task<IActionResult> UpdateUser(int id, [FromBody] UserUpdateInfo updateInfo)
{
HttpResponseMessage response = await userServiceClient.UpdateUserAsync(id, updateInfo);
return new HttpResponseMessageResult(response);
}