Whatta fuck? Nem is volt kimenőm.

This commit is contained in:
Adam 2024-03-27 12:39:11 +01:00
parent 1005c4d39f
commit c0ec3b624f
18 changed files with 229 additions and 47 deletions

View File

@ -14,13 +14,12 @@
@inject ISecureStorageHandler SecureStorageHandler
@inject ISessionService sessionService;
@inject HttpClient http;
<h3>AppLaunch</h3>
@{
if (string.IsNullOrWhiteSpace(TrackingId))
{
TrackingId = "";
<p>Loading...</p>
// <p>Loading...</p>
}
else
{
@ -28,7 +27,6 @@
}
}
Loading....
@code {
@ -57,7 +55,7 @@ Loading....
logToBrowserConsole = new LogToBrowserConsole(JSRuntime);
//wait for 5 seconds
await Task.Delay(1000);
//await Task.Delay(1000);
if (!string.IsNullOrWhiteSpace(userDetailsStr))
{

View File

@ -20,13 +20,13 @@ namespace TIAMSharedUI.Pages.Components
[CascadingParameter]
private PopupMessageBox PopupMessageBox { get; set; } = default!;
public bool IsVisible = true;
public bool IsVisible = false;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
IsLoggedIn = sessionService.IsAuthenticated;
await PopupMessageBox.ShowAsync("AuthComponent", "Initialized", null, null, null, PopupMessageBox.ButtonOk);
//await PopupMessageBox.ShowAsync("AuthComponent", "Initialized", null, null, null, PopupMessageBox.ButtonOk);
//if (await PopupMessageBox.Show("Cancel", "Cancel this stuff",
//PopupMessageBox.ButtonNo, PopupMessageBox.ButtonYes) == PopupMessageBox.ButtonNo)

View File

@ -117,6 +117,8 @@
public async Task SubmitForm(object Result)
{
var transfer = await WizardProcessor.ProcessWizardAsync<TransferWizardModel>(Result.GetType(), Result);
logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}");
navManager.NavigateTo("/transfer2/" + transfer.Id);

View File

@ -0,0 +1,45 @@
@page "/user/createAndManageTransfer"
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Models;
@using TIAMWebApp.Shared.Application.Interfaces;
@layout AdminLayout
@inject IPopulationStructureDataProvider DataProvider
@inject ISupplierService SupplierService
@inject IUserDataService UserDataService
<PageTitle>Transfer</PageTitle>
<!--We need to check if the user is owner of a swerviceprovider-->
<div class="container">
<!-- Stats admin-->
<hr />
<div class="row py-3">
<div class=" col-12 col-xl-3">
</div>
</div>
</div>
@code {
string Id = "2312-32132121-32123";
bool isUserLoggedIn;
int userType = 0;
protected override void OnInitialized()
{
base.OnInitialized();
}
}

View File

@ -55,8 +55,25 @@
</div>
</div>
</div>
@{
for (int i = 0; i < Destinations.Count; i++)
{
var destination = Destinations[i];
var j = i + 1;
<div class="item" id="@j" style="background-image: url('_content/TIAMSharedUI/images/mapbg.jpg'); background-position: center;">
<div class="item-desc text-center pt-3">
<h3>@destination.Name</h3>
<p>@destination.AddressString</p>
</div>
</div>
}
}
<div class="item" id="1" style="background-image: url(https://images.unsplash.com/photo-1551867633-194f125bddfa?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D); background-position: center;">
@* <div class="item" id="1" style="background-image: url(https://images.unsplash.com/photo-1551867633-194f125bddfa?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D); background-position: center;">
<div class="item-desc text-center pt-3">
<h3>Liszt Ferenc Airport</h3>
@ -73,7 +90,7 @@
<h3>Chain Bridge</h3>
</div>
</div>
</div> *@
</div>
<p>Please type an address or swipe to select from preset destinations!</p>
@ -222,10 +239,10 @@
{
if(firstRender)
{
var dotNetObjRef = DotNetObjectReference.Create(this);
JSRuntime.InvokeVoidAsync("setOwlId", OwlId);
JSRuntime.InvokeVoidAsync("InitOwl", OwlId);
JSRuntime.InvokeVoidAsync("CStoJSCall", dotNetObjRef);
// var dotNetObjRef = DotNetObjectReference.Create(this);
// JSRuntime.InvokeVoidAsync("setOwlId", OwlId);
// JSRuntime.InvokeVoidAsync("InitOwl", OwlId);
// JSRuntime.InvokeVoidAsync("CStoJSCall", dotNetObjRef);
}
@ -277,7 +294,15 @@
{
Destinations = await TransferDataService.GetDestinationsAsync();
Content = TextValue;
InitOwl();
}
private void InitOwl()
{
var dotNetObjRef = DotNetObjectReference.Create(this);
JSRuntime.InvokeVoidAsync("setOwlId", OwlId);
JSRuntime.InvokeVoidAsync("InitOwl", OwlId);
JSRuntime.InvokeVoidAsync("CStoJSCall", dotNetObjRef);
}
}

View File

@ -48,12 +48,6 @@
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="user/cards">
Cards
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" @onclick="()=>expandSysAdminNav = !expandSysAdminNav">
<span class="oi oi-list-rich" aria-hidden="true"></span> System Admin
@ -94,6 +88,11 @@
Hotel Dashboard
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="user/createAndManageTransfer">
Transfer
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="user/serviceprovider/5453-a87f77787d-khj899">
Manage

View File

@ -16,7 +16,7 @@ namespace TIAMWebApp.Client.Services
Task<Supplier[]?> ISupplierService.GetSuppliersAsync()
{
return http.GetFromJsonAsync<Supplier[]>("SupplierAPI");
return http.GetFromJsonAsync<Supplier[]>("api/v1/SupplierAPI");
}
}
}

View File

@ -51,7 +51,7 @@ namespace TIAMWebApp.Client.Services
logToBrowserConsole.LogToBC($"{hasProperties.Count} properties found");
//create user session model
var user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1);
var user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto, hasProperties, 1);
return user;
}
else
@ -64,7 +64,7 @@ namespace TIAMWebApp.Client.Services
public async Task<string> TestUserApi(int Param)
{
var url = $"{Setting.BaseUrl}/{APIUrls.UserTest}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.UserTest}";
var response = await http.PostAsJsonAsync(url, Param);
@ -75,7 +75,7 @@ namespace TIAMWebApp.Client.Services
public async Task<string> AuthenticateUser(LoginModel loginModel)
{
string result = string.Empty;
var url = $"{Setting.BaseUrl}/{APIUrls.AuthenticateUser}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.AuthenticateUser}";
var response = await http.PostAsJsonAsync(url, loginModel);
@ -107,7 +107,7 @@ namespace TIAMWebApp.Client.Services
bool isSuccess = true;
string result = string.Empty;
var url = $"{Setting.BaseUrl}/{APIUrls.CreateUser}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateUser}";
logToBrowserConsole.LogToBC("CreateUser url: " + url);
var response = await http.PostAsJsonAsync(url, regModel);
result = await response.Content.ReadAsStringAsync();
@ -133,13 +133,13 @@ namespace TIAMWebApp.Client.Services
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
{
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserByEmail}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserByEmail}";
return await http.GetFromJsonAsync<UserModelDto?>(url);
}
public async Task<UserModelDto?> GetUserByIdAsync(Guid id)
{
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserById}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUserById}";
logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + id.ToString());
var response = await http.PostAsJsonAsync(url, id);
@ -154,7 +154,7 @@ namespace TIAMWebApp.Client.Services
logToBrowserConsole.LogToBC("RefreshToken() called");
bool isTokenRefreshed = false;
var url = $"{Setting.BaseUrl}/{APIUrls.RefreshToken}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.RefreshToken}";
//var url = APIUrls.RefreshToken;
var serializedStr = JsonConvert.SerializeObject(new AuthenticateRequestAndResponse

View File

@ -1,10 +1,12 @@
using AyCode.Interfaces.Enums;
using AyCode.Interfaces.Messages;
using AyCode.Models.Messages;
using System.Diagnostics;
using TIAM.Entities.Transfers;
//using TIAM.Entities.TransferDestinations;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
using TIAMWebApp.Shared.Application.Utility;
using static AyCode.Interfaces.Enums.IMessageTypes;
namespace TIAMWebApp.Client.Services
@ -33,6 +35,7 @@ namespace TIAMWebApp.Client.Services
return result as TModelType;
case "TransferWizardModel":
Console.WriteLine("TransferWizardModel");
var transferResult = await TransferDataService.CreateTransfer((TransferWizardModel)data);
return transferResult as TModelType;

View File

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.3",
"commands": [
"dotnet-ef"
]
}
}
}

View File

