Changing UserDataServiceClientBase Http to Signalr in progress...
This commit is contained in:
parent
2b11c329af
commit
5bc9663930
|
|
@ -113,8 +113,13 @@ public class SignalRTags : AcSignalRTags
|
|||
public const int GetTransferDestinationToProductsByTransferDestinationId = 96;
|
||||
|
||||
public const int GetAllUsers = 120;
|
||||
public const int GetAllUserModelDtoDetails = 121;
|
||||
public const int GetAllUserModelDtoEmails = 125;
|
||||
public const int GetAllUserModelDto = 121;
|
||||
public const int GetAllUserModelDtoDetails = 122;
|
||||
public const int GetAllUserModelDtoEmails = 123;
|
||||
public const int GetUserModelDtoById = 126;
|
||||
public const int GetUserModelDtoByEmail = 127;
|
||||
public const int GetUserModelDtoDetailById = 128;
|
||||
public const int GetUserModelDtoDetailByEmail = 129;
|
||||
public const int AddUser = 130;
|
||||
public const int AddUserModelDtoDetail = 131;
|
||||
public const int UpdateUser = 135;
|
||||
|
|
@ -125,5 +130,6 @@ public class SignalRTags : AcSignalRTags
|
|||
public const int GuestUpdateTransfer = 150;
|
||||
public const int DriverUpdateTransfer = 151;
|
||||
|
||||
public const int AuthenticateUser = 160;
|
||||
public const int GetAllLogItemsByFilterText = 1000;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ using TIAMWebApp.Shared.Application.Utility;
|
|||
|
||||
namespace TIAMMobileApp.Services
|
||||
{
|
||||
public class UserDataServiceMobile(HttpClient http, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
|
||||
: UserDataServiceClientBase(http, sessionService, secureStorageHandler, serviceProviderDataService, logWriters);
|
||||
public class UserDataServiceMobile(HttpClient http, AdminSignalRClient adminSignalRClient, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
|
||||
: UserDataServiceClientBase(http, adminSignalRClient, sessionService, secureStorageHandler, serviceProviderDataService, logWriters);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Text.Json;
|
||||
using AyCode.Core.Extensions;
|
||||
using AyCode.Core.Helpers;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
|
@ -64,22 +65,22 @@ namespace TIAMSharedUI.Pages
|
|||
{
|
||||
_currentStep = 1;
|
||||
BrowserConsoleLogWriter.Info("Login started: " + "Email: " + _loginModel.Email + ", Password: " + _loginModel.Password);
|
||||
var response = await userDataService.AuthenticateUser(_loginModel);
|
||||
|
||||
var mainResponse = await userDataService.AuthenticateUser(_loginModel);
|
||||
|
||||
//var response = await UserDataservice.TestUserApi(30);
|
||||
BrowserConsoleLogWriter.Info("Login started");
|
||||
BrowserConsoleLogWriter.Info(response);
|
||||
//BrowserConsoleLogWriter.Info(response);
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
//if (!string.IsNullOrEmpty(response))
|
||||
if (mainResponse != null)
|
||||
{
|
||||
//get token and save to local storage
|
||||
//parse to Mainresponse from json string
|
||||
|
||||
|
||||
//var Mainresponse = JsonSerializer.Deserialize<MainResponse>(response);
|
||||
var mainResponse = JsonSerializer.Deserialize<MainResponse>(response, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
|
||||
if (mainResponse != null)
|
||||
{
|
||||
//var mainResponse = JsonSerializer.Deserialize<MainResponse>(response, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
|
||||
if (!mainResponse.IsSuccess)
|
||||
{
|
||||
|
|
@ -93,9 +94,9 @@ namespace TIAMSharedUI.Pages
|
|||
}
|
||||
else
|
||||
{
|
||||
string authResponseJson = JsonSerializer.Serialize(mainResponse.Content);
|
||||
string authResponseJson = mainResponse.Content.ToJson(); //JsonSerializer.Serialize(mainResponse.Content);
|
||||
|
||||
var authResponse = JsonSerializer.Deserialize<AuthenticationResponse>(authResponseJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
var authResponse = authResponseJson.JsonTo<AuthenticationResponse>(); //JsonSerializer.Deserialize<AuthenticationResponse>(authResponseJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
|
||||
string accessToken = authResponse.AccessToken;
|
||||
|
||||
|
|
@ -139,16 +140,14 @@ namespace TIAMSharedUI.Pages
|
|||
navManager.NavigateTo("/");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//api error
|
||||
//await App.Current.MainPage.DisplayAlert("Error", "An error occured while trying to login", "Ok");
|
||||
//display error message via jsinterop
|
||||
BrowserConsoleLogWriter.Info("An error occured while trying to login");
|
||||
BrowserConsoleLogWriter.Warning("An error occured while trying to login");
|
||||
navManager.NavigateTo("login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ using TIAMWebApp.Shared.Application.Services;
|
|||
|
||||
namespace TIAMWebApp.Client.Services
|
||||
{
|
||||
public class UserDataServiceWeb(HttpClient http, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
|
||||
: UserDataServiceClientBase(http, sessionService, secureStorageHandler, serviceProviderDataService, logWriters);
|
||||
public class UserDataServiceWeb(HttpClient http, AdminSignalRClient adminSignalRClient, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
|
||||
: UserDataServiceClientBase(http, adminSignalRClient, sessionService, secureStorageHandler, serviceProviderDataService, logWriters);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,11 +96,27 @@ namespace TIAMWebApp.Server.Controllers
|
|||
|
||||
if (authenticateUser == null) throw new NullReferenceException("authenticateUser == null");
|
||||
|
||||
_logger.Info(authenticateUser.Email);
|
||||
var response = await AuthenticateUser(authenticateUser);
|
||||
|
||||
var loggedInModel = _loginService.Login(authenticateUser.Email, authenticateUser.Password);
|
||||
if (loggedInModel.IsLoggedIn)
|
||||
if (response != null) return Ok(response);
|
||||
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
[SignalR(SignalRTags.AuthenticateUser)]
|
||||
public async Task<MainResponse?> AuthenticateUser(LoginModel authenticateUser)
|
||||
{
|
||||
_logger.Info($"AuthenticateUser; {authenticateUser.Email}");
|
||||
|
||||
var loggedInModel = await _loginService.LoginAsync(authenticateUser.Email, authenticateUser.Password);
|
||||
|
||||
if (!loggedInModel.IsLoggedIn)
|
||||
{
|
||||
_logger.Warning(@"User not valid! errorCode: " + loggedInModel.LoginErrorCode);
|
||||
return null;
|
||||
}
|
||||
|
||||
var response = new MainResponse
|
||||
{
|
||||
Content = new AuthenticationResponse
|
||||
|
|
@ -113,11 +129,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
ErrorMessage = ""
|
||||
};
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
_logger.Warning(@"User not valid! errorCode: " + loggedInModel.LoginErrorCode);
|
||||
return Unauthorized();
|
||||
return response;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
@ -199,7 +211,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
else
|
||||
{
|
||||
var user = JObject.Parse(serializedRegistrationModel.GetRawText()).ToObject<RegistrationModel>();
|
||||
bool result = false;
|
||||
var result = false;
|
||||
if (user != null)
|
||||
{
|
||||
//add userModel to users array
|
||||
|
|
@ -297,6 +309,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetUsers")]
|
||||
[SignalR(SignalRTags.GetAllUserModelDto)]
|
||||
public async Task<List<UserModelDto>> GetUsers()
|
||||
{
|
||||
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
|
||||
|
|
@ -412,34 +425,35 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route(APIUrls.GetUserByEmailRouteName + "/{email}")]
|
||||
public async Task<UserModelDto>? GetUserByEmail(string email)
|
||||
[SignalR(SignalRTags.GetUserModelDtoByEmail)]
|
||||
public async Task<UserModelDto?> GetUserByEmail(string email)
|
||||
{
|
||||
_logger.Info($"GetUserByEmail called with email: {email}");
|
||||
var result = await userDal.GetUserModelDtoByEmailAsync<UserModelDto>(email, false);
|
||||
if (result == null)
|
||||
{
|
||||
UserModelDto resultDto = new UserModelDto();
|
||||
return resultDto;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return await userDal.GetUserModelDtoByEmailAsync<UserModelDto>(email, false);
|
||||
|
||||
//var result = await userDal.GetUserModelDtoByEmailAsync<UserModelDto>(email, false);
|
||||
//if (result != null) return result;
|
||||
|
||||
//var resultDto = new UserModelDto();
|
||||
//return resultDto;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetUserByIdRouteName)]
|
||||
[SignalR(SignalRTags.GetUserModelDtoById)]
|
||||
public async Task<UserModelDto?> GetUserById([FromBody] Guid id)
|
||||
{
|
||||
_logger.Info($"GetUserById called with id: {id}");
|
||||
|
||||
return await userDal.GetUserModelDtoByIdAsync<UserModelDto>(id, true);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetUserDetailByIdRouteName)]
|
||||
[SignalR(SignalRTags.GetUserModelDtoDetailById)]
|
||||
public async Task<UserModelDtoDetail?> GetUserDetailById([FromBody] Guid id)
|
||||
{
|
||||
_logger.Info($"GetUserDetailById called with id: {id}");
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ namespace TIAMWebApp.Shared.Application.Interfaces
|
|||
{
|
||||
public Task<UserSessionModel> IsLoggedInAsync(Guid id);
|
||||
|
||||
public Task<string> AuthenticateUser(LoginModel loginModel);
|
||||
public Task<MainResponse?> AuthenticateUser(LoginModel loginModel);
|
||||
public Task<(bool isSuccess, string ErrorMessage)> CreateUser(RegistrationModel regModel);
|
||||
public Task<(bool isSuccess, UserModelDto? user)> CreateGuestUser(RegistrationModel regModel);
|
||||
public Task<string> TestUserApi(int Param);
|
||||
|
||||
//public Task<Dictionary<int, string>> GetUserRolesAsync(UserModel userModel);
|
||||
|
||||
public Task<List<UserModelDto>?> GetUsersAsync();
|
||||
public Task<List<UserModelDto>> GetUsersAsync();
|
||||
|
||||
public Task<List<UserModelDtoDetail>> GetUsersWithDetailsAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,7 @@ public abstract class SessionServiceClientBase : ISessionService
|
|||
|
||||
public virtual List<Product> GetHotels()
|
||||
{
|
||||
if (User != null)
|
||||
{
|
||||
return User.UserModelDto.Products.Count > 0 ? User.UserModelDto.Products.Where(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel).ToList() : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
return User != null ? User.UserModelDto.Products.Where(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel).ToList() : [];
|
||||
}
|
||||
|
||||
public virtual void ClearAll()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using AyCode.Interfaces.StorageHandlers;
|
|||
using AyCode.Services.Loggers;
|
||||
using Newtonsoft.Json;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAM.Services;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||
|
|
@ -17,15 +18,18 @@ public abstract class UserDataServiceClientBase : IUserDataService
|
|||
{
|
||||
protected readonly HttpClient Http;
|
||||
protected readonly LoggerClient Logger;
|
||||
protected readonly AdminSignalRClient AdminSignalRClient;
|
||||
|
||||
protected readonly ISessionService SessionService;
|
||||
protected readonly ISecureStorageHandler SecureStorageHandler;
|
||||
protected readonly IServiceProviderDataService ServiceProviderDataService;
|
||||
|
||||
|
||||
protected UserDataServiceClientBase(HttpClient http, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
|
||||
protected UserDataServiceClientBase(HttpClient http, AdminSignalRClient adminSignalRClient, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
|
||||
{
|
||||
Http = http;
|
||||
AdminSignalRClient = adminSignalRClient;
|
||||
|
||||
SessionService = sessionService;
|
||||
SecureStorageHandler = secureStorageHandler;
|
||||
|
||||
|
|
@ -71,34 +75,37 @@ public abstract class UserDataServiceClientBase : IUserDataService
|
|||
return result;
|
||||
}
|
||||
|
||||
public async Task<string> AuthenticateUser(LoginModel loginModel)
|
||||
public async Task<MainResponse?> AuthenticateUser(LoginModel loginModel)
|
||||
{
|
||||
var result = string.Empty;
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.AuthenticateUser}";
|
||||
Logger.Debug($"AuthenticateUser; email: {loginModel.Email}");
|
||||
|
||||
var response = await Http.PostAsJsonAsync(url, loginModel);
|
||||
return await AdminSignalRClient.PostDataAsync<LoginModel, MainResponse>(SignalRTags.AuthenticateUser, loginModel);
|
||||
|
||||
//try
|
||||
//var result = string.Empty;
|
||||
//var url = $"{Setting.ApiBaseUrl}/{APIUrls.AuthenticateUser}";
|
||||
|
||||
//var response = await Http.PostAsJsonAsync(url, loginModel);
|
||||
|
||||
////try
|
||||
////{
|
||||
//// Logger.Detail("Login started: " + "Email: " + loginModel.Email + ", Password: " + loginModel.Password);
|
||||
////}
|
||||
////catch (Exception ex)
|
||||
////{
|
||||
//// _logger.Error(ex.Message, ex);
|
||||
////}
|
||||
|
||||
//if (response.IsSuccessStatusCode)
|
||||
//{
|
||||
// Logger.Detail("Login started: " + "Email: " + loginModel.Email + ", Password: " + loginModel.Password);
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// _logger.Error(ex.Message, ex);
|
||||
//}
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
result = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
// result = await response.Content.ReadAsStringAsync();
|
||||
return result;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// result = await response.Content.ReadAsStringAsync();
|
||||
//}
|
||||
|
||||
////result = await response.Content.ReadAsStringAsync();
|
||||
//return result;
|
||||
}
|
||||
|
||||
public async Task<(bool isSuccess, string ErrorMessage)> CreateUser(RegistrationModel regModel)
|
||||
|
|
@ -107,7 +114,7 @@ public abstract class UserDataServiceClientBase : IUserDataService
|
|||
var result = string.Empty;
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateUser}";
|
||||
|
||||
Logger.Info("CreateUser url: " + url);
|
||||
Logger.Debug("CreateUser url: " + url);
|
||||
|
||||
var response = await Http.PostAsJsonAsync(url, regModel);
|
||||
result = await response.Content.ReadAsStringAsync();
|
||||
|
|
@ -133,7 +140,7 @@ public abstract class UserDataServiceClientBase : IUserDataService
|
|||
var user = new UserModelDto();
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateGuestUser}";
|
||||
|
||||
Logger.Info("CreateGuestUser url: " + url);
|
||||
Logger.Debug("CreateGuestUser url: " + url);
|
||||
|
||||
var response = await Http.PostAsJsonAsync(url, regModel);
|
||||
|
||||
|
|
@ -141,7 +148,7 @@ public abstract class UserDataServiceClientBase : IUserDataService
|
|||
{
|
||||
isSuccess = true;
|
||||
result = await response.Content.ReadAsStringAsync();
|
||||
Logger.Info("CreateGuestUser result: " + result);
|
||||
Logger.Debug("CreateGuestUser result: " + result);
|
||||
user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
}
|
||||
else
|
||||
|
|
@ -155,89 +162,107 @@ public abstract class UserDataServiceClientBase : IUserDataService
|
|||
}
|
||||
|
||||
|
||||
public async Task<List<UserModelDto>?> GetUsersAsync()
|
||||
public async Task<List<UserModelDto>> GetUsersAsync()
|
||||
{
|
||||
return await Http.GetFromJsonAsync<List<UserModelDto>>(APIUrls.GetUsers);
|
||||
Logger.Debug($"GetUsersAsync");
|
||||
|
||||
return await AdminSignalRClient.GetAllAsync<List<UserModelDto>>(SignalRTags.GetAllUserModelDto) ?? [];
|
||||
|
||||
//return await Http.GetFromJsonAsync<List<UserModelDto>>(APIUrls.GetUsers);
|
||||
}
|
||||
|
||||
public async Task<List<UserModelDtoDetail>> GetUsersWithDetailsAsync()
|
||||
{
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUsersWithDetails}";
|
||||
Logger.Debug($"GetUsersWithDetailsAsync");
|
||||
|
||||
Logger.Info("GetUserByEmailAsync url: " + url + "!");
|
||||
var response = await Http.GetFromJsonAsync<List<UserModelDtoDetail>>(APIUrls.GetUsersWithDetails);
|
||||
//var result = await response.Content.ReadAsStringAsync();
|
||||
//var user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
return await AdminSignalRClient.GetAllAsync<List<UserModelDtoDetail>>(SignalRTags.GetAllUserModelDtoDetails) ?? [];
|
||||
|
||||
return response ?? [];
|
||||
////var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUsersWithDetails}";
|
||||
|
||||
////Logger.Info("GetUserByEmailAsync url: " + url + "!");
|
||||
////var response = await Http.GetFromJsonAsync<List<UserModelDtoDetail>>(APIUrls.GetUsersWithDetails);
|
||||
//////var result = await response.Content.ReadAsStringAsync();
|
||||
//////var user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
|
||||
////return response ?? [];
|
||||
}
|
||||
|
||||
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserByEmail}/{email}";
|
||||
Logger.Info("GetUserByEmailAsync url: " + url + ", " + email);
|
||||
Logger.Debug($"GetUserByEmailAsync; email: {email}");
|
||||
|
||||
var response = await Http.GetAsync(url);
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await AdminSignalRClient.GetByIdAsync<UserModelDto>(SignalRTags.GetUserModelDtoByEmail, email);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
var user = System.Text.Json.JsonSerializer.Deserialize<UserModelDto>(jsonResponse, new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
});
|
||||
return user;
|
||||
}
|
||||
//try
|
||||
//{
|
||||
// var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserByEmail}/{email}";
|
||||
// Logger.Info("GetUserByEmailAsync url: " + url + ", " + email);
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (HttpRequestException httpRequestException)
|
||||
{
|
||||
// Handle specific HTTP request exceptions
|
||||
Logger.DebugConditional($"Request error: {httpRequestException.Message}");
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Handle other possible exceptions
|
||||
Logger.DebugConditional($"An error occurred: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
// var response = await Http.GetAsync(url);
|
||||
// response.EnsureSuccessStatusCode();
|
||||
|
||||
// if (response.IsSuccessStatusCode)
|
||||
// {
|
||||
// var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
// var user = System.Text.Json.JsonSerializer.Deserialize<UserModelDto>(jsonResponse, new JsonSerializerOptions
|
||||
// {
|
||||
// PropertyNameCaseInsensitive = true
|
||||
// });
|
||||
// return user;
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
//catch (HttpRequestException httpRequestException)
|
||||
//{
|
||||
// // Handle specific HTTP request exceptions
|
||||
// Logger.DebugConditional($"Request error: {httpRequestException.Message}");
|
||||
// throw;
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// // Handle other possible exceptions
|
||||
// Logger.DebugConditional($"An error occurred: {ex.Message}");
|
||||
// throw;
|
||||
//}
|
||||
}
|
||||
|
||||
public async Task<UserModelDto?> GetUserByIdAsync(Guid id)
|
||||
{
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserById}";
|
||||
Logger.Info("GetUserByIdAsync url: " + url + ", " + id.ToString());
|
||||
Logger.Debug($"GetUserByIdAsync; id: {id}");
|
||||
|
||||
var response = await Http.PostAsJsonAsync(url, id);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
var user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
return await AdminSignalRClient.GetByIdAsync<UserModelDto>(SignalRTags.GetUserModelDtoById, id);
|
||||
|
||||
return user;
|
||||
//var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserById}";
|
||||
//Logger.Debug("GetUserByIdAsync url: " + url + ", " + id.ToString());
|
||||
|
||||
//var response = await Http.PostAsJsonAsync(url, id);
|
||||
//var result = await response.Content.ReadAsStringAsync();
|
||||
//var user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
|
||||
//return user;
|
||||
}
|
||||
|
||||
public async Task<UserModelDtoDetail?> GetUserDetailByIdAsync(Guid id)
|
||||
{
|
||||
Logger.Info("GetUserDetailByIdAsync", "GLOBAL_LOGGER");
|
||||
Logger.Debug($"GetUserDetailByIdAsync; id: {id}");
|
||||
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserDetailById}";
|
||||
Logger.Info("GetUserDetailByIdAsync url: " + url + ", " + id.ToString());
|
||||
return await AdminSignalRClient.GetByIdAsync<UserModelDtoDetail>(SignalRTags.GetUserModelDtoDetailById, id);
|
||||
|
||||
var response = await Http.PostAsJsonAsync(url, id);
|
||||
//var result = await response.Content.ReadAsStringAsync();
|
||||
var result = await response.Content.ReadFromJsonAsync<UserModelDtoDetail>();
|
||||
//var user = JsonConvert.DeserializeObject<UserModelDtoDetail>(result);
|
||||
//var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserDetailById}";
|
||||
//Logger.Info("GetUserDetailByIdAsync url: " + url + ", " + id.ToString());
|
||||
|
||||
return result;
|
||||
//var response = await Http.PostAsJsonAsync(url, id);
|
||||
////var result = await response.Content.ReadAsStringAsync();
|
||||
//var result = await response.Content.ReadFromJsonAsync<UserModelDtoDetail>();
|
||||
////var user = JsonConvert.DeserializeObject<UserModelDtoDetail>(result);
|
||||
|
||||
//return result;
|
||||
}
|
||||
|
||||
public async Task<bool> RefreshToken()
|
||||
{
|
||||
Logger.Info("RefreshToken() called");
|
||||
Logger.Debug("RefreshToken() called");
|
||||
|
||||
var isTokenRefreshed = false;
|
||||
var url = $"{Setting.ApiBaseUrl}/{APIUrls.RefreshToken}";
|
||||
|
|
@ -251,7 +276,7 @@ public abstract class UserDataServiceClientBase : IUserDataService
|
|||
|
||||
try
|
||||
{
|
||||
Logger.Info("Refreshtoken url: " + url);
|
||||
Logger.Debug("Refreshtoken url: " + url);
|
||||
var response = await Http.PostAsync(url, new StringContent(serializedStr, Encoding.UTF8, "application/json"));
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue