errörandling updates

This commit is contained in:
Adam 2024-05-18 22:57:12 +02:00
parent 439e76e9b0
commit 89c5f76797
12 changed files with 319 additions and 157 deletions

View File

@ -49,7 +49,7 @@ namespace TIAMMobileApp
builder.Services.AddScoped<IWeatherForecastService, WeatherForecastService>(); builder.Services.AddScoped<IWeatherForecastService, WeatherForecastService>();
builder.Services.AddScoped<ITransferDataService, TransferDataService>(); builder.Services.AddScoped<ITransferDataService, TransferDataService>();
//builder.Services.AddScoped<IAcLogWriterBase, BrowserConsoleLogWriter>(); //builder.Services.AddScoped<IAcLogWriterBase, BrowserConsoleLogWriter>();
builder.Services.AddSingleton<IAcLogWriterClientBase, BrowserConsoleLogWriter>(); //builder.Services.AddSingleton<IAcLogWriterClientBase, BrowserConsoleLogWriter>();
builder.Services.AddSingleton<IAcLogWriterClientBase, HttpClientLogItemWriter>(); builder.Services.AddSingleton<IAcLogWriterClientBase, HttpClientLogItemWriter>();
builder.Services.AddScoped<IPopulationStructureDataProvider, PopulationStructureDataProvider>(); builder.Services.AddScoped<IPopulationStructureDataProvider, PopulationStructureDataProvider>();
builder.Services.AddScoped<ISupplierService, SupplierService>(); builder.Services.AddScoped<ISupplierService, SupplierService>();

View File

