From 5bc9663930d8cd481767cc3522e9b7d89d18c267 Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 29 Aug 2024 16:40:46 +0200 Subject: [PATCH 1/6] Changing UserDataServiceClientBase Http to Signalr in progress... --- TIAM.Services/SignalRTags.cs | 10 +- .../Services/UserDataServiceMobile.cs | 4 +- TIAMSharedUI/Pages/Login.razor.cs | 119 ++++++------ .../Client/Services/UserDataServiceWeb.cs | 4 +- .../Server/Controllers/UserAPIController.cs | 74 ++++--- .../Shared/Interfaces/IUserDataService.cs | 4 +- .../Services/SessionServiceClientBase.cs | 7 +- .../Services/UserDataServiceClientBase.cs | 181 ++++++++++-------- 8 files changed, 221 insertions(+), 182 deletions(-) diff --git a/TIAM.Services/SignalRTags.cs b/TIAM.Services/SignalRTags.cs index 1e540bd6..3dd95968 100644 --- a/TIAM.Services/SignalRTags.cs +++ b/TIAM.Services/SignalRTags.cs @@ -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; } diff --git a/TIAMMobileApp/Services/UserDataServiceMobile.cs b/TIAMMobileApp/Services/UserDataServiceMobile.cs index 07f5ae4f..dba4f1e3 100644 --- a/TIAMMobileApp/Services/UserDataServiceMobile.cs +++ b/TIAMMobileApp/Services/UserDataServiceMobile.cs @@ -17,7 +17,7 @@ using TIAMWebApp.Shared.Application.Utility; namespace TIAMMobileApp.Services { - public class UserDataServiceMobile(HttpClient http, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable logWriters) - : UserDataServiceClientBase(http, sessionService, secureStorageHandler, serviceProviderDataService, logWriters); + public class UserDataServiceMobile(HttpClient http, AdminSignalRClient adminSignalRClient, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable logWriters) + : UserDataServiceClientBase(http, adminSignalRClient, sessionService, secureStorageHandler, serviceProviderDataService, logWriters); } diff --git a/TIAMSharedUI/Pages/Login.razor.cs b/TIAMSharedUI/Pages/Login.razor.cs index 0a81b8d1..0ce4884f 100644 --- a/TIAMSharedUI/Pages/Login.razor.cs +++ b/TIAMSharedUI/Pages/Login.razor.cs @@ -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,80 +65,79 @@ 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(response); - var mainResponse = JsonSerializer.Deserialize(response, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + //var mainResponse = JsonSerializer.Deserialize(response, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); - if (mainResponse != null) + if (!mainResponse.IsSuccess) { + //await App.Current.MainPage.DisplayAlert("Error", "Invalid credentials", "Ok"); + //display error message via jsinterop + BrowserConsoleLogWriter.Info("Invalid credentials"); + messageClass = "text-danger"; + resultMessage = "Invalid credentials"; + await InvokeAsync(StateHasChanged); + //navManager.NavigateTo("login"); + } + else + { + string authResponseJson = mainResponse.Content.ToJson(); //JsonSerializer.Serialize(mainResponse.Content); - if (!mainResponse.IsSuccess) + var authResponse = authResponseJson.JsonTo(); //JsonSerializer.Deserialize(authResponseJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + + string accessToken = authResponse.AccessToken; + + var token = ProcessToken(accessToken); + + string userId = token.Claims.First(claim => claim.Type == JwtRegisteredClaimNames.NameId).Value; + string email = token.Claims.First(claim => claim.Type == JwtRegisteredClaimNames.Email).Value; + + var myId = Guid.Parse(userId); + //userDataService.User.Email = _email; + + var userBasicDetails = new UserBasicDetails(userId, email, authResponse.AccessToken, authResponse.RefreshToken); + + string userBasicDetailsJson = JsonSerializer.Serialize(userBasicDetails); + + + //save to local storage + await secureStorageHandler.SaveToSecureStorageAsync(nameof(Setting.UserBasicDetails), userBasicDetailsJson); + + await AuthStateProvider.GetAuthenticationStateAsync(); + + + //await App.Current.MainPage.DisplayAlert("Success", "Successful login", "Ok"); + //display success message via jsinterop + BrowserConsoleLogWriter.Info("Successful login"); + var user = await userDataService.IsLoggedInAsync(myId); + + _adminSignalRClient.GetByIdAsync(SignalRTags.GetSiteViewModelByUserId, signalResponseMessage => { - //await App.Current.MainPage.DisplayAlert("Error", "Invalid credentials", "Ok"); - //display error message via jsinterop - BrowserConsoleLogWriter.Info("Invalid credentials"); - messageClass = "text-danger"; - resultMessage = "Invalid credentials"; - await InvokeAsync(StateHasChanged); - //navManager.NavigateTo("login"); - } - else - { - string authResponseJson = JsonSerializer.Serialize(mainResponse.Content); + sessionService.SiteViewModel.Initialize(signalResponseMessage.ResponseData!); + BrowserConsoleLogWriter.Debug($"UnreadMessages: {sessionService.SiteViewModel.UnreadMessages.Count}"); - var authResponse = JsonSerializer.Deserialize(authResponseJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + componentUpdateService.CallRequestRefreshAll(); + return Task.CompletedTask; + }, user.UserId).Forget(); - string accessToken = authResponse.AccessToken; + messageClass = "text-success"; + resultMessage = "Successful login"; - var token = ProcessToken(accessToken); - - string userId = token.Claims.First(claim => claim.Type == JwtRegisteredClaimNames.NameId).Value; - string email = token.Claims.First(claim => claim.Type == JwtRegisteredClaimNames.Email).Value; - - var myId = Guid.Parse(userId); - //userDataService.User.Email = _email; - - var userBasicDetails = new UserBasicDetails(userId, email, authResponse.AccessToken, authResponse.RefreshToken); - - string userBasicDetailsJson = JsonSerializer.Serialize(userBasicDetails); - - - //save to local storage - await secureStorageHandler.SaveToSecureStorageAsync(nameof(Setting.UserBasicDetails), userBasicDetailsJson); - - await AuthStateProvider.GetAuthenticationStateAsync(); - - - //await App.Current.MainPage.DisplayAlert("Success", "Successful login", "Ok"); - //display success message via jsinterop - BrowserConsoleLogWriter.Info("Successful login"); - var user = await userDataService.IsLoggedInAsync(myId); - - _adminSignalRClient.GetByIdAsync(SignalRTags.GetSiteViewModelByUserId, signalResponseMessage => - { - sessionService.SiteViewModel.Initialize(signalResponseMessage.ResponseData!); - BrowserConsoleLogWriter.Debug($"UnreadMessages: {sessionService.SiteViewModel.UnreadMessages.Count}"); - - componentUpdateService.CallRequestRefreshAll(); - return Task.CompletedTask; - }, user.UserId).Forget(); - - messageClass = "text-success"; - resultMessage = "Successful login"; - - SaveToSessionInfo(user).Forget(); - navManager.NavigateTo("/"); - } + SaveToSessionInfo(user).Forget(); + navManager.NavigateTo("/"); } } else @@ -145,10 +145,9 @@ namespace TIAMSharedUI.Pages //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() diff --git a/TIAMWebApp/Client/Services/UserDataServiceWeb.cs b/TIAMWebApp/Client/Services/UserDataServiceWeb.cs index 71268bf4..6a9e8d63 100644 --- a/TIAMWebApp/Client/Services/UserDataServiceWeb.cs +++ b/TIAMWebApp/Client/Services/UserDataServiceWeb.cs @@ -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 logWriters) - : UserDataServiceClientBase(http, sessionService, secureStorageHandler, serviceProviderDataService, logWriters); + public class UserDataServiceWeb(HttpClient http, AdminSignalRClient adminSignalRClient, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable logWriters) + : UserDataServiceClientBase(http, adminSignalRClient, sessionService, secureStorageHandler, serviceProviderDataService, logWriters); } diff --git a/TIAMWebApp/Server/Controllers/UserAPIController.cs b/TIAMWebApp/Server/Controllers/UserAPIController.cs index 09e86ed8..49265339 100644 --- a/TIAMWebApp/Server/Controllers/UserAPIController.cs +++ b/TIAMWebApp/Server/Controllers/UserAPIController.cs @@ -96,28 +96,40 @@ 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 AuthenticateUser(LoginModel authenticateUser) + { + _logger.Info($"AuthenticateUser; {authenticateUser.Email}"); + + var loggedInModel = await _loginService.LoginAsync(authenticateUser.Email, authenticateUser.Password); + + if (!loggedInModel.IsLoggedIn) { - var response = new MainResponse - { - Content = new AuthenticationResponse - { - RefreshToken = loggedInModel.LoggedInUser.RefreshToken, - AccessToken = loggedInModel.AccessToken - }, - - IsSuccess = true, - ErrorMessage = "" - }; - - return Ok(response); + _logger.Warning(@"User not valid! errorCode: " + loggedInModel.LoginErrorCode); + return null; } - _logger.Warning(@"User not valid! errorCode: " + loggedInModel.LoginErrorCode); - return Unauthorized(); + var response = new MainResponse + { + Content = new AuthenticationResponse + { + RefreshToken = loggedInModel.LoggedInUser.RefreshToken, + AccessToken = loggedInModel.AccessToken + }, + + IsSuccess = true, + ErrorMessage = "" + }; + + return response; } [AllowAnonymous] @@ -199,7 +211,7 @@ namespace TIAMWebApp.Server.Controllers else { var user = JObject.Parse(serializedRegistrationModel.GetRawText()).ToObject(); - 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> 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? GetUserByEmail(string email) + [SignalR(SignalRTags.GetUserModelDtoByEmail)] + public async Task GetUserByEmail(string email) { _logger.Info($"GetUserByEmail called with email: {email}"); - var result = await userDal.GetUserModelDtoByEmailAsync(email, false); - if (result == null) - { - UserModelDto resultDto = new UserModelDto(); - return resultDto; - } - else - { - return result; - } + return await userDal.GetUserModelDtoByEmailAsync(email, false); + + //var result = await userDal.GetUserModelDtoByEmailAsync(email, false); + //if (result != null) return result; + + //var resultDto = new UserModelDto(); + //return resultDto; } [AllowAnonymous] [HttpPost] [Route(APIUrls.GetUserByIdRouteName)] + [SignalR(SignalRTags.GetUserModelDtoById)] public async Task GetUserById([FromBody] Guid id) { _logger.Info($"GetUserById called with id: {id}"); + return await userDal.GetUserModelDtoByIdAsync(id, true); } [AllowAnonymous] [HttpPost] [Route(APIUrls.GetUserDetailByIdRouteName)] + [SignalR(SignalRTags.GetUserModelDtoDetailById)] public async Task GetUserDetailById([FromBody] Guid id) { _logger.Info($"GetUserDetailById called with id: {id}"); diff --git a/TIAMWebApp/Shared/Interfaces/IUserDataService.cs b/TIAMWebApp/Shared/Interfaces/IUserDataService.cs index 202a5ae0..72cbd3dd 100644 --- a/TIAMWebApp/Shared/Interfaces/IUserDataService.cs +++ b/TIAMWebApp/Shared/Interfaces/IUserDataService.cs @@ -8,14 +8,14 @@ namespace TIAMWebApp.Shared.Application.Interfaces { public Task IsLoggedInAsync(Guid id); - public Task AuthenticateUser(LoginModel loginModel); + public Task AuthenticateUser(LoginModel loginModel); public Task<(bool isSuccess, string ErrorMessage)> CreateUser(RegistrationModel regModel); public Task<(bool isSuccess, UserModelDto? user)> CreateGuestUser(RegistrationModel regModel); public Task TestUserApi(int Param); //public Task> GetUserRolesAsync(UserModel userModel); - public Task?> GetUsersAsync(); + public Task> GetUsersAsync(); public Task> GetUsersWithDetailsAsync(); diff --git a/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs b/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs index 1159d3b9..fa0bec25 100644 --- a/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs +++ b/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs @@ -23,12 +23,7 @@ public abstract class SessionServiceClientBase : ISessionService public virtual List 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() diff --git a/TIAMWebApp/Shared/Services/UserDataServiceClientBase.cs b/TIAMWebApp/Shared/Services/UserDataServiceClientBase.cs index 5d806ba7..f562f87f 100644 --- a/TIAMWebApp/Shared/Services/UserDataServiceClientBase.cs +++ b/TIAMWebApp/Shared/Services/UserDataServiceClientBase.cs @@ -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,18 +18,21 @@ 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 logWriters) + protected UserDataServiceClientBase(HttpClient http, AdminSignalRClient adminSignalRClient, ISessionService sessionService, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable logWriters) { Http = http; + AdminSignalRClient = adminSignalRClient; + SessionService = sessionService; SecureStorageHandler = secureStorageHandler; - + ServiceProviderDataService = serviceProviderDataService; Logger = new LoggerClient(this.GetType().Name, logWriters.ToArray()); } @@ -71,34 +75,37 @@ public abstract class UserDataServiceClientBase : IUserDataService return result; } - public async Task AuthenticateUser(LoginModel loginModel) + public async Task 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(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); + // result = await response.Content.ReadAsStringAsync(); //} - //catch (Exception ex) + //else //{ - // _logger.Error(ex.Message, ex); + // result = await response.Content.ReadAsStringAsync(); //} - if (response.IsSuccessStatusCode) - { - result = await response.Content.ReadAsStringAsync(); - } - else - { - result = await response.Content.ReadAsStringAsync(); - } - - //result = await response.Content.ReadAsStringAsync(); - return result; - + ////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(result); } else @@ -155,89 +162,107 @@ public abstract class UserDataServiceClientBase : IUserDataService } - public async Task?> GetUsersAsync() + public async Task> GetUsersAsync() { - return await Http.GetFromJsonAsync>(APIUrls.GetUsers); + Logger.Debug($"GetUsersAsync"); + + return await AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllUserModelDto) ?? []; + + //return await Http.GetFromJsonAsync>(APIUrls.GetUsers); } public async Task> GetUsersWithDetailsAsync() { - var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUsersWithDetails}"; + Logger.Debug($"GetUsersWithDetailsAsync"); - Logger.Info("GetUserByEmailAsync url: " + url + "!"); - var response = await Http.GetFromJsonAsync>(APIUrls.GetUsersWithDetails); - //var result = await response.Content.ReadAsStringAsync(); - //var user = JsonConvert.DeserializeObject(result); + return await AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllUserModelDtoDetails) ?? []; + + ////var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUsersWithDetails}"; + + ////Logger.Info("GetUserByEmailAsync url: " + url + "!"); + ////var response = await Http.GetFromJsonAsync>(APIUrls.GetUsersWithDetails); + //////var result = await response.Content.ReadAsStringAsync(); + //////var user = JsonConvert.DeserializeObject(result); - return response ?? []; + ////return response ?? []; } public async Task 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(SignalRTags.GetUserModelDtoByEmail, email); - if (response.IsSuccessStatusCode) - { - var jsonResponse = await response.Content.ReadAsStringAsync(); - var user = System.Text.Json.JsonSerializer.Deserialize(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(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 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(result); + return await AdminSignalRClient.GetByIdAsync(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(result); + + //return user; } public async Task 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(SignalRTags.GetUserModelDtoDetailById, id); - var response = await Http.PostAsJsonAsync(url, id); - //var result = await response.Content.ReadAsStringAsync(); - var result = await response.Content.ReadFromJsonAsync(); - //var user = JsonConvert.DeserializeObject(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(); + ////var user = JsonConvert.DeserializeObject(result); + + //return result; } public async Task 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) { From 1f59b4b8a31cdfa5e53b4c970928a7b9bb9cf33e Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 29 Aug 2024 18:01:30 +0200 Subject: [PATCH 2/6] ComboboxItemSelector.razor improvements, fixes, etc... --- .../Shared/ComboboxItemSelector.razor | 49 ++++++++++++------- .../Shared/Services/AdminSignalRClient.cs | 2 +- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/TIAMSharedUI/Shared/ComboboxItemSelector.razor b/TIAMSharedUI/Shared/ComboboxItemSelector.razor index 9195bb66..fce38927 100644 --- a/TIAMSharedUI/Shared/ComboboxItemSelector.razor +++ b/TIAMSharedUI/Shared/ComboboxItemSelector.razor @@ -1,7 +1,9 @@ @using System.Linq.Expressions @using AyCode.Core.Extensions +@using AyCode.Core.Helpers @using AyCode.Core.Loggers @using AyCode.Services.Loggers +@using AyCode.Services.SignalRs @using TIAM.Core.Loggers @using TIAM.Entities.Products @using TIAM.Entities.Transfers @@ -79,7 +81,7 @@ [Parameter] public Guid? ProductId { get; set; } - public List Destinations = new List(); + public List Destinations = []; public DxTextBox TextField; @@ -87,22 +89,21 @@ ILogger _logger; - IEnumerable Data { get; set; } + List Data { get; set; } = []; private string Address { get; set; } private string ValidationMessage { get; set; } - private TransferDestination _selectedDestination; - public TransferDestination SelectedDestination + private TransferDestination? _selectedDestination; + public TransferDestination? SelectedDestination { get => _selectedDestination; set { - if (_selectedDestination != value) - { - _selectedDestination = value; - SetNewDestination(value.AddressString!); - } + if (_selectedDestination == value) return; + + _selectedDestination = value; + SetNewDestination(value?.AddressString ?? string.Empty); } } @@ -115,8 +116,6 @@ { _logger = new LoggerClient(LogWriters.ToArray()); - Data = await _adminSignalRClient.GetAllAsync>(SignalRTags.GetAllTransferDestinations); - Guid? productAddressId = Guid.Empty; if (!ProductId.IsNullOrEmpty()) { @@ -130,16 +129,28 @@ } } - _logger.Debug($"List length: {Data.Count().ToString()}"); - if (Data.Any(x => x.AddressId == (Guid)productAddressId)) + _adminSignalRClient.GetAllAsync>(SignalRTags.GetAllTransferDestinations, response => { - SelectedDestination = Data.Where(x => x.AddressId == (Guid)productAddressId).FirstOrDefault()!; - } - else - { - SelectedDestination = Data.FirstOrDefault(); - } + Data.Clear(); + SelectedDestination = null; + + if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) + { + _logger.Error($"OnInitializedAsync->GetAllTransferDestinations; response.Status: {response.Status}"); + return Task.CompletedTask; + } + + Data.AddRange(response.ResponseData); + + _logger.Debug($"TransferDestinations Data length: {Data.Count}"); + SelectedDestination = productAddressId.IsNullOrEmpty() ? Data.FirstOrDefault() : Data.FirstOrDefault(x => x.AddressId == productAddressId); + + return Task.CompletedTask; + }).Forget(); + + //await _adminSignalRClient.GetAllIntoAsync(Data, SignalRTags.GetAllTransferDestinations); } + // RenderFragment GetSelectedItemDescription() // { // if (SelectedDestination != null) diff --git a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs index 09889a38..e87959cd 100644 --- a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs +++ b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs @@ -61,9 +61,9 @@ namespace TIAMWebApp.Shared.Application.Services //TODO: AdminSignalRClient.GetAllIntoAsync(_cars, SignalRTags.GetAllCarsByProductId, [productId]) - J. return GetAllAsync>(SignalRTags.GetAllCarsByProductId, response => { + intoCars.Clear(); if (response is { Status: SignalResponseStatus.Success, ResponseData: not null }) { - intoCars.Clear(); intoCars.AddRange(response.ResponseData); } From 5355bd09cdba2326a8c6924e261fc4f7a64be179 Mon Sep 17 00:00:00 2001 From: Loretta Date: Fri, 30 Aug 2024 16:29:39 +0200 Subject: [PATCH 3/6] improvements, fixes, etc... --- TIAM.Database/DataLayers/Admins/AdminDal.cs | 2 +- .../ITransferApiControllerClient.cs | 7 +- .../ITransferApiControllerCommon.cs | 2 +- .../CardComponents/ProductCardComponent.razor | 77 ++++++++--------- .../ProductDetailGridComponent.razor | 9 +- .../User/SysAdmins/ProductGridComponent.razor | 9 +- ...tinationToProductDetailGridComponent.razor | 34 ++++---- ...ferDestinationToProductGridComponent.razor | 8 +- .../Shared/ComboboxItemSelector.razor | 42 ++++----- .../ServiceProviderAPIController.cs | 85 ++++++++++--------- .../Controllers/TransferDataAPIController.cs | 4 +- .../Shared/Services/AdminSignalRClient.cs | 25 ++---- .../Services/ServiceProviderDataService.cs | 7 +- 13 files changed, 147 insertions(+), 164 deletions(-) diff --git a/TIAM.Database/DataLayers/Admins/AdminDal.cs b/TIAM.Database/DataLayers/Admins/AdminDal.cs index b0fce43f..d3cccfdc 100644 --- a/TIAM.Database/DataLayers/Admins/AdminDal.cs +++ b/TIAM.Database/DataLayers/Admins/AdminDal.cs @@ -148,7 +148,7 @@ namespace TIAM.Database.DataLayers.Admins #region TransferDestination - public List GetTransferDestinations() => Session(ctx => ctx.GetTransferDestinations().ToList()); + public Task> GetTransferDestinationsAsync() => SessionAsync(ctx => ctx.GetTransferDestinations().ToList()); public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)); public Task GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationById(transferDestinationId)); public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson()); diff --git a/TIAM.Services/Interfaces/ITransferApiControllerClient.cs b/TIAM.Services/Interfaces/ITransferApiControllerClient.cs index 59d6b1fd..2104fb72 100644 --- a/TIAM.Services/Interfaces/ITransferApiControllerClient.cs +++ b/TIAM.Services/Interfaces/ITransferApiControllerClient.cs @@ -1,5 +1,8 @@ -namespace TIAM.Services.Interfaces; +using TIAM.Entities.Transfers; -public interface ITransferApiControllerClient : IUserApiControllerCommon +namespace TIAM.Services.Interfaces; + +public interface ITransferApiControllerClient : ITransferApiControllerCommon { + Task GetTransferDestinationsInto(List intoDestinationList, Action? callback = null); } \ No newline at end of file diff --git a/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs b/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs index a2925269..02b8158e 100644 --- a/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs +++ b/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs @@ -26,7 +26,7 @@ public interface ITransferApiControllerCommon #endregion Drivers #region TransferDestination - public List GetTransferDestinations(); + public Task> GetTransferDestinations(); public Task GetTransferDestinationById(Guid transferDestinationId); public Task CreateTransferDestination(TransferDestination transferDestination); public Task UpdateTransferDestination(TransferDestination transferDestination); diff --git a/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor b/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor index e505c230..a9c95b7b 100644 --- a/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor +++ b/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor @@ -1,4 +1,5 @@ -@using BlazorAnimation +@using AyCode.Core.Helpers +@using BlazorAnimation @using TIAM.Core.Enums @using TIAM.Entities.Addresses @using TIAM.Entities.Products @@ -42,7 +43,7 @@

Information

- @RenderDetailsItem("fa-solid fa-user", "Contact Name", productProfile.FullName) + @RenderDetailsItem("fa-solid fa-user", "Contact Name", _productProfile.FullName) @RenderDetailsItem("fa-solid fa-circle-info", "Description", Context.Description)
@@ -79,16 +80,16 @@
@{ - if (!isAddressTransferDestination) + if (!_isAddressTransferDestination) { - + } }
-

@msg

+

@_msg

@@ -120,11 +121,11 @@ AccordionExpandMode ExpandMode { get; set; } = AccordionExpandMode.SingleOrNone; AccordionExpandCollapseAction ExpandCollapseAction { get; set; } = AccordionExpandCollapseAction.HeaderClick; - private Profile productProfile = new Profile(); - private List destinations = new List(); - string msg; - private bool isSaveActive = false; - private bool isAddressTransferDestination = false; + private Profile _productProfile = new Profile(); + private readonly List _destinations = []; + string _msg; + private bool _isSaveActive = false; + private bool _isAddressTransferDestination = false; private async Task CopyUrl(string url) { @@ -139,19 +140,20 @@ protected override async Task OnInitializedAsync() { var productOwner = await AdminSignalRClient.GetByIdAsync>(SignalRTags.GetCompaniesById, Context.ServiceProviderId); - var ProductProfiles = await AdminSignalRClient.GetByIdAsync>(SignalRTags.GetProfileById, Context.ProfileId); - await AdminSignalRClient.GetAllIntoAsync(destinations, SignalRTags.GetAllTransferDestinations); + var productProfiles = await AdminSignalRClient.GetByIdAsync>(SignalRTags.GetProfileById, Context.ProfileId); + if (productOwner != null) { - ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAndOwnerAffiliateIdAsync(new Guid[] { productOwner[0].AffiliateId, Context.Id }); - } - if (ProductProfiles != null) - { - productProfile = ProductProfiles[0]; - var AddressId = productProfile.AddressId; - isAddressTransferDestination = CheckDestinations(AddressId); + ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAndOwnerAffiliateIdAsync([productOwner[0].AffiliateId, Context.Id]); } + if (productProfiles != null) + { + _productProfile = productProfiles[0]; + _isAddressTransferDestination = CheckDestinations(_productProfile.AddressId); + } + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); await base.OnInitializedAsync(); } @@ -163,40 +165,27 @@ RenderFragment RenderDetailsItem(string iconCssClass, string caption, string value) { return @
-
- -
-
- -
@value
-
-
; +
+ +
+
+ +
@value
+
+ ; } private bool CheckDestinations(Guid addressId) { - if (destinations != null) - { - if (destinations.Any(d => d.AddressId == addressId)) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } + return _destinations.Any(d => d.AddressId == addressId); } private async Task SaveAsDestination(Address address, Product product) { - TransferDestination transferDestination = new TransferDestination(); + var transferDestination = new TransferDestination(); transferDestination.Id = Guid.NewGuid(); transferDestination.Name = product.Name; + if (!string.IsNullOrEmpty(product.Profile.Description)) { transferDestination.Description = product.Profile.Description; @@ -205,8 +194,10 @@ { transferDestination.Description = "No description available"; } + transferDestination.AddressId = address.Id; transferDestination.AddressString = address.AddressText; + var result = await AdminSignalRClient.PostDataAsync(SignalRTags.CreateTransferDestination, transferDestination); await InvokeAsync(StateHasChanged); } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor index 7a436f9e..7927f52e 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor @@ -143,7 +143,7 @@ [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; [Parameter] public bool ShowManageButtons { get; set; } = false; - private List destinations = []; + private List _destinations = []; private ProductDetailGrid _productGrid = null!; private LoggerClient _logger = null!; @@ -157,7 +157,8 @@ protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(destinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); //DataSource = new List
(); } @@ -166,9 +167,9 @@ { - if(destinations!=null) + if(_destinations!=null) { - if (destinations.Any(d => d.AddressId == addressId)) + if (_destinations.Any(d => d.AddressId == addressId)) { return true; } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor index c17c9960..0165a30e 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor @@ -144,7 +144,7 @@ [Parameter] public EventCallback OnGridEditModelSaving { get; set; } [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; - private List destinations = []; + private List _destinations = []; private ProductGrid _productGrid = null!; private LoggerClient _logger = null!; @@ -159,16 +159,17 @@ protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(destinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); } private bool CheckDestinations(Guid addressId) { - if (destinations != null) + if (_destinations != null) { - if (destinations.Any(d => d.AddressId == addressId)) + if (_destinations.Any(d => d.AddressId == addressId)) { return true; } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor index 075e9710..93135d5c 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor @@ -36,10 +36,10 @@ @{ - var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; + var transferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; } - @@ -47,10 +47,10 @@ @{ - var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; + var transferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; } - @@ -111,11 +111,11 @@ [Parameter] public bool IsProductIdReadonly { get; set; } = false; [Parameter] public bool IsDestinationIdReadonly { get; set; } = false; - private bool ProductIdReadOnly = false; - private bool DestinationIdReadOnly = false; + private bool _productIdReadOnly = false; + private bool _destinationIdReadOnly = false; //private bool? _isNewState = null; - private List _transferDestinations = []; + private List _destinations = []; private List _products = []; private LoggerClient _logger = null!; @@ -123,8 +123,10 @@ protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(_transferDestinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget(); + base.OnInitialized(); } @@ -132,9 +134,9 @@ { if (!e.IsNew) { - DestinationIdReadOnly = true; + _destinationIdReadOnly = true; - ProductIdReadOnly = true; + _productIdReadOnly = true; } else @@ -143,12 +145,12 @@ { ((TransferDestinationToProduct)(e.EditModel)).TransferDestinationId = (Guid)ContextIds[0]; } - DestinationIdReadOnly = IsDestinationIdReadonly; + _destinationIdReadOnly = IsDestinationIdReadonly; if (IsProductIdReadonly) { ((TransferDestinationToProduct)(e.EditModel)).ProductId = (Guid)ContextIds[0]; } - ProductIdReadOnly = IsProductIdReadonly; + _productIdReadOnly = IsProductIdReadonly; } if (!e.IsNew) return; @@ -157,14 +159,14 @@ private void OnGridEditModelSaving(GridEditModelSavingEventArgs e) { - DestinationIdReadOnly = false; - ProductIdReadOnly = false; + _destinationIdReadOnly = false; + _productIdReadOnly = false; } private void EditCanceling(GridEditCancelingEventArgs e) { - DestinationIdReadOnly = false; - ProductIdReadOnly = false; + _destinationIdReadOnly = false; + _productIdReadOnly = false; } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor index 9ee683bf..f7d0f55d 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor @@ -47,7 +47,7 @@ var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; } - @@ -101,15 +101,17 @@ private LoggerClient _logger = null!; private bool? _isNewState = null; - private List _transferDestinations = []; + private List _destinations = []; private List _products = []; protected override async Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(_transferDestinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget(); + await base.OnInitializedAsync(); } diff --git a/TIAMSharedUI/Shared/ComboboxItemSelector.razor b/TIAMSharedUI/Shared/ComboboxItemSelector.razor index fce38927..90e9d01c 100644 --- a/TIAMSharedUI/Shared/ComboboxItemSelector.razor +++ b/TIAMSharedUI/Shared/ComboboxItemSelector.razor @@ -25,7 +25,7 @@ - -

Selected address: @Address

+

Selected address: @_address

@*

@@ -81,18 +81,16 @@ [Parameter] public Guid? ProductId { get; set; } - public List Destinations = []; - public DxTextBox TextField; TransferDestination Result; ILogger _logger; - List Data { get; set; } = []; + readonly List _destinations = []; - private string Address { get; set; } - private string ValidationMessage { get; set; } + private string _address = string.Empty; + private string _validationMessage = string.Empty; private TransferDestination? _selectedDestination; public TransferDestination? SelectedDestination @@ -129,25 +127,19 @@ } } - _adminSignalRClient.GetAllAsync>(SignalRTags.GetAllTransferDestinations, response => + _adminSignalRClient.GetTransferDestinationsInto(_destinations, () => { - Data.Clear(); - SelectedDestination = null; - - if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) - { - _logger.Error($"OnInitializedAsync->GetAllTransferDestinations; response.Status: {response.Status}"); - return Task.CompletedTask; - } - - Data.AddRange(response.ResponseData); - - _logger.Debug($"TransferDestinations Data length: {Data.Count}"); - SelectedDestination = productAddressId.IsNullOrEmpty() ? Data.FirstOrDefault() : Data.FirstOrDefault(x => x.AddressId == productAddressId); - - return Task.CompletedTask; + SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId); }).Forget(); + // _adminSignalRClient.GetAllIntoAsync(_destinations, SignalRTags.GetAllTransferDestinations, null, resultData => + // { + // if (resultData == null) SelectedDestination = null; + // else SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId); + + // return Task.CompletedTask; + // }).Forget(); + //await _adminSignalRClient.GetAllIntoAsync(Data, SignalRTags.GetAllTransferDestinations); } @@ -170,13 +162,13 @@ public void OnSelectedAddressChanged(string address) { - Address = address; + _address = address; OnSliderChanged.InvokeAsync(address); } public void SetNewDestination(string address) { - Address = address; + _address = address; OnSliderChanged.InvokeAsync(address); } diff --git a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs index f085fce6..e137d9a4 100644 --- a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs +++ b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs @@ -497,64 +497,69 @@ namespace TIAMWebApp.Server.Controllers [Tags("In-Progress", "Product")] public async Task GetQRCodeByProductId([FromBody] Guid productId) { - _logger.Info(@"GetQRCode called"); + _logger.Info($"GetQRCode called; productId: {productId}"); - if (productId == Guid.Empty) - { - return BadRequest("Product is required"); - } - else - { - //var result = _serviceProviderDal.GetQRCodeAsync(productId); + return BadRequest("OBSOLATE"); + if (productId.IsNullOrEmpty()) return BadRequest("Product is required"); - var qrGenerator = new QRCodeGenerator(); - var qrCodeData = qrGenerator.CreateQrCode($"https://touriam.com/{productId}", QRCodeGenerator.ECCLevel.Q); - var qrCode = new QRCode(qrCodeData); - //Bitmap qrCodeImage = qrCode.GetGraphic(20); - //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); - var rootpath = System.IO.Path.Combine(env.WebRootPath, "assets"); - var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); - _logger.Info($@"qrCodeLogo: {rootpath}/myimage.png"); - var ms = new MemoryStream(); + //var result = _serviceProviderDal.GetQRCodeAsync(productId); + + var qrGenerator = new QRCodeGenerator(); + var qrCodeData = qrGenerator.CreateQrCode($"https://touriam.com/{productId}", QRCodeGenerator.ECCLevel.Q); + var qrCode = new QRCode(qrCodeData); + + //Bitmap qrCodeImage = qrCode.GetGraphic(20); + //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); + var rootpath = Path.Combine(env.WebRootPath, "assets"); + var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); + + _logger.Debug($@"qrCodeLogo: {rootpath}/myimage.png"); + + byte[] byteImage; + using (var ms = new MemoryStream()) + { qrCodeImage.Save(ms, ImageFormat.Jpeg); - var byteImage = ms.ToArray(); - - var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 - - return Ok(sigBase64); + byteImage = ms.ToArray(); } + + var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 + + return Ok(sigBase64); } [AllowAnonymous] [HttpPost] [Route(APIUrls.GetQrCodeByProductIdAndOwnerAffiliateIdRouteName)] - public async Task GetQrCodeByProductIdAndOwnerAffiliateId([FromBody] Guid[] Ids) + public async Task GetQrCodeByProductIdAndOwnerAffiliateId([FromBody] Guid[] ids) { _logger.Info(@"GetQRCode called"); - if (Ids[0].IsNullOrEmpty() || Ids[1].IsNullOrEmpty()) + if (ids[0].IsNullOrEmpty() || ids[1].IsNullOrEmpty()) { return BadRequest("Product is required"); } - else + + var qrGenerator = new QRCodeGenerator(); + var qrCodeData = qrGenerator.CreateQrCode($"{Setting.BaseUrl}/public/transfer/{ids[0]}/{ids[1]}", QRCodeGenerator.ECCLevel.Q); + var qrCode = new QRCode(qrCodeData); + + //Bitmap qrCodeImage = qrCode.GetGraphic(20); + //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); + var rootpath = Path.Combine(env.WebRootPath, "assets"); + var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); + + _logger.Info($@"qrCodeLogo: {rootpath}/myimage.png"); + + byte[] byteImage; + using (var ms = new MemoryStream()) { - - var qrGenerator = new QRCodeGenerator(); - var qrCodeData = qrGenerator.CreateQrCode($"{Setting.BaseUrl}/public/transfer/{Ids[0]}/{Ids[1]}", QRCodeGenerator.ECCLevel.Q); - var qrCode = new QRCode(qrCodeData); - //Bitmap qrCodeImage = qrCode.GetGraphic(20); - //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); - var rootpath = System.IO.Path.Combine(env.WebRootPath, "assets"); - var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); - _logger.Info($@"qrCodeLogo: {rootpath}/myimage.png"); - var ms = new MemoryStream(); qrCodeImage.Save(ms, ImageFormat.Jpeg); - var byteImage = ms.ToArray(); - - var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 - - return Ok(sigBase64); + byteImage = ms.ToArray(); } + + var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 + + return Ok(sigBase64); } } } \ No newline at end of file diff --git a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs index 38a200e0..a04aa8f8 100644 --- a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs +++ b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs @@ -77,9 +77,9 @@ namespace TIAMWebApp.Server.Controllers [HttpGet] [Route(APIUrls.GetTransferDestinationsRouteName)] [SignalR(SignalRTags.GetAllTransferDestinations)] - public List GetTransferDestinations() + public async Task> GetTransferDestinations() { - return _adminDal.GetTransferDestinations(); + return await _adminDal.GetTransferDestinationsAsync(); } //[Authorize] diff --git a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs index e87959cd..8e423118 100644 --- a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs +++ b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs @@ -2,7 +2,6 @@ using AyCode.Core.Consts; using AyCode.Core.Helpers; using AyCode.Services.Loggers; -using AyCode.Services.SignalRs; using TIAM.Entities.Drivers; using TIAM.Entities.Transfers; using TIAM.Entities.Users; @@ -58,19 +57,7 @@ namespace TIAMWebApp.Shared.Application.Services { Logger.Detail($"GetAllCarsByProductIdAsync client called; productId: {productId}"); - //TODO: AdminSignalRClient.GetAllIntoAsync(_cars, SignalRTags.GetAllCarsByProductId, [productId]) - J. - return GetAllAsync>(SignalRTags.GetAllCarsByProductId, response => - { - intoCars.Clear(); - if (response is { Status: SignalResponseStatus.Success, ResponseData: not null }) - { - intoCars.AddRange(response.ResponseData); - } - - callback?.Invoke(); - - return Task.CompletedTask; - }, [productId]); + return GetAllIntoAsync(intoCars, SignalRTags.GetAllCarsByProductId, [productId], callback); } #endregion ICompanyApiController @@ -137,10 +124,12 @@ namespace TIAMWebApp.Shared.Application.Services throw new NotImplementedException(); } - public List GetTransferDestinations() - { - throw new NotImplementedException(); - } + public async Task> GetTransferDestinations() + => await GetAllAsync>(SignalRTags.GetAllTransferDestinations) ?? []; + + public Task GetTransferDestinationsInto(List intoDestinationList, Action? callback = null) + => GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinations, null, callback); + public async Task GetTransferDestinationById(Guid transferDestinationId) { diff --git a/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs b/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs index 7d0a70b8..b050a6f4 100644 --- a/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs +++ b/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs @@ -199,8 +199,6 @@ namespace TIAMWebApp.Shared.Application.Services public async Task GetQRCodeByProductIdAsync(Guid productId) { - - var url = APIUrls.GetQrCodeByProductId; var response = await http.PostAsJsonAsync(url, productId); if (response.IsSuccessStatusCode) @@ -215,11 +213,10 @@ namespace TIAMWebApp.Shared.Application.Services } } - public async Task GetQRCodeByProductIdAndOwnerAffiliateIdAsync(Guid[] Ids) + public async Task GetQRCodeByProductIdAndOwnerAffiliateIdAsync(Guid[] ids) { - var url = APIUrls.GetQrCodeByProductIdAndOwnerAffiliateId; - var response = await http.PostAsJsonAsync(url, Ids); + var response = await http.PostAsJsonAsync(url, ids); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); From 05b76fe8a46a5591ec81eaf00decfe4c942cdc69 Mon Sep 17 00:00:00 2001 From: Loretta Date: Sat, 31 Aug 2024 07:52:13 +0200 Subject: [PATCH 4/6] improvements, fixes --- TIAM.Database/DataLayers/Admins/AdminDal.cs | 3 +- .../Transfers/TransferDestination.cs | 1 + .../ITransferApiControllerClient.cs | 3 +- .../ITransferApiControllerCommon.cs | 1 + TIAM.Services/SignalRTags.cs | 7 +- TIAMSharedUI/Pages/TransferPage.razor | 3 +- .../CardComponents/ProductCardComponent.razor | 2 +- .../User/Hotels/CreateAndManageTransfer.razor | 69 +++++++++---------- .../ProductDetailGridComponent.razor | 2 +- .../User/SysAdmins/ProductGridComponent.razor | 2 +- ...tinationToProductDetailGridComponent.razor | 2 +- ...ferDestinationToProductGridComponent.razor | 2 +- .../Shared/ComboboxItemSelector.razor | 34 +++------ .../BaseComponents/BasePageComponent.cs | 7 ++ .../BaseComponents/UserBasePageComponent.cs | 10 +-- TIAMSharedUI/Shared/NavHelperComponent.razor | 8 +-- .../Controllers/TransferDataAPIController.cs | 7 ++ .../Shared/Services/AdminSignalRClient.cs | 8 ++- .../Services/SessionServiceClientBase.cs | 3 +- TIAMWebApp/Shared/Utility/PageHistoryState.cs | 22 ++---- 20 files changed, 98 insertions(+), 98 deletions(-) diff --git a/TIAM.Database/DataLayers/Admins/AdminDal.cs b/TIAM.Database/DataLayers/Admins/AdminDal.cs index d3cccfdc..25e2ab7d 100644 --- a/TIAM.Database/DataLayers/Admins/AdminDal.cs +++ b/TIAM.Database/DataLayers/Admins/AdminDal.cs @@ -149,9 +149,10 @@ namespace TIAM.Database.DataLayers.Admins #region TransferDestination public Task> GetTransferDestinationsAsync() => SessionAsync(ctx => ctx.GetTransferDestinations().ToList()); + public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)); public Task GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationById(transferDestinationId)); - public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson()); + public Task> GetPublicTransferDestinationsAsync(Guid productId) => SessionAsync(ctx => ctx.GetTransferDestinations().Where(x => !x.ProductId.HasValue || x.ProductId == productId).ToList()); public Task AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination)); public Task UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination)); diff --git a/TIAM.Entities/Transfers/TransferDestination.cs b/TIAM.Entities/Transfers/TransferDestination.cs index 6a4432f3..999aad33 100644 --- a/TIAM.Entities/Transfers/TransferDestination.cs +++ b/TIAM.Entities/Transfers/TransferDestination.cs @@ -16,6 +16,7 @@ namespace TIAM.Entities.Transfers [ForeignKey(nameof(AddressId))] public virtual Address Address { get; set; } + public Guid? ProductId { get; set; } //public virtual List Products { get; set; } //public virtual List TransferDestinationToProducts { get; set; } diff --git a/TIAM.Services/Interfaces/ITransferApiControllerClient.cs b/TIAM.Services/Interfaces/ITransferApiControllerClient.cs index 2104fb72..fcee6203 100644 --- a/TIAM.Services/Interfaces/ITransferApiControllerClient.cs +++ b/TIAM.Services/Interfaces/ITransferApiControllerClient.cs @@ -4,5 +4,6 @@ namespace TIAM.Services.Interfaces; public interface ITransferApiControllerClient : ITransferApiControllerCommon { - Task GetTransferDestinationsInto(List intoDestinationList, Action? callback = null); + Task GetTransferDestinationsAsync(List intoDestinationList, Action? callback = null); + Task GetPublicTransferDestinationsAsync(List intoDestinationList, Guid includeProductId, Action? callback = null); } \ No newline at end of file diff --git a/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs b/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs index 02b8158e..430e755c 100644 --- a/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs +++ b/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs @@ -27,6 +27,7 @@ public interface ITransferApiControllerCommon #region TransferDestination public Task> GetTransferDestinations(); + public Task> GetPublicTransferDestinations(Guid includeProductId); public Task GetTransferDestinationById(Guid transferDestinationId); public Task CreateTransferDestination(TransferDestination transferDestination); public Task UpdateTransferDestination(TransferDestination transferDestination); diff --git a/TIAM.Services/SignalRTags.cs b/TIAM.Services/SignalRTags.cs index 3dd95968..7d95d595 100644 --- a/TIAM.Services/SignalRTags.cs +++ b/TIAM.Services/SignalRTags.cs @@ -100,9 +100,10 @@ public class SignalRTags : AcSignalRTags public const int GetTransferDestinationById = 80; public const int GetAllTransferDestinations = 81; - public const int CreateTransferDestination = 82; - public const int UpdateTransferDestination = 83; - public const int RemoveTransferDestination = 84; //set permissions to 0 + public const int GetAllTransferDestinationsByProductId = 82; + public const int CreateTransferDestination = 83; + public const int UpdateTransferDestination = 84; + public const int RemoveTransferDestination = 85; //set permissions to 0 public const int CreateTransferDestinationToProduct = 90; public const int UpdateTransferDestinationToProduct = 91; diff --git a/TIAMSharedUI/Pages/TransferPage.razor b/TIAMSharedUI/Pages/TransferPage.razor index 06412237..5541caa3 100644 --- a/TIAMSharedUI/Pages/TransferPage.razor +++ b/TIAMSharedUI/Pages/TransferPage.razor @@ -371,7 +371,8 @@ new HeroSliderItem if (createdUserDetail != null) { createdUserDetail.UserDto.RefferalId = userDetail.UserDto.RefferalId; - var updatedNewUser = await _adminSignalRClient.PostDataAsync(SignalRTags.UpdateUserModelDtoDetail, userDetail); + + var updatedNewUser = await _adminSignalRClient.UpdateUserModelDtoDetail(userDetail); if (updatedNewUser != null) { //referral set diff --git a/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor b/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor index a9c95b7b..fe39c4ab 100644 --- a/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor +++ b/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor @@ -153,7 +153,7 @@ _isAddressTransferDestination = CheckDestinations(_productProfile.AddressId); } - AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); + AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget(); await base.OnInitializedAsync(); } diff --git a/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor b/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor index 059a5530..ea310d37 100644 --- a/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor +++ b/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor @@ -8,6 +8,7 @@ @using TIAMSharedUI.Pages.Components.EditComponents @using TIAMSharedUI.Shared @using AyCode.Services.Loggers +@using TIAM.Core.Enums @using TIAMWebApp.Shared.Application.Interfaces; @using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @using TIAMWebApp.Shared.Application.Models.PageModels @@ -38,7 +39,7 @@

Selected Hotel:

- - +
- Reload + Reload
@@ -66,60 +67,58 @@ @code { private LoggerClient _logger; - private TransferWizardModel Data = new(); - private List Hotels = new List(); + private TransferWizardModel _data = new(); + private List _hotels = []; private Product selectedHotel { get; set; } public Product SelectedHotel { - get - { - return selectedHotel; - } + get => selectedHotel; set { + if (selectedHotel == value) return; + selectedHotel = value; StateHasChanged(); } } - public List TransferIgnorList = new List - { - nameof(TransferWizardModel.Id), - nameof(TransferWizardModel.UserId), - nameof(TransferWizardModel.ProductId), - nameof(TransferWizardModel.FirstName), - nameof(TransferWizardModel.LastName), - nameof(TransferWizardModel.UserProductMappingId), - nameof(TransferWizardModel.UserProductToCarId), - nameof(TransferWizardModel.ReferralId), - nameof(TransferWizardModel.Price) - }; - private bool isReloadVisible = false; - private bool SelectedHotelInitialized = false; + public List TransferIgnorList = + [ + nameof(TransferWizardModel.Id), + nameof(TransferWizardModel.UserId), + nameof(TransferWizardModel.ProductId), + nameof(TransferWizardModel.FirstName), + nameof(TransferWizardModel.LastName), + nameof(TransferWizardModel.UserProductMappingId), + nameof(TransferWizardModel.UserProductToCarId), + nameof(TransferWizardModel.ReferralId), + nameof(TransferWizardModel.Price) + ]; + + private bool _isReloadVisible = false; + private bool _selectedHotelInitialized = false; protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); + if (_sessionService.User != null) { - - if (_sessionService.User.UserModelDto.Products.Count() > 0) + if (_sessionService.User.UserModelDto.Products.Any()) { - if (_sessionService.User.UserModelDto.Products.Any(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel)) + if (_sessionService.User.UserModelDto.Products.Any(x => x.ProductType == ProductType.Hotel)) { - Hotels = _sessionService.GetHotels(); - if (!SelectedHotelInitialized) + _hotels = _sessionService.GetHotels(); + if (!_selectedHotelInitialized) { - SelectedHotel = Hotels[0]; - SelectedHotelInitialized = true; + SelectedHotel = _hotels[0]; + _selectedHotelInitialized = true; } } } } - Data = new TransferWizardModel(); base.OnInitialized(); - } public async Task SubmitForm(object result) @@ -171,13 +170,13 @@ var saveResult = await _adminSignalRClient.PostDataAsync(SignalRTags.AddTransfer, valami); _logger.Info($"Submitted form: {result.GetType().FullName}, {valami.ToAddress}, {valami.FromAddress}, {valami.ProductId}"); - isReloadVisible = true; + _isReloadVisible = true; } public void Reload() { - Data = new TransferWizardModel(); - isReloadVisible = false; + _data = new TransferWizardModel(); + _isReloadVisible = false; StateHasChanged(); } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor index 7927f52e..2aa0916e 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor @@ -158,7 +158,7 @@ { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); + AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget(); //DataSource = new List
(); } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor index 0165a30e..ca534687 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor @@ -160,7 +160,7 @@ { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); + AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget(); } private bool CheckDestinations(Guid addressId) diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor index 93135d5c..4fe9d82b 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor @@ -124,7 +124,7 @@ { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); + AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget(); AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget(); base.OnInitialized(); diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor index f7d0f55d..4bcc3094 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor @@ -109,7 +109,7 @@ { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); + AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget(); AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget(); await base.OnInitializedAsync(); diff --git a/TIAMSharedUI/Shared/ComboboxItemSelector.razor b/TIAMSharedUI/Shared/ComboboxItemSelector.razor index 90e9d01c..538b5bf8 100644 --- a/TIAMSharedUI/Shared/ComboboxItemSelector.razor +++ b/TIAMSharedUI/Shared/ComboboxItemSelector.razor @@ -110,37 +110,19 @@ // StateHasChanged(); } - protected override async Task OnInitializedAsync() + protected override Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); - Guid? productAddressId = Guid.Empty; - if (!ProductId.IsNullOrEmpty()) + if (ProductId.IsNullOrEmpty()) _adminSignalRClient.GetTransferDestinationsAsync(_destinations, GetTransferDestinationsCallback()).Forget(); + else _adminSignalRClient.GetPublicTransferDestinationsAsync(_destinations, ProductId.Value, GetTransferDestinationsCallback()).Forget(); + + return Task.CompletedTask; + + Action GetTransferDestinationsCallback() { - var currentProduct = await _adminSignalRClient.GetByIdAsync(SignalRTags.GetProductById, ProductId); - if (currentProduct != null) - { - if (!currentProduct.Profile.AddressId.IsNullOrEmpty()) - { - productAddressId = currentProduct.Profile.AddressId; - } - } + return () => { SelectedDestination = ProductId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.ProductId == ProductId); }; } - - _adminSignalRClient.GetTransferDestinationsInto(_destinations, () => - { - SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId); - }).Forget(); - - // _adminSignalRClient.GetAllIntoAsync(_destinations, SignalRTags.GetAllTransferDestinations, null, resultData => - // { - // if (resultData == null) SelectedDestination = null; - // else SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId); - - // return Task.CompletedTask; - // }).Forget(); - - //await _adminSignalRClient.GetAllIntoAsync(Data, SignalRTags.GetAllTransferDestinations); } // RenderFragment GetSelectedItemDescription() diff --git a/TIAMSharedUI/Shared/Components/BaseComponents/BasePageComponent.cs b/TIAMSharedUI/Shared/Components/BaseComponents/BasePageComponent.cs index d1d42989..f6954e1f 100644 --- a/TIAMSharedUI/Shared/Components/BaseComponents/BasePageComponent.cs +++ b/TIAMSharedUI/Shared/Components/BaseComponents/BasePageComponent.cs @@ -47,9 +47,16 @@ namespace TIAMSharedUI.Shared.Components.BaseComponents protected override void OnInitialized() { + Initialize(); base.OnInitialized(); + } + + private void Initialize() + { _logger = new LoggerClient(_logWriters.ToArray()); + var currentUrl = _navManager.ToBaseRelativePath(_navManager.Uri); + _pageState.AddPageToHistory(currentUrl); _logger.Debug(_pageState.GetGoBackPage()); } diff --git a/TIAMSharedUI/Shared/Components/BaseComponents/UserBasePageComponent.cs b/TIAMSharedUI/Shared/Components/BaseComponents/UserBasePageComponent.cs index b3a52997..027f9d34 100644 --- a/TIAMSharedUI/Shared/Components/BaseComponents/UserBasePageComponent.cs +++ b/TIAMSharedUI/Shared/Components/BaseComponents/UserBasePageComponent.cs @@ -17,20 +17,20 @@ namespace TIAMSharedUI.Shared.Components.BaseComponents { [Authorize] public class UserBasePageComponent : BasePageComponent - { - + { private LoggerClient _logger = null!; + public UserBasePageComponent() { - + } protected override void OnInitialized() { - base.OnInitialized(); _logger = new LoggerClient(_logWriters.ToArray()); - + + base.OnInitialized(); } } } diff --git a/TIAMSharedUI/Shared/NavHelperComponent.razor b/TIAMSharedUI/Shared/NavHelperComponent.razor index 431246c3..357cf255 100644 --- a/TIAMSharedUI/Shared/NavHelperComponent.razor +++ b/TIAMSharedUI/Shared/NavHelperComponent.razor @@ -24,17 +24,17 @@ protected override void OnInitialized() { - if(pageHistoryState.CanGoBack()) + if (pageHistoryState.CanGoBack()) { isBackVisible = true; - } + } } private void GoBack() { @if (pageHistoryState.CanGoBack()) { - NavManager.NavigateTo(pageHistoryState.GetGoBackPage()); - } + NavManager.NavigateTo(pageHistoryState.GetGoBackPage()!); + } } } diff --git a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs index a04aa8f8..65ed3eb8 100644 --- a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs +++ b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs @@ -82,6 +82,13 @@ namespace TIAMWebApp.Server.Controllers return await _adminDal.GetTransferDestinationsAsync(); } + [NonAction] + [SignalR(SignalRTags.GetAllTransferDestinationsByProductId)] + public async Task> GetPublicTransferDestinations(Guid includeProductId) + { + return await _adminDal.GetPublicTransferDestinationsAsync(includeProductId); + } + //[Authorize] //[HttpGet] //[Route(APIUrls.GetTransferDriversByTransferIdRouteName)] diff --git a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs index 8e423118..1a14b69c 100644 --- a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs +++ b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs @@ -127,9 +127,15 @@ namespace TIAMWebApp.Shared.Application.Services public async Task> GetTransferDestinations() => await GetAllAsync>(SignalRTags.GetAllTransferDestinations) ?? []; - public Task GetTransferDestinationsInto(List intoDestinationList, Action? callback = null) + + public Task GetTransferDestinationsAsync(List intoDestinationList, Action? callback = null) => GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinations, null, callback); + public async Task> GetPublicTransferDestinations(Guid includeProductId) + => await GetAllAsync>(SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId]) ?? []; + + public Task GetPublicTransferDestinationsAsync(List intoDestinationList, Guid includeProductId, Action? callback = null) + => GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId], callback); public async Task GetTransferDestinationById(Guid transferDestinationId) { diff --git a/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs b/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs index fa0bec25..d5014e7f 100644 --- a/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs +++ b/TIAMWebApp/Shared/Services/SessionServiceClientBase.cs @@ -1,4 +1,5 @@ using System.Net; +using TIAM.Core.Enums; using TIAM.Entities.Products; using TIAM.Models; using TIAMWebApp.Shared.Application.Interfaces; @@ -23,7 +24,7 @@ public abstract class SessionServiceClientBase : ISessionService public virtual List GetHotels() { - return User != null ? User.UserModelDto.Products.Where(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel).ToList() : []; + return User != null ? User.UserModelDto.Products.Where(x => x.ProductType == ProductType.Hotel).ToList() : []; } public virtual void ClearAll() diff --git a/TIAMWebApp/Shared/Utility/PageHistoryState.cs b/TIAMWebApp/Shared/Utility/PageHistoryState.cs index 6a8be99d..fff7834d 100644 --- a/TIAMWebApp/Shared/Utility/PageHistoryState.cs +++ b/TIAMWebApp/Shared/Utility/PageHistoryState.cs @@ -8,32 +8,24 @@ namespace TIAMWebApp.Shared.Application.Utility { public class PageHistoryState { - private List previousPages; + private readonly List _previousPages = []; public PageHistoryState() + { } + + public void AddPageToHistory(string pageUrl) { - previousPages = new List(); - } - public void AddPageToHistory(string pageName) - { - previousPages.Add(pageName); + _previousPages.Add(pageUrl); } public string GetGoBackPage() { - if (previousPages.Count > 1) - { - // You add a page on initialization, so you need to return the 2nd from the last - return previousPages.ElementAt(previousPages.Count - 2); - } - - // Can't go back because you didn't navigate enough - return previousPages.FirstOrDefault(); + return _previousPages.Count > 1 ? _previousPages[^2] : _previousPages.FirstOrDefault() ?? string.Empty; } public bool CanGoBack() { - return previousPages.Count > 1; + return _previousPages.Count > 1; } } } From 17529c008ffe25ca63ab23f002c515a1ce3ac19a Mon Sep 17 00:00:00 2001 From: Loretta Date: Sat, 31 Aug 2024 09:27:15 +0200 Subject: [PATCH 5/6] improvements, fixes --- TIAMSharedUI/Pages/TransferPage.razor | 151 +++++------ .../TransferCardComponent.razor | 40 ++- .../User/Drivers/DriverManageTransfers.razor | 13 - .../User/Hotels/CreateAndManageTransfer.razor | 30 ++- .../Pages/User/Hotels/HotelComponent.razor | 16 +- .../Pages/User/Hotels/HotelComponent.razor.cs | 235 +++++++----------- .../User/SysAdmins/ManageTransfers.razor | 68 +++-- .../Pages/User/UserManageTransfers.razor | 13 - .../ClientSide/UI/TransferStatusModel.cs | 23 +- 9 files changed, 263 insertions(+), 326 deletions(-) diff --git a/TIAMSharedUI/Pages/TransferPage.razor b/TIAMSharedUI/Pages/TransferPage.razor index 5541caa3..c652b4a5 100644 --- a/TIAMSharedUI/Pages/TransferPage.razor +++ b/TIAMSharedUI/Pages/TransferPage.razor @@ -11,22 +11,24 @@ @using TIAMWebApp.Shared.Application.Models.ClientSide.UI @using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @using AyCode.Services.Loggers +@using TIAMSharedUI.Pages.User.Hotels @using TIAMWebApp.Shared.Application.Models.PageModels @using TIAMWebApp.Shared.Application.Services +@using TIAMWebApp.Shared.Application.Utility @inherits BasePageComponent @inject NavigationManager navManager -@inject IAcLogWriterClientBase BrowserConsoleLogWriter +@inject IEnumerable LogWriters @inject IWizardProcessor WizardProcessor @inject IUserDataService UserDataService @inject AdminSignalRClient _adminSignalRClient Transfer - +
- + @{ - if (displayHelp) + if (_displayHelp) {
@@ -164,18 +166,18 @@ - - + + - + - + @@ -187,8 +189,8 @@ SubtitleResourceString="TransferSubtitle"> *@ -
- +
+
@@ -234,83 +236,88 @@ @code { - public TransferWizardModel myModel = new TransferWizardModel(); + private LoggerClient _logger; - public List sliders = new List - { - new HeroSliderItem - { - Title = "Welcome to TIAM", - ImageUrl = "_content/TIAMSharedUI/images/f1_1.png" - }, - new HeroSliderItem - { - Title = "Welcome to TIAM", - ImageUrl = "_content/TIAMSharedUI/images/f1_2.png" - }, -new HeroSliderItem - { - Title = "Welcome to TIAM", - ImageUrl = "_content/TIAMSharedUI/images/f1_3.png" - }, - }; + private readonly TransferWizardModel _myModel = new TransferWizardModel(); - public List TransferIgnorList1 = new List - { - "Id", - "Destination", - "UserId", - "ProductId", - "PaymentId", - "TripDate", - "FirstName", - "LastName", - "UserProductMappingId", - "UserProductToCarId", - "ReferralId", - "Price" - }; + private readonly List _sliders = + [ + new HeroSliderItem + { + Title = "Welcome to TIAM", + ImageUrl = "_content/TIAMSharedUI/images/f1_1.png" + }, - public List TransferIgnorList2 = new List - { - "Id", - "PickupAddress", - "UserId", - "ProductId", - "PaymentId", - "TripDate", - "FirstName", - "LastName", - "UserProductMappingId", - "UserProductToCarId", - "ReferralId", - "Price" - }; + new HeroSliderItem + { + Title = "Welcome to TIAM", + ImageUrl = "_content/TIAMSharedUI/images/f1_2.png" + }, + + new HeroSliderItem + { + Title = "Welcome to TIAM", + ImageUrl = "_content/TIAMSharedUI/images/f1_3.png" + } + ]; + + private readonly List _transferIgnorList1 = + [ + "Id", + "Destination", + "UserId", + "ProductId", + "PaymentId", + "TripDate", + "FirstName", + "LastName", + "UserProductMappingId", + "UserProductToCarId", + "ReferralId", + "Price" + ]; + + private readonly List _transferIgnorList2 = + [ + "Id", + "PickupAddress", + "UserId", + "ProductId", + "PaymentId", + "TripDate", + "FirstName", + "LastName", + "UserProductMappingId", + "UserProductToCarId", + "ReferralId", + "Price" + ]; /*protected override void OnAfterRender(bool isFirst) { message = " Target destination is " + slider.SliderElementId.ToString(); }*/ - private bool toAirport = true; + private bool _toAirport = true; - private bool displayHelp = false; + private bool _displayHelp = false; public void ToAirport() { - toAirport = true; - myModel.Destination = "Budapest, 1185"; + _toAirport = true; + _myModel.Destination = "Budapest, 1185"; } public void FromAirport() { - toAirport = false; - myModel.PickupAddress = "Budapest, 1185"; + _toAirport = false; + _myModel.PickupAddress = "Budapest, 1185"; } - public async Task SubmitForm(object Result) + public async Task SubmitForm(object result) { - TransferWizardModel resModel = (TransferWizardModel)Result; + var resModel = (TransferWizardModel)result; + //let's check if user exists with this email var user = await UserDataService.GetUserByEmailAsync(resModel.EmailAddress!); if (user != null && user.Id != Guid.Empty) @@ -382,6 +389,7 @@ new HeroSliderItem //something wrong } } + resModel.ReferralId = userDetail.UserDto.RefferalId; } @@ -394,20 +402,23 @@ new HeroSliderItem } } } - var transfer = await WizardProcessor.ProcessWizardAsync(Result.GetType(), Result); - BrowserConsoleLogWriter.Info($"Submitted nested form: {Result.GetType().FullName}"); + + var transfer = await WizardProcessor.ProcessWizardAsync(result.GetType(), result); + _logger.Info($"Submitted nested form: {result.GetType().FullName}"); navManager.NavigateTo($"/transfer2/{resModel.Id}"); } protected override Task OnInitializedAsync() { + _logger = new LoggerClient(LogWriters.ToArray()); + ToAirport(); return base.OnInitializedAsync(); } private void ShowHelp_Click() { - displayHelp = !displayHelp; + _displayHelp = !_displayHelp; } } diff --git a/TIAMSharedUI/Pages/User/CardComponents/TransferCardComponent.razor b/TIAMSharedUI/Pages/User/CardComponents/TransferCardComponent.razor index b224693e..ea7cc8cc 100644 --- a/TIAMSharedUI/Pages/User/CardComponents/TransferCardComponent.razor +++ b/TIAMSharedUI/Pages/User/CardComponents/TransferCardComponent.razor @@ -109,10 +109,10 @@ @RenderDetailsItem("fa-solid fa-hashtag", "Comment", Context.Comment)
- @RenderDetailsItem("fa-solid fa-list-check", "Status", AllStatuses.FirstOrDefault(x => x.StatusValue == (byte)Context.TransferStatusType).StatusName) + @RenderDetailsItem("fa-solid fa-list-check", "Status", TransferStatusModel.AllStatuses.FirstOrDefault(x => x.StatusValue == Context.TransferStatusType)!.StatusName)
- Statuses = new[] - { - new TransferStatusModel(Convert.ToByte(TransferStatusType.DriverConfirmed), "Driver confirmed"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.DriverEnRoute), "Driver enroute"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.PassengerPickup), "Passenger in car"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.Finished), "Finished"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.UserCanceled), "User cancelled"), - }; + private static readonly IEnumerable DriverStatuses = TransferStatusModel.AllStatuses.Where(x => x.StatusValue is TransferStatusType.DriverConfirmed or + TransferStatusType.DriverEnRoute or TransferStatusType.PassengerPickup or TransferStatusType.Finished or TransferStatusType.UserCanceled); + + // private static readonly IEnumerable Statuses = new[] + // { + // new TransferStatusModel(TransferStatusType.DriverConfirmed, "Driver confirmed"), + // new TransferStatusModel(TransferStatusType.DriverEnRoute, "Driver enroute"), + // new TransferStatusModel(TransferStatusType.PassengerPickup, "Passenger in car"), + // new TransferStatusModel(TransferStatusType.Finished, "Finished"), + // new TransferStatusModel(TransferStatusType.UserCanceled, "User cancelled"), + // }; - private static readonly List AllStatuses = new() - { - new TransferStatusModel(Convert.ToByte(TransferStatusType.OrderSubmitted), "Order submitted"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.OrderConfirmed), "Order confirmed"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.AssignedToDriver), "Assigned to driver"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.DriverConfirmed), "Driver confirmed"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.DriverEnRoute), "Driver enroute"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.PassengerPickup), "Passenger in car"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.Finished), "Finished"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.UserCanceled), "User cancelled"), - new TransferStatusModel(Convert.ToByte(TransferStatusType.AdminDenied), "Admin cancelled") - }; private TransferStatusModel _currentStatusType; public TransferStatusModel CurrentStatusType @@ -241,7 +232,7 @@ var result = await AdminSignalRClient.PostDataAsync(SignalRTags.UpdateTransfer, Context); if (result != null) { - if (AllStatuses.FirstOrDefault(x => x.StatusValue == (byte)result.TransferStatusType) == CurrentStatusType) + if (TransferStatusModel.AllStatuses.FirstOrDefault(x => x.StatusValue == result.TransferStatusType) == CurrentStatusType) { msg = $"Stataus saved"; StateHasChanged(); @@ -278,12 +269,13 @@ { _logger = new LoggerClient(LogWriters.ToArray()); sysAdmins = await AdminSignalRClient.GetByIdAsync>(SignalRTags.GetAllUserModelDtoDetails, TiamConstClient.SysAdmins[0]); + await base.OnInitializedAsync(); } protected override Task OnParametersSetAsync() { - CurrentStatusType = AllStatuses.FirstOrDefault(x => x.StatusValue == (byte)Context.TransferStatusType); + CurrentStatusType = TransferStatusModel.AllStatuses.FirstOrDefault(x => x.StatusValue == Context.TransferStatusType)!; return base.OnParametersSetAsync(); } diff --git a/TIAMSharedUI/Pages/User/Drivers/DriverManageTransfers.razor b/TIAMSharedUI/Pages/User/Drivers/DriverManageTransfers.razor index b51b7cd3..54121d0e 100644 --- a/TIAMSharedUI/Pages/User/Drivers/DriverManageTransfers.razor +++ b/TIAMSharedUI/Pages/User/Drivers/DriverManageTransfers.razor @@ -227,19 +227,6 @@ "ContextId", ]; - private static readonly List Statuses = - [ - new(Convert.ToByte(TransferStatusType.OrderSubmitted), "Order submitted"), - new(Convert.ToByte(TransferStatusType.OrderConfirmed), "Order confirmed"), - new(Convert.ToByte(TransferStatusType.AssignedToDriver), "Assigned to driver"), - new(Convert.ToByte(TransferStatusType.DriverConfirmed), "Driver confirmed"), - new(Convert.ToByte(TransferStatusType.DriverEnRoute), "Driver enroute"), - new(Convert.ToByte(TransferStatusType.PassengerPickup), "Passenger in car"), - new(Convert.ToByte(TransferStatusType.Finished), "Finished"), - new(Convert.ToByte(TransferStatusType.UserCanceled), "User cancelled"), - new(Convert.ToByte(TransferStatusType.AdminDenied), "Admin cancelled") - ]; - void Grid_CustomizeElement(GridCustomizeElementEventArgs e) { try diff --git a/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor b/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor index ea310d37..e9b0e3ec 100644 --- a/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor +++ b/TIAMSharedUI/Pages/User/Hotels/CreateAndManageTransfer.razor @@ -69,15 +69,16 @@ private LoggerClient _logger; private TransferWizardModel _data = new(); private List _hotels = []; - private Product selectedHotel { get; set; } - public Product SelectedHotel + + private static Product? _selectedHotel; + public Product? SelectedHotel { - get => selectedHotel; + get => _selectedHotel; set { - if (selectedHotel == value) return; + if (_selectedHotel == value) return; - selectedHotel = value; + _selectedHotel = value; StateHasChanged(); } } @@ -96,7 +97,6 @@ ]; private bool _isReloadVisible = false; - private bool _selectedHotelInitialized = false; protected override void OnInitialized() { @@ -109,11 +109,7 @@ if (_sessionService.User.UserModelDto.Products.Any(x => x.ProductType == ProductType.Hotel)) { _hotels = _sessionService.GetHotels(); - if (!_selectedHotelInitialized) - { - SelectedHotel = _hotels[0]; - _selectedHotelInitialized = true; - } + SelectedHotel = _hotels.FirstOrDefault(x => x.Id == _selectedHotel?.Id) ?? _hotels[0]; } } } @@ -123,9 +119,16 @@ public async Task SubmitForm(object result) { + if (_selectedHotel == null) + { + _logger.Error($"_selectedHotel == null"); + return; + } + var valami = ((TransferWizardModel)result).CopyToTransfer(); valami.Id = Guid.NewGuid(); - valami.ProductId = SelectedHotel.Id; + valami.ProductId = _selectedHotel.Id; + var user = await UserDataService.GetUserByEmailAsync(valami.ContactEmail); if (user != null && user.Id != Guid.Empty) { @@ -151,7 +154,7 @@ registration.PhoneNumber = valami.ContactPhone; registration.Password = password; //get list with one member! - var productOwner = await _adminSignalRClient.GetByIdAsync>(SignalRTags.GetCompaniesById, SelectedHotel.ServiceProviderId); + var productOwner = await _adminSignalRClient.GetByIdAsync>(SignalRTags.GetCompaniesById, _selectedHotel.ServiceProviderId); registration.ReferralId = productOwner[0].AffiliateId; @@ -165,6 +168,7 @@ } _logger.Info("New user created added"); } + //valami.ProductId = SessionService.User.UserId; //TODO ProductID! // await WizardProcessor.ProcessWizardAsync(result.GetType(), result); diff --git a/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor b/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor index dc2a19ec..3f19881b 100644 --- a/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor +++ b/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor @@ -44,9 +44,9 @@
-

Hotel name: @hotelName

-

Address: @hotelAddress

-

Contact name: @hotelContactName

+

Hotel name: @_hotelName

+

Address: @_hotelAddress

+

Contact name: @_hotelContactName

@@ -79,7 +79,7 @@
-