User továbbgondolása
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
@@ -15,23 +16,17 @@ namespace WorkFlowCheck.Web.Services
|
||||
try
|
||||
{
|
||||
// Az API végpont meghatározása
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/user/authenticate";
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/Authenticate";
|
||||
|
||||
var userDTO = new UserDTO()
|
||||
var userSimpleDTO = new UserSimpleDTO()
|
||||
{
|
||||
Email = "",
|
||||
FirstName = "",
|
||||
LastName = "",
|
||||
Id = 0,
|
||||
UserName = username,
|
||||
Password = password,
|
||||
JwtToken = "",
|
||||
RoleDTO = new List<RoleDTO>(),
|
||||
|
||||
};
|
||||
|
||||
|
||||
// HTTP POST kérés küldése
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userDTO))
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userSimpleDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
@@ -53,5 +48,58 @@ namespace WorkFlowCheck.Web.Services
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public Task<ApiRequestDTO<List<RoleDTO>>> GetAllRoles() => throw new NotImplementedException();
|
||||
public Task<ApiRequestDTO<List<UserDTO>>> GetAllUserRoles() => throw new NotImplementedException();
|
||||
public async Task<List<UserDTO>> GetAllUsers()
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/GetAllUsers";
|
||||
var retVal = new List<UserDTO>();
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<UserDTO>>>(endpoint);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
return response.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public Task<RoleDTO> GetRole(int id) => throw new NotImplementedException();
|
||||
public async Task<UserDTO> GetUser(int id)
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/GetUser/{id}";
|
||||
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<UserDTO>>(endpoint);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
return response.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public Task<UserRoleDTO> GetUserRole(int id) => throw new NotImplementedException();
|
||||
public Task<RoleDTO> UpdateRole(RoleDTO role) => throw new NotImplementedException();
|
||||
public Task<UserDTO> UpdateUser(UserDTO user) => throw new NotImplementedException();
|
||||
public Task<UserRoleDTO> UpdateUserRole(UserRoleDTO userRole) => throw new NotImplementedException();
|
||||
Task<List<RoleDTO>> IUserService.GetAllRoles() => throw new NotImplementedException();
|
||||
Task<List<UserDTO>> IUserService.GetAllUserRoles() => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user