@ -71,6 +71,60 @@ namespace TIAMWebApp.Server.Controllers
return null;//await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Address == address);
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.CreateTransferRouteName)]
public async Task<IActionResult> CreateTransfer([FromBody] JsonElement serializedTransferModel)
{
Console.WriteLine("CreateTransfer called!");
if (string.IsNullOrEmpty(serializedTransferModel.GetRawText()))
{
return BadRequest("SerializedTramsferDestinationWizardModel is required");
}
else
{
TransferWizardModel? transfer = JObject.Parse(serializedTransferModel.GetRawText()).ToObject<TransferWizardModel>();
if (transfer != null)
{
var id = Guid.NewGuid();
//TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
if (string.IsNullOrEmpty(transfer.PhoneNumber) || string.IsNullOrEmpty(transfer.EmailAddress))
{
return BadRequest("Invalid request");
}
else
{
Console.WriteLine($"Transfer to be created: {id}");
Console.WriteLine($"Transfer to be created: {transfer.Id}");
Console.WriteLine($"Transfer to be created: {transfer.Destination}");
Console.WriteLine($"Transfer to be created: {transfer.PickupAddress}");
Console.WriteLine($"Transfer to be created: {transfer.TripDate}");
Console.WriteLine($"Transfer to be created: {transfer.NumberOfPassengers}");
Console.WriteLine($"Transfer to be created: {transfer.FullName}");
Console.WriteLine($"Transfer to be created: {transfer.PhoneNumber}");
Console.WriteLine($"Transfer to be created: {transfer.EmailAddress}");
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
await _adminDal.AddTransferAsync(transfer.CopyToTransfer());
return Ok(transfer);
}
}
else
{
return BadRequest("Invalid request");
}
}
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.CreateTransferDestinationRouteName)]

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
@ -13,5 +13,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishUrl>C:\REPOS\AYCODE\Publish\Server</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net8.0</TargetFramework>
<ProjectGuid>9d0f60cb-0462-4bdb-91bd-cadb574ab5a5</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -9,7 +9,9 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide
public class Setting
{
public static UserBasicDetails UserBasicDetails { get; set; }
public const string BaseUrl = "https://localhost:7116";
//public const string BaseUrl = "https://localhost:7116";
public const string BaseUrl = "https://touriam.mangoweb.hu";
public const string ApiBaseUrl = "https://touriam.mangoweb.hu";
public const bool DarkMode = false;
public static string Locale { get; set; }
}

View File