@ -1,84 +1,90 @@
using System.Net.Http.Json; using System.Net.Http.Json;
using System.Text; using System.Text;
using AyCode.Interfaces.StorageHandlers; using AyCode.Interfaces.StorageHandlers;
using AyCode.Services.Loggers;
using Newtonsoft.Json; using Newtonsoft.Json;
using TIAM.Core.Loggers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models;
using TIAMWebApp.Shared.Application.Models.ClientSide; using TIAMWebApp.Shared.Application.Models.ClientSide;
using TIAMWebApp.Shared.Application.Models.PageModels; using TIAMWebApp.Shared.Application.Models.PageModels;
using TIAMWebApp.Shared.Application.Services;
using TIAMWebApp.Shared.Application.Utility; using TIAMWebApp.Shared.Application.Utility;
namespace TIAMMobileApp.Services namespace TIAMMobileApp.Services
{ {
public class UserDataServiceMobile : IUserDataService public class UserDataServiceMobile : IUserDataService
{ {
private readonly HttpClient _http; private readonly HttpClient http;
private readonly ISecureStorageHandler _secureStorageHandler; private readonly ISecureStorageHandler secureStorageHandler;
private readonly IServiceProviderDataService _serviceProviderDataService; private readonly IServiceProviderDataService serviceProviderDataService;
private readonly ILogger _logger;
public Dictionary<int, string> userRoleTypes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public Dictionary<int, string> userRoleTypes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public UserDataServiceMobile(HttpClient http, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService) public UserDataServiceMobile(HttpClient http, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
{ {
this._http = http; this.http = http;
this._secureStorageHandler = secureStorageHandler; this.secureStorageHandler = secureStorageHandler;
_serviceProviderDataService = serviceProviderDataService;
//this._browserConsoleLogWriter = new BrowserConsoleLogWriter(jsRuntime);
this.serviceProviderDataService = serviceProviderDataService;
_logger = new LoggerClient<UserDataServiceMobile>(logWriters.ToArray());
//_logger = new TIAM.Core.Loggers.Logger<UserDataServiceWeb>(AppType.Web, LogLevel.Info, logWriters.ToArray());
//_logger = new TIAM.Core.Loggers.Logger<UserDataServiceWeb>(AppType.Web, LogLevel.Info, logWriter);
} }
public List<RoleType> roleTypes = new List<RoleType>
{
new RoleType { Id = 1, RoleName = "Login" },
new RoleType { Id = 2, RoleName = "Member" },
new RoleType { Id = 4, RoleName = "Vip" },
new RoleType { Id = 8, RoleName = "Uvip" },
new RoleType { Id = 16, RoleName = "Volunteer" },
new RoleType { Id = 32, RoleName = "Guide" },
new RoleType { Id = 64, RoleName = "Protector" },
new RoleType { Id = 128, RoleName = "Admin" },
new RoleType { Id = 256, RoleName = "SuperAdmin" },
new RoleType { Id = 512, RoleName = "God" }
};
public async Task<UserSessionModel> IsLoggedInAsync(Guid id) public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
{ {
//api call to get user
var userModelDto = await GetUserDetailByIdAsync(id); var userModelDto = await GetUserDetailByIdAsync(id);
if (userModelDto != null) if (userModelDto != null)
{ {
//get user's properties
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id);
var hasProperties = await _serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id); if (hasProperties != null)
var user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto, hasProperties, 1); _logger.Info($"{hasProperties.Count} properties found");
return user; //create user session model
} var user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto, hasProperties, 1);
else return user;
{ }
else
return null; {
}
return null;
}
} }
public async Task<string> TestUserApi(int param) public async Task<string> TestUserApi(int Param)
{ {
var url = APIUrls.UserTest; var url = $"{Setting.ApiBaseUrl}/{APIUrls.UserTest}";
var response = await _http.PostAsJsonAsync(url, param);
var response = await http.PostAsJsonAsync(url, Param);
var result = await response.Content.ReadAsStringAsync(); var result = await response.Content.ReadAsStringAsync();
return result; return result;
} }
public async Task<string> AuthenticateUser(LoginModel loginModel) public async Task<string> AuthenticateUser(LoginModel loginModel)
{ {
string result = string.Empty;
var url = $"{Setting.ApiBaseUrl}/{APIUrls.AuthenticateUser}";
var response = await http.PostAsJsonAsync(url, loginModel);
//try
var result = string.Empty; //{
var url = APIUrls.AuthenticateUser; // Logger.Detail("Login started: " + "Email: " + loginModel.Email + ", Password: " + loginModel.Password);
//}
var response = await _http.PostAsJsonAsync(url, loginModel); //catch (Exception ex)
//{
// _logger.Error(ex.Message, ex);
//}
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
@ -89,20 +95,19 @@ namespace TIAMMobileApp.Services
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
} }
//result = await response.Content.ReadAsStringAsync(); //result = await response.Content.ReadAsStringAsync();
return result; return result;
} }
public async Task<(bool isSuccess, string ErrorMessage)> CreateUser(RegistrationModel regModel) public async Task<(bool isSuccess, string ErrorMessage)> CreateUser(RegistrationModel regModel)
{ {
var isSuccess = true; bool isSuccess = true;
var result = string.Empty; string result = string.Empty;
var url = APIUrls.CreateUser; var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateUser}";
_logger.Info("CreateUser url: " + url);
var response = await _http.PostAsJsonAsync(url, regModel); var response = await http.PostAsJsonAsync(url, regModel);
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
/*if (response.IsSuccessStatusCode) /*if (response.IsSuccessStatusCode)
{ {
@ -122,18 +127,19 @@ namespace TIAMMobileApp.Services
public async Task<(bool isSuccess, UserModelDto? user)> CreateGuestUser(RegistrationModel regModel) public async Task<(bool isSuccess, UserModelDto? user)> CreateGuestUser(RegistrationModel regModel)
{ {
var isSuccess = false; bool isSuccess = false;
var result = string.Empty; string result = string.Empty;
UserModelDto? user; UserModelDto? user = new UserModelDto();
var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateGuestUser}"; var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateGuestUser}";
_logger.Info("CreateGuestUser url: " + url);
var response = await _http.PostAsJsonAsync(url, regModel); var response = await http.PostAsJsonAsync(url, regModel);
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
isSuccess = true; isSuccess = true;
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
_logger.Info("CreateGuestUser result: " + result);
user = JsonConvert.DeserializeObject<UserModelDto>(result); user = JsonConvert.DeserializeObject<UserModelDto>(result);
} }
else else
@ -149,108 +155,127 @@ namespace TIAMMobileApp.Services
public async Task<List<UserModelDto>?> GetUsersAsync() public async Task<List<UserModelDto>?> GetUsersAsync()
{ {
return await _http.GetFromJsonAsync<List<UserModelDto>>(APIUrls.GetUsers); return await http.GetFromJsonAsync<List<UserModelDto>>(APIUrls.GetUsers);
} }
public async Task<List<UserModelDtoDetail>?> GetUsersWithDetailsAsync() public async Task<List<UserModelDtoDetail>?> GetUsersWithDetailsAsync()
{ {
return await _http.GetFromJsonAsync<List<UserModelDtoDetail>>(APIUrls.GetUsersWithDetails);
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) public async Task<UserModelDto?> GetUserByEmailAsync(string email)
{ {
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserByEmail}"; var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserByEmail}";
var response = await _http.PostAsJsonAsync(url, email);
_logger.Info("GetUserByEmailAsync url: " + url + ", " + email);
//GlobalLogger.Info("GetUserByEmailAsync url: " + url + ", " + email, "GLOBAL_LOGGER");
var response = await http.PostAsJsonAsync(url, email);
var result = await response.Content.ReadAsStringAsync(); var result = await response.Content.ReadAsStringAsync();
var user = JsonConvert.DeserializeObject<UserModelDto>(result); var user = JsonConvert.DeserializeObject<UserModelDto>(result);
return user; return user;
} }
public async Task<UserModelDto?> GetUserByIdAsync(Guid id) public async Task<UserModelDto?> GetUserByIdAsync(Guid id)
{ {
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserById}"; var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserById}";
//logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + id.ToString()); _logger.Info("GetUserByIdAsync url: " + url + ", " + id.ToString());
var response = await _http.PostAsJsonAsync(url, id); var response = await http.PostAsJsonAsync(url, id);
var result = await response.Content.ReadAsStringAsync(); var result = await response.Content.ReadAsStringAsync();
var user = JsonConvert.DeserializeObject<UserModelDto>(result); var user = JsonConvert.DeserializeObject<UserModelDto>(result);
return user; return user;
} }
public async Task<bool> RefreshToken()
{
var isTokenRefreshed = false;
using (var client = new HttpClient())
{
var url = APIUrls.RefreshToken;
var serializedStr = JsonConvert.SerializeObject(new AuthenticateRequestAndResponse
{
RefreshToken = Setting.UserBasicDetails.RefreshToken,
AccessToken = Setting.UserBasicDetails.AccessToken
});
try
{
var response = await client.PostAsync(url, new StringContent(serializedStr, Encoding.UTF8, "application/json"));
if (response.IsSuccessStatusCode)
{
var contentStr = await response.Content.ReadAsStringAsync();
var mainResponse = JsonConvert.DeserializeObject<MainResponse>(contentStr);
if (mainResponse.IsSuccess)
{
var tokenDetails = JsonConvert.DeserializeObject<AuthenticateRequestAndResponse>(mainResponse.Content.ToString());
Setting.UserBasicDetails.AccessToken = tokenDetails.AccessToken;
Setting.UserBasicDetails.RefreshToken = tokenDetails.RefreshToken;
var userDetailsStr = JsonConvert.SerializeObject(Setting.UserBasicDetails);
await _secureStorageHandler.SaveToSecureStorageAsync(nameof(Setting.UserBasicDetails), userDetailsStr);
isTokenRefreshed = true;
}
}
}
catch (Exception ex)
{
var msg = ex.Message;
}
}
return isTokenRefreshed;
}
public Task<Dictionary<int, string>> GetUserRolesAsync(UserModel userModel)
{
//TODO Finish this
//get the userModel's roles
var role = userModel.UserRoles;
foreach (var roleType in roleTypes)
{
if ((role & roleType.Id) == roleType.Id)
{
//add the role to the dictionary
userRoleTypes.Add(roleType.Id, roleType.RoleName);
}
}
return Task.FromResult(userRoleTypes);
}
public async Task<UserModelDtoDetail?> GetUserDetailByIdAsync(Guid id) public async Task<UserModelDtoDetail?> GetUserDetailByIdAsync(Guid id)
{ {
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserDetailById}"; _logger.Info("GetUserDetailByIdAsync", "GLOBAL_LOGGER");
var response = await _http.PostAsJsonAsync(url, id); var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserDetailById}";
_logger.Info("GetUserDetailByIdAsync url: " + url + ", " + id.ToString());
var response = await http.PostAsJsonAsync(url, id);
var result = await response.Content.ReadAsStringAsync(); var result = await response.Content.ReadAsStringAsync();
var user = JsonConvert.DeserializeObject<UserModelDtoDetail>(result); var user = JsonConvert.DeserializeObject<UserModelDtoDetail>(result);
return user; return user;
} }
public async Task<bool> RefreshToken()
{
_logger.Info("RefreshToken() called");
bool isTokenRefreshed = false;
var url = $"{Setting.ApiBaseUrl}/{APIUrls.RefreshToken}";
//var url = APIUrls.RefreshToken;
var serializedStr = JsonConvert.SerializeObject(new AuthenticateRequestAndResponse
{
RefreshToken = Setting.UserBasicDetails.RefreshToken,
AccessToken = Setting.UserBasicDetails.AccessToken
});
try
{
_logger.Info("Refreshtoken url: " + url);
var response = await http.PostAsync(url, new StringContent(serializedStr, Encoding.UTF8, "application/json"));
if (response.IsSuccessStatusCode)
{
string contentStr = await response.Content.ReadAsStringAsync();
var mainResponse = JsonConvert.DeserializeObject<MainResponse>(contentStr);
if (mainResponse.IsSuccess)
{
var tokenDetails = JsonConvert.DeserializeObject<AuthenticateRequestAndResponse>(mainResponse.Content.ToString());
Setting.UserBasicDetails.AccessToken = tokenDetails.AccessToken;
Setting.UserBasicDetails.RefreshToken = tokenDetails.RefreshToken;
string userDetailsStr = JsonConvert.SerializeObject(Setting.UserBasicDetails);
await secureStorageHandler.SaveToSecureStorageAsync(nameof(Setting.UserBasicDetails), userDetailsStr);
isTokenRefreshed = true;
}
}
}
catch (Exception ex)
{
string msg = ex.Message;
_logger.Error("Refreshtoken exception: " + ex.Message, ex);
}
return isTokenRefreshed;
}
//public Task<Dictionary<int, string>> GetUserRolesAsync(UserModel userModel)
//{
// //TODO Finish this
// //get the userModel's roles
// var role = userModel.UserRoles;
// foreach (var roleType in roleTypes)
// {
// if ((role & roleType.Id) == roleType.Id)
// {
// //add the role to the dictionary
// userRoleTypes.Add(roleType.Id, roleType.RoleName);
// }
// }
// return Task.FromResult(userRoleTypes);
//}
} }
} }

View File

@ -35,7 +35,7 @@
<div class="container mt-5"> <div class="container mt-5">
<div class="row align-items-center"> <div class="row align-items-center">
<div class="col-6 col-xs-12 p-5"> <div class="col-12 col-sm-6 p-5">
<h1>Book an Airport Transfer</h1> <h1>Book an Airport Transfer</h1>
<p>Welcome to Tour I Am! Book your airport transfer with us for a smooth and stress-free experience. Our professional drivers are ready to take you to and from the airport in comfort and style. We offer competitive rates and reliable service, ensuring you get to your destination on time.</p> <p>Welcome to Tour I Am! Book your airport transfer with us for a smooth and stress-free experience. Our professional drivers are ready to take you to and from the airport in comfort and style. We offer competitive rates and reliable service, ensuring you get to your destination on time.</p>
@ -49,13 +49,13 @@
</div> </div>
<div class="col-6 col-xs-12 p-5"> <div class="col-12 col-sm-6 p-5">
<img class="img-fluid" src="_content/TIAMSharedUI/images/about1.jpg" /> <img class="img-fluid" src="_content/TIAMSharedUI/images/about1.jpg" />
</div> </div>
<div class="col-6 col-xs-12 p-5"> <div class="col-12 col-sm-6 p-5">
<img class="img-fluid" src="_content/TIAMSharedUI/images/about2.jpg" /> <img class="img-fluid" src="_content/TIAMSharedUI/images/about2.jpg" />
</div> </div>
<div class="col-6 col-xs-12 p-5"> <div class="col-12 col-sm-6 p-5">
<h2>How to Book</h2> <h2>How to Book</h2>
<p>Booking your airport transfer is easy! Simply visit our <a href="/transfer">booking page</a>, enter your details, and confirm your reservation. You can also contact us at <a href="mailto:info@touriam.com">info@touriam.com</a> or call us at (123) 456-7890 for assistance.</p> <p>Booking your airport transfer is easy! Simply visit our <a href="/transfer">booking page</a>, enter your details, and confirm your reservation. You can also contact us at <a href="mailto:info@touriam.com">info@touriam.com</a> or call us at (123) 456-7890 for assistance.</p>

View File

@ -120,6 +120,13 @@
</div> </div>
</li> </li>
<li class="nav-item">
<div class="btn-nav">
<Button class="btn btn-primary btn-small navbar-btn" @onclick="ThrowSomeError">
x
</Button>
</div>
</li>
} }
} }

View File

@ -85,6 +85,11 @@ namespace TIAMSharedUI.Shared.Components
sessionService.IsAuthenticated = false; sessionService.IsAuthenticated = false;
} }
private void ThrowSomeError()
{
throw new Exception();
}
protected override void OnInitialized() protected override void OnInitialized()
{ {
base.OnInitialized(); base.OnInitialized();

View File

@ -0,0 +1,35 @@
@inherits ErrorBoundary
@if (_currentError != null)
{
<div class="error-message">
<p>An error has occurred: @_currentError.Message</p>
</div>
}
else
{
@ChildContent
}
@code {
private Exception _currentError;
[Parameter]
public EventCallback<Exception> OnError { get; set; }
protected override Task OnErrorAsync(Exception exception)
{
_currentError = exception;
if (OnError.HasDelegate)
{
return OnError.InvokeAsync(exception);
}
return base.OnErrorAsync(exception);
}
protected override void OnParametersSet()
{
_currentError = null;
}
}

View File

@ -1,5 +1,6 @@
@inherits LayoutComponentBase @inherits LayoutComponentBase
@using AyCode.Interfaces.StorageHandlers; @using AyCode.Interfaces.StorageHandlers;
@using AyCode.Services.Loggers
@using Newtonsoft.Json; @using Newtonsoft.Json;
@using TIAMSharedUI.Pages @using TIAMSharedUI.Pages
@using TIAMSharedUI.Shared.Components @using TIAMSharedUI.Shared.Components
@ -9,33 +10,40 @@
@using TIAMWebApp.Shared.Application.Models; @using TIAMWebApp.Shared.Application.Models;
@using TIAMWebApp.Shared.Application.Utility; @using TIAMWebApp.Shared.Application.Utility;
@using System.IdentityModel.Tokens.Jwt; @using System.IdentityModel.Tokens.Jwt;
@using TIAM.Core.Loggers;
@inject NavigationManager NavManager @inject NavigationManager NavManager
@inject IJSRuntime jsRuntime; @inject IJSRuntime jsRuntime
@inject ISecureStorageHandler SecureStorageHandler @inject ISecureStorageHandler SecureStorageHandler
@inject ISessionService sessionService; @inject ISessionService sessionService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
<!--div-- class="page"--> <!--div-- class="page"-->
<div> <div>
<AppLaunchComponent />
<TiamErrorBoundaryComponent OnError="HandleError">
<AppLaunchComponent />
<Navbar />
<!--div class="my-sidebar">
<NavMenu />
</div-->
<main>
<article class="content">
<CascadingValue Value=PopupMessageBox>
@Body
</CascadingValue>
</article>
</main>
@* <div class="footer">
</div> *@
<FooterComponent></FooterComponent>
<PopupMessageBox @ref="PopupMessageBox" />
</TiamErrorBoundaryComponent>
<Navbar/>
<!--div class="my-sidebar">
<NavMenu />
</div-->
<main>
<article class="content">
<CascadingValue Value=PopupMessageBox>
@Body
</CascadingValue>
</article>
</main>
@* <div class="footer">
</div> *@
<FooterComponent></FooterComponent>
<PopupMessageBox @ref="PopupMessageBox" />
</div> </div>
@ -43,4 +51,30 @@
@code { @code {
public PopupMessageBox PopupMessageBox { get; private set; } = default!; public PopupMessageBox PopupMessageBox { get; private set; } = default!;
ILogger _logger;
private void HandleError(Exception exception)
{
// Log the error to server
LogErrorToServer(exception);
// Show a notification on UI
ShowErrorNotification("An unexpected error occurred. Please try again later.");
jsRuntime.InvokeVoidAsync("console.error", $"An error occurred: {exception.Message}");
jsRuntime.InvokeVoidAsync("console.warn", $"Error details: {exception.StackTrace}");
_logger.Info($"An error occurred: {exception.Message}");
}
private void LogErrorToServer(Exception exception)
{
//_logger.Error($"An error occurred: {exception.Message}");
}
private void ShowErrorNotification(string message)
{
jsRuntime.InvokeVoidAsync("alert", message);
}
} }

View File

@ -25,7 +25,7 @@
</div> </div>
<nav class="flex-column"> <nav class="flex-column">
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="index"> <NavLink class="nav-link" href="">
Home Home
</NavLink> </NavLink>
</div> </div>

View File

@ -15,6 +15,7 @@ using ILogger = TIAM.Core.Loggers.ILogger;
using LogLevel = AyCode.Core.Loggers.LogLevel; using LogLevel = AyCode.Core.Loggers.LogLevel;
using AyCode.Core.Loggers; using AyCode.Core.Loggers;
using AyCode.Services.Loggers; using AyCode.Services.Loggers;
using TIAMWebApp.Shared.Application.Services;
namespace TIAMWebApp.Client.Services namespace TIAMWebApp.Client.Services
@ -23,7 +24,6 @@ namespace TIAMWebApp.Client.Services
{ {
private readonly HttpClient http; private readonly HttpClient http;
private readonly ISecureStorageHandler secureStorageHandler; private readonly ISecureStorageHandler secureStorageHandler;
private readonly IJSRuntime jsRuntime;
//private readonly BrowserConsoleLogWriter _browserConsoleLogWriter; //private readonly BrowserConsoleLogWriter _browserConsoleLogWriter;
private readonly IServiceProviderDataService serviceProviderDataService; private readonly IServiceProviderDataService serviceProviderDataService;
private readonly ILogger _logger; private readonly ILogger _logger;
@ -31,16 +31,16 @@ namespace TIAMWebApp.Client.Services
public Dictionary<int, string> userRoleTypes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public Dictionary<int, string> userRoleTypes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public UserDataServiceWeb(HttpClient http, ISecureStorageHandler secureStorageHandler, IJSRuntime jSRuntime, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters) public UserDataServiceWeb(HttpClient http, ISecureStorageHandler secureStorageHandler, IServiceProviderDataService serviceProviderDataService, IEnumerable<IAcLogWriterClientBase> logWriters)
//public UserDataServiceWeb(HttpClient http, ISecureStorageHandler secureStorageHandler, IJSRuntime jSRuntime, IServiceProviderDataService serviceProviderDataService, HttpClientLogItemWriter logWriter) //public UserDataServiceWeb(HttpClient http, ISecureStorageHandler secureStorageHandler, IJSRuntime jSRuntime, IServiceProviderDataService serviceProviderDataService, HttpClientLogItemWriter logWriter)
{ {
this.http = http; this.http = http;
this.secureStorageHandler = secureStorageHandler; this.secureStorageHandler = secureStorageHandler;
this.jsRuntime = jSRuntime;
//this._browserConsoleLogWriter = new BrowserConsoleLogWriter(jsRuntime); //this._browserConsoleLogWriter = new BrowserConsoleLogWriter(jsRuntime);
this.serviceProviderDataService = serviceProviderDataService; this.serviceProviderDataService = serviceProviderDataService;
_logger = new LoggerClient<UserDataServiceWeb>(logWriters.ToArray());
_logger = new TIAM.Core.Loggers.Logger<UserDataServiceWeb>(AppType.Web, LogLevel.Info, logWriters.ToArray()); //_logger = new TIAM.Core.Loggers.Logger<UserDataServiceWeb>(AppType.Web, LogLevel.Info, logWriters.ToArray());
//_logger = new TIAM.Core.Loggers.Logger<UserDataServiceWeb>(AppType.Web, LogLevel.Info, logWriter); //_logger = new TIAM.Core.Loggers.Logger<UserDataServiceWeb>(AppType.Web, LogLevel.Info, logWriter);
} }

View File

@ -0,0 +1,51 @@
using AyCode.Core.Consts;
using AyCode.Core.Loggers;
using AyCode.Core.Server.Loggers;
using AyCode.Entities;
using AyCode.Entities.Server.LogItems;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using TIAM.Database.DataLayers.Admins;
using TIAM.Database.DataLayers.Users;
using TIAM.Entities.Emails;
using TIAM.Entities.Transfers;
using TIAM.Services.Server;
using TIAM.Services.Server.Logins;
using TIAMWebApp.Server.Services;
using TIAMWebApp.Shared.Application.Models;
namespace TIAMWebApp.Server.Controllers
{
[Authorize]
[ApiController]
[EnableCors("_myAllowSpecificOrigins")]
[Route("api/v1/[controller]")]
public class PaymentAPIController : ControllerBase
{
private LoginService _loginService;
private AdminDal _adminDal;
private readonly TIAM.Core.Loggers.ILogger _logger;
private readonly IMessageSenderService _messageSenderService;
public PaymentAPIController(LoginService loginService, AdminDal adminDal, IMessageSenderService messageSenderService, IEnumerable<IAcLogWriterBase> logWriters)
{
_loginService = loginService;
_adminDal = adminDal;
_messageSenderService = messageSenderService;
_logger = new TIAM.Core.Loggers.Logger<PaymentAPIController>(logWriters.ToArray());
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.CreatePaymentRouteName)]
public async Task CreatePayment(Transfer? paymentItem)
{
}
}
}

View File

@ -17,6 +17,7 @@ namespace TIAMWebApp.Shared.Application.Models
public const string UserPermissionAPI = BaseUrlWithSlashAndVersion + "UserPermissionAPI/"; public const string UserPermissionAPI = BaseUrlWithSlashAndVersion + "UserPermissionAPI/";
public const string FileAPI = BaseUrlWithSlashAndVersion + "FileAPI/"; public const string FileAPI = BaseUrlWithSlashAndVersion + "FileAPI/";
public const string MessageAPI = BaseUrlWithSlashAndVersion + "MessageAPI/"; public const string MessageAPI = BaseUrlWithSlashAndVersion + "MessageAPI/";
public const string PaymentAPI = BaseUrlWithSlashAndVersion + "PaymentAPI/";
public const string LoggerRouteName = "Logger"; public const string LoggerRouteName = "Logger";
public const string Logger = LoggerApi + LoggerRouteName; public const string Logger = LoggerApi + LoggerRouteName;
@ -163,5 +164,9 @@ namespace TIAMWebApp.Shared.Application.Models
public const string SendEmailRouteName = "SendEmail"; public const string SendEmailRouteName = "SendEmail";
public const string SendEmail = MessageAPI+SendEmailRouteName; public const string SendEmail = MessageAPI+SendEmailRouteName;
//payment
public const string CreatePaymentRouteName = "CreatePayment";
public const string CreatePayment = PaymentAPI + CreatePaymentRouteName;
} }
} }

View File

@ -48,7 +48,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Services.Server", "TIA
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Services.Server.Tests", "TIAM.Services.Server.Tests\TIAM.Services.Server.Tests.csproj", "{433A137C-0FEF-4B96-B17F-1F4400108207}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Services.Server.Tests", "TIAM.Services.Server.Tests\TIAM.Services.Server.Tests.csproj", "{433A137C-0FEF-4B96-B17F-1F4400108207}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Models.Server", "TIAM.Models.Server\TIAM.Models.Server.csproj", "{D21032B0-B25F-495E-B784-1D3166FE720C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Models.Server", "TIAM.Models.Server\TIAM.Models.Server.csproj", "{D21032B0-B25F-495E-B784-1D3166FE720C}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution