@page "/formulaone" @using AyCode.Interfaces.StorageHandlers; @using BlazorAnimation @using Newtonsoft.Json; @using TIAM.Entities.Transfers @using TIAMSharedUI.Shared.Components @using TIAMWebApp.Shared.Application.Interfaces @using TIAMWebApp.Shared.Application.Models.ClientSide; @using AyCode.Blazor.Components; @using TIAMWebApp.Shared.Application.Models; @using TIAMWebApp.Shared.Application.Models.ClientSide.UI @using TIAMWebApp.Shared.Application.Models.PageModels @using TIAMWebApp.Shared.Application.Utility; @using System.IdentityModel.Tokens.Jwt; @using TIAMSharedUI.Pages.Components; @using TIAMSharedUI.Shared @using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @inject NavigationManager NavManager @inject IUserDataService UserDataService; @inject IJSRuntime jsRuntime; @inject ISecureStorageHandler SecureStorageHandler @inject ISessionService sessionService; @inject IStringLocalizer localizer; @inject NavigationManager navManager @inject LogToBrowserConsole logToBrowserConsole @inject ITransferDataService transferDataService Index
@{ if (!showWizard) {

BUDAPEST - HUNGARORING

Early bird sale

Friday

round trip

Budapest Hungaroring
Early bird sale

Saturday

round trip

Budapest Hungaroring
Early bird sale

Sunday

round trip

Budapest Hungaroring
Early bird sale

3 days

round trip

Budapest Hungaroring

AIRPORT - HUNGARORING

One way transfer

One way transfer

One way transfer

FROM LOCATION OUTSIDE OF BUDAPEST

Friday round trip

Saturday round trip

Sunday round trip

3 days round trip bundle

//six cards for the six available services } else {
Early bird sale
} }
@code { [CascadingParameter] private PopupMessageBox PopupMessageBox { get; set; } = default!; public bool showWizard = false; public string _location1 = "Budapest"; public string _location2 = "Airport"; public string _location3 = "Other"; public int[] OrderDates; public bool OrderIsReturn; public string OrderLocation; public List sliders = new List { new HeroSliderItem { Title = "Welcome to TIAM", ImageUrl = "https://cdn.discordapp.com/attachments/1009417752978661446/1223738909545201734/adam_the_walking_dad_on_the_racetrack_in_epic_scene_with_sunset_949f618b-40f6-460c-80c8-b1acb1dd609e.png?ex=661af2ac&is=66087dac&hm=a65227652da3b9c165b197f58d031cbdbbea392290a1bca53fc8c768d732b53e&" }, new HeroSliderItem { Title = "Welcome to TIAM", ImageUrl = "https://cdn.discordapp.com/attachments/1009417752978661446/1223720528544792687/adam_the_walking_dad_a_formula_1_race_track_with_a_formula_1_ra_f9ca52cb-6e1a-4458-929d-99d08bce7c1f.png?ex=661ae18d&is=66086c8d&hm=aa9ef7d602f1f9e42884469b0c556886540400c0a46131d9b06e855e85523140&" }, new HeroSliderItem { Title = "Welcome to TIAM", ImageUrl = "https://cdn.discordapp.com/attachments/1009417752978661446/1223734873504616580/adam_the_walking_dad_a_formula_1_race_track_with_a_formula_1_ra_09b9f360-9660-41bc-840a-5b0b7a189ef7.png?ex=661aeee9&is=660879e9&hm=6e07a2da7d6de8767f56b4d62e5a268975b62d417e96cd5ed723dcb88f299d65&" }, }; public TransferWizardModel myModel = new TransferWizardModel(); public List TransferIgnorList = new List { "Id", "UserId", "Destination", "PickupAddress", "ProductId", "TripDate", "FirstName", "LastName", "UserProductMappingId", "UserProductToCarId", "ReferralId", "Price", "Comment" }; /*protected override void OnAfterRender(bool isFirst) { message = " Target destination is " + slider.SliderElementId.ToString(); }*/ public async Task SubmitForm(object result) { var orderModel = result as TransferWizardModel; //check if user exists if (sessionService.IsAuthenticated && sessionService.User != null ) { //Basic settings orderModel.UserId = sessionService.User.UserModelDto.Id; orderModel.ProductId = sessionService.User.UserModelDto.Products.FirstOrDefault()?.Id; } else { //cherck if user exists var user = await UserDataService.GetUserByEmailAsync(orderModel.EmailAddress); if (user.Id == Guid.Empty) user = null; if (user != null) { orderModel.UserId = user.Id; orderModel.ProductId = user.Products.FirstOrDefault()?.Id; } else { //if not, create user Random random = new Random(); string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; string password = new string(Enumerable.Repeat(chars, 10) .Select(s => s[random.Next(s.Length)]).ToArray()); RegistrationModel regModel = new RegistrationModel { PhoneNumber = orderModel.PhoneNumber, Email = orderModel.EmailAddress, Password = password, ReferralId = null }; var bleh = await UserDataService.CreateGuestUser(regModel); orderModel.UserId = bleh.user.Id; } } await ProcessTransfers(orderModel); } protected override void OnInitialized() { bool IsLoggedIn = sessionService.IsAuthenticated; if (IsLoggedIn) { logToBrowserConsole.LogToBC("logged in" + sessionService.User.UserModelDto.Products.FirstOrDefault().Id); } } public void Book(int[] dates, bool isReturn, string location) { myModel.TripDate = new DateTime(2024, 07, dates[0]); myModel.Destination = "Hungaroring"; myModel.PickupAddress = location; OrderDates = dates; OrderIsReturn = isReturn; OrderLocation = location; showWizard = true; } public async Task> ProcessTransfers(TransferWizardModel orderModel) { List transferList = new List(); foreach (var date in OrderDates) { TransferWizardModel transfer = orderModel.Clone(); transfer.TripDate = new DateTime(2024, 07, date); // Outbound trip transfer.PickupAddress = OrderLocation; transfer.Destination = "Hungaroring"; transferList.Add(transfer); // Return trip transfer = orderModel.Clone(); transfer.TripDate = new DateTime(2024, 07, date); transfer.PickupAddress = "Hungaroring"; transfer.Destination = OrderLocation; transfer.PhoneNumber = orderModel.PhoneNumber; transfer.EmailAddress = orderModel.EmailAddress; transferList.Add(transfer); } var transferResult = await transferDataService.CreateTransfers(transferList); logToBrowserConsole.LogToBC($"Submitted nested form: {transferResult.GetType().FullName}, {transferResult.Count}"); return transferResult; } }