@ -46,12 +46,12 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
[Required(ErrorMessage = "The price should be specified.")]
[DataType("Price")]
[Display(Name = ResourceKeys.Price, ResourceType = typeof(TIAMResources))]
public double Price2 { get; set; }
public double? Price2 { get; set; }
[Required(ErrorMessage = "The price should be specified.")]
[DataType("Price")]
[Display(Name = ResourceKeys.Price, ResourceType = typeof(TIAMResources))]
public double Price3 { get; set; }
public double? Price3 { get; set; }
public PriceType PriceType { get; set; }
public Address Address { get; set; }
@ -66,9 +66,9 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
public TransferDestinationWizardModel() { }
public TransferDestinationWizardModel(string name, string description, string addressString, double price, double price2, double price3, Address address) :this(Guid.NewGuid(), name, description, addressString, price, price2, price3, address)
public TransferDestinationWizardModel(string name, string description, string addressString, double price, double? price2, double? price3, Address address) :this(Guid.NewGuid(), name, description, addressString, price, price2, price3, address)
{ }
public TransferDestinationWizardModel(Guid id, string name, string description, string addressString, double price, double price2, double price3, Address address)
public TransferDestinationWizardModel(Guid id, string name, string description, string addressString, double price, double? price2, double? price3, Address address)
{
Id = id.ToString();

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using TIAM.Entities.Transfers;
using TIAM.Resources;
namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@ -15,15 +16,13 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
{
public Guid Id { get; set; }
//[Required(ErrorMessage = "The Username value should be specified.")]
//[Required(ErrorMessage = "The destination address should be specified.")]
[Destination(ErrorMessage = "The destination value is invalid.")]
[DataType("TransferDestination")]
[Display(Name = ResourceKeys.Destination, ResourceType = typeof(TIAMResources))]
public string? Destination { get; set; }
//[Required(ErrorMessage = "The Username value should be specified.")]
//[Required(ErrorMessage = "The pickup address should be specified.")]
[DataType("TransferDestination")]
[Display(Name = ResourceKeys.PickupAddress, ResourceType = typeof(TIAMResources))]
public string? PickupAddress { get; set; }
@ -106,6 +105,29 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
Driver = driver;
}
public Transfer CopyToTransfer()
{
var transfer = new Transfer
{
Id = this.Id,
ToAddress = this.Destination,
FromAddress = this.PickupAddress,
Appointment = this.TripDate,
PassengerCount = Convert.ToByte(this.NumberOfPassengers),
//FullName = model.FullName,
//PhoneNumber = model.PhoneNumber,
//EmailAddress = model.EmailAddress,
Price = this.Price,
UserProductMappingId = Guid.NewGuid(),
TransferStatusType = TIAM.Core.Enums.TransferStatusType.OrderSubmitted,
Comment = "Transfer order",
ReferralProductId = Guid.NewGuid(),
};
return transfer;
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]

View File

@ -1,28 +1,33 @@
using System.Collections.Generic;
using Microsoft.IdentityModel.Tokens;
using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users;
namespace TIAMWebApp.Shared.Application.Models
{
public class UserSessionModel
{
//TODO: add user class
public UserModelDto UserModelDto { get; set; }
public Guid UserId { get; set; }
public UserType UserType { get; set; }
public string? UserName { get; set; }
public string? UserName => UserModelDto?.Profile?.Name;
public string DisplayName => string.IsNullOrWhiteSpace(UserName) ? UserId.ToString() : UserName;
public Dictionary<Guid, string>? HasProperties { get; set; }
public int UserRoles { get; set; }
public Dictionary<int, string> UserRolesDictionary { get; set; }
public UserSessionModel(Guid userId, UserType userType, string? userName, Dictionary<Guid, string>? hasProperties, int userRoles)
public UserSessionModel(Guid userId, UserType userType, UserModelDto userModelDto, Dictionary<Guid, string>? hasProperties, int userRoles)
{
UserId = userId;
UserType = userType;
UserName = userName;
UserModelDto = userModelDto;
HasProperties = hasProperties;
//UserRoles = userRoles;
//UserRolesDictionary = new Dictionary<int, string>();
//UserModelDto.ServiceProviders[0].
}
}

View File

@ -56,7 +56,7 @@ namespace TIAMWebApp.Shared.Application.Services
public async Task<string> UploadImageAsync(MultipartContent image)
{
var url = $"{Setting.BaseUrl}/{APIUrls.UploadImage}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.UploadImage}";
var response = await _http.PostAsync(url, image);
//var result = new WizardProcessorResult();

View File

@ -22,7 +22,8 @@ namespace TIAMWebApp.Shared.Application.Services
public async Task<List<TransferDestination>> GetDestinationsAsync()
{
var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinations}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetTransferDestinations}";
//var url = $"{APIUrls.GetTransferDestinations}";
logToBrowserConsole.LogToBC(url);
List<TransferDestination>? response = await http.GetFromJsonAsync<List<TransferDestination>>(url);
if(response == null)
@ -32,19 +33,19 @@ namespace TIAMWebApp.Shared.Application.Services
public async Task<TransferDestination?> GetTransferDestinationbyCoordinatesAsync(string destinationId)
{
var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinationByCoordinates}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetTransferDestinationByCoordinates}";
return await http.GetFromJsonAsync<TransferDestination>(url);
}
public async Task<TransferDestination?> GetTransferDestinationbyAddressAsync(string destinationId)
{
var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinationByAddress}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetTransferDestinationByAddress}";
return await http.GetFromJsonAsync<TransferDestination>(url);
}
public async Task<TransferDestination?> CreateTransferDestination(TransferDestination model)
{
var url = $"{Setting.BaseUrl}/{APIUrls.CreateTransferDestination}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateTransferDestination}";
var response = await http.PostAsJsonAsync(url, model);
//var result = new WizardProcessorResult();
@ -64,10 +65,20 @@ namespace TIAMWebApp.Shared.Application.Services
}
public async Task<TransferWizardModel?> CreateTransfer(TransferWizardModel model)
{
var url = $"{Setting.BaseUrl}/{APIUrls.CreateTransferDestination}";
{
logToBrowserConsole.LogToBC("CreateTransfer called");
logToBrowserConsole.LogToBC(model.PickupAddress);
logToBrowserConsole.LogToBC(model.Destination);
logToBrowserConsole.LogToBC(model.EmailAddress);
logToBrowserConsole.LogToBC(model.PhoneNumber);
logToBrowserConsole.LogToBC(model.TripDate.ToString());
logToBrowserConsole.LogToBC(model.NumberOfPassengers.ToString());
model.Id = Guid.NewGuid();
var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreateTransfer}";
var response = await http.PostAsJsonAsync(url, model);
//var result = new WizardProcessorResult();
//if (response.IsSuccessStatusCode)
@ -86,7 +97,7 @@ namespace TIAMWebApp.Shared.Application.Services
public async Task<TransferDestination?> UpdateTransferDestination(TransferDestination model)
{
var url = $"{Setting.BaseUrl}/{APIUrls.UpdateTransferDestination}";
var url = $"{Setting.ApiBaseUrl}/{APIUrls.UpdateTransferDestination}";
var response = await http.PostAsJsonAsync(url, model);
//var result = new WizardProcessorResult();