diff --git a/TIAMMobileApp/MauiProgram.cs b/TIAMMobileApp/MauiProgram.cs index bbd0a6d7..e1a9dfb6 100644 --- a/TIAMMobileApp/MauiProgram.cs +++ b/TIAMMobileApp/MauiProgram.cs @@ -49,6 +49,7 @@ namespace TIAMMobileApp builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(); + builder.Services.AddScoped(); builder.Services.AddSingleton(x => new ResourceManager("TIAMWebApp.Shared.Application.Resources", typeof(Main).Assembly)); return builder.Build(); } diff --git a/TIAMMobileApp/Services/TransferDataService.cs b/TIAMMobileApp/Services/TransferDataService.cs index a896f8c2..96821dc0 100644 --- a/TIAMMobileApp/Services/TransferDataService.cs +++ b/TIAMMobileApp/Services/TransferDataService.cs @@ -3,6 +3,7 @@ using TIAM.Entities.TransferDestinations; using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models.ClientSide; +using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; namespace TIAMMobileApp.Services { @@ -16,6 +17,13 @@ namespace TIAMMobileApp.Services this.http = http; } + public async Task CreateTransferDestination(TransferDestinationWizardModel model) + { + var url = $"{Setting.BaseUrl}/{APIUrls.CreateTransferDestination}"; + var response = await http.PostAsJsonAsync(url, model); + return response.IsSuccessStatusCode; + } + /// /// calls the TransferDataAPI to get the list of destinations public async Task GetDestinationsAsync() @@ -24,6 +32,11 @@ namespace TIAMMobileApp.Services return await http.GetFromJsonAsync(url); } + public Task GetTransferDestinationbyAddressAsync(string destinationId) + { + throw new NotImplementedException(); + } + public async Task GetTransferDestinationbyCoordinatesAsync(string destinationId) { var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinationByCoordinates}"; diff --git a/TIAMMobileApp/Services/WizardProcessor.cs b/TIAMMobileApp/Services/WizardProcessor.cs new file mode 100644 index 00000000..37d34784 --- /dev/null +++ b/TIAMMobileApp/Services/WizardProcessor.cs @@ -0,0 +1,48 @@ +using TIAM.Entities.TransferDestinations; +using TIAMWebApp.Shared.Application.Interfaces; +using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; + +namespace TIAMMobileApp.Services +{ + public class WizardProcessor : IWizardProcessor + { + + public ITransferDataService transferDataService { get; set; } + public IUserDataService userDataService { get; set; } + + public WizardProcessor(ITransferDataService transferDataService, IUserDataService userDataService) + { + this.transferDataService = transferDataService; + this.userDataService = userDataService; + } + + public async Task ProcessWizardAsync(Type type, object data) + { + switch (type.Name) + { + case "TransferDestinationWizardModel": + var result = await transferDataService.CreateTransferDestination((TransferDestinationWizardModel)data); + if (result) + return "Success"; + else + return "Failed"; + + case "ServiceProvider": + default: + return "Not implemented"; + } + } + + public Task ValidateWizardStepAsync(Type type, string fieldName, object fieldValue) + { + //if type is TransferDestination, then validate the field name + //if (type.Name == "TransferDestination") + // return await TransferDataService.ValidateDestination(fieldName); + //if type is ServiceProvider, then validate the field name + //if type is something else, then throw an exception + + + throw new NotImplementedException(); + } + } +} diff --git a/TIAMResources/TIAMResources.Designer.cs b/TIAMResources/TIAMResources.Designer.cs index 322bfc8a..d43e6571 100644 --- a/TIAMResources/TIAMResources.Designer.cs +++ b/TIAMResources/TIAMResources.Designer.cs @@ -95,5 +95,14 @@ namespace TIAM.Resources { return ResourceManager.GetString("Test", resourceCulture); } } + + /// + /// Looks up a localized string similar to Wizard. + /// + public static string Wizard { + get { + return ResourceManager.GetString("Wizard", resourceCulture); + } + } } } diff --git a/TIAMResources/TIAMResources.hu.resx b/TIAMResources/TIAMResources.hu.resx index 7578f720..6d78fa23 100644 --- a/TIAMResources/TIAMResources.hu.resx +++ b/TIAMResources/TIAMResources.hu.resx @@ -129,4 +129,7 @@ Müxik! + + Varázsló + \ No newline at end of file diff --git a/TIAMResources/TIAMResources.resx b/TIAMResources/TIAMResources.resx index 21bc2e2d..7d018fec 100644 --- a/TIAMResources/TIAMResources.resx +++ b/TIAMResources/TIAMResources.resx @@ -129,4 +129,7 @@ This works! + + Wizard + \ No newline at end of file diff --git a/TIAMSharedUI/Pages/Components/InputWizard.razor b/TIAMSharedUI/Pages/Components/InputWizard.razor index 0eac3f89..bddd642d 100644 --- a/TIAMSharedUI/Pages/Components/InputWizard.razor +++ b/TIAMSharedUI/Pages/Components/InputWizard.razor @@ -1,8 +1,8 @@ @using System.Linq.Expressions @using System.ComponentModel.DataAnnotations -@inject IStringLocalizer Localizer -

Edit Form

+ +
-

Register with DevExpress

+

@localizer.GetString(TitleResourceString)

- Create a new account to see it in action + Sibtitle here

@@ -24,7 +24,7 @@

-

@Localizer.GetString("DestinationName")

+

@localizer.GetString("DestinationName")

@_formSubmitResult

diff --git a/TIAMSharedUI/Pages/Components/InputWizard.razor.cs b/TIAMSharedUI/Pages/Components/InputWizard.razor.cs index 8646c63b..a298bf51 100644 --- a/TIAMSharedUI/Pages/Components/InputWizard.razor.cs +++ b/TIAMSharedUI/Pages/Components/InputWizard.razor.cs @@ -9,6 +9,9 @@ using TIAMWebApp.Shared.Application.Utility; using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; using TIAMWebApp.Shared.Application.Models.PageModels; using DevExpress.Pdf.Native.BouncyCastle.Asn1.X509.Qualified; +using Microsoft.Extensions.Localization; +using TIAM.Resources; +using TIAMWebApp.Shared.Application.Interfaces; namespace TIAMSharedUI.Pages.Components @@ -18,12 +21,20 @@ namespace TIAMSharedUI.Pages.Components [Inject] public required LogToBrowserConsole LogToBrowserConsole { get; set; } + [Inject] + IStringLocalizer localizer { get; set; } + + [Inject] + public IWizardProcessor WizardProcessor { get; set; } + public Dictionary FormSteps { get; set; } = new Dictionary(); public int CurrentStep { get; set; } = 0; - //TestUserData Data { get; set; } = new TestUserData(); + [Parameter] + public string TitleResourceString { get; set; } = "Wizard"; + [Parameter] public object Data { get; set; } = new object(); @@ -31,7 +42,7 @@ namespace TIAMSharedUI.Pages.Components public EventCallback OnSubmit { get; set; } - string _phoneMask = "(999)000-0000"; + string _formSubmitResult = ""; private string _spinnerClass = ""; @@ -39,6 +50,7 @@ namespace TIAMSharedUI.Pages.Components { _spinnerClass = "spinner-border spinner-border-sm"; await Task.Delay(500); + await WizardProcessor.ProcessWizardAsync(Data.GetType(), Data); _formSubmitResult = "You have been registred successully."; _spinnerClass = ""; @@ -80,10 +92,10 @@ namespace TIAMSharedUI.Pages.Components { //if (property.Name == "Id" || property.Name == "Latitude" || property.Name == "Longitude" || property.Name == "Created" || property.Name == "Modified") - if (property.Name == "Id" || property.Name == "Created" || property.Name == "Modified") - { - continue; - } + //if (property.Name == "Id" || property.Name == "Created" || property.Name == "Modified") + //{ + // continue; + //} Guid _stepID = Guid.Empty; @@ -149,7 +161,7 @@ namespace TIAMSharedUI.Pages.Components { editor.OpenComponent>(j++); editor.AddAttribute(j++, "Value", property.GetValue(Data)); - editor.AddAttribute(j++, "Mask", _phoneMask); + editor.AddAttribute(j++, "Mask", TIAMRegularExpressions.PhoneNumberMask); editor.AddAttribute(j++, "ValueExpression", lambda); editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create(this, str => { property.SetValue(Data, str); })); editor.CloseComponent(); diff --git a/TIAMSharedUI/Pages/Components/StepComponent.Razor.cs b/TIAMSharedUI/Pages/Components/StepComponent.Razor.cs deleted file mode 100644 index 8784dfa0..00000000 --- a/TIAMSharedUI/Pages/Components/StepComponent.Razor.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TIAMWebApp.Shared.Application.Models.ClientSide.UI; - -namespace TIAMSharedUI.Pages.Components -{ - public partial class StepComponent : ComponentBase - { - - [Parameter] - public RenderFragment ChildContent { get; set; } - - [Parameter] - public ACStepModelBase StepModel { get; set; } - - - [Parameter] - public EventCallback OnNext { get; set; } - - - } -} diff --git a/TIAMSharedUI/Pages/Components/StepComponent.razor b/TIAMSharedUI/Pages/Components/StepComponent.razor deleted file mode 100644 index 6ab7f06d..00000000 --- a/TIAMSharedUI/Pages/Components/StepComponent.razor +++ /dev/null @@ -1,5 +0,0 @@ -

StepComponent

- -@code { - -} diff --git a/TIAMSharedUI/Pages/Components/StepComponentBase.Razor.cs b/TIAMSharedUI/Pages/Components/StepComponentBase.Razor.cs deleted file mode 100644 index 74fddd70..00000000 --- a/TIAMSharedUI/Pages/Components/StepComponentBase.Razor.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.AspNetCore.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TIAMSharedUI.Pages.Components -{ - public partial class StepComponentBase : ComponentBase - { - - - - - - } -} diff --git a/TIAMSharedUI/Pages/Components/StepComponentBase.razor b/TIAMSharedUI/Pages/Components/StepComponentBase.razor deleted file mode 100644 index 0f7b5209..00000000 --- a/TIAMSharedUI/Pages/Components/StepComponentBase.razor +++ /dev/null @@ -1,5 +0,0 @@ -

StepComponentBase

- -@code { - -} diff --git a/TIAMSharedUI/Pages/User/HotelComponent.razor.cs b/TIAMSharedUI/Pages/User/HotelComponent.razor.cs index e1152313..1c3ecb46 100644 --- a/TIAMSharedUI/Pages/User/HotelComponent.razor.cs +++ b/TIAMSharedUI/Pages/User/HotelComponent.razor.cs @@ -35,7 +35,7 @@ namespace TIAMSharedUI.Pages.User OrderData = new object[] { - new { + new { Date = DateTime.Now.AddDays(3), Income = "$5", TransactionId = "POX987532582", diff --git a/TIAMSharedUI/Pages/User/MyServiceProviders.razor b/TIAMSharedUI/Pages/User/MyServiceProviders.razor new file mode 100644 index 00000000..42b9b799 --- /dev/null +++ b/TIAMSharedUI/Pages/User/MyServiceProviders.razor @@ -0,0 +1,72 @@ +@page "/user/properties" +@using TIAMSharedUI.Shared +@layout AdminLayout +

Properties

+ +

You have no properties yet...

+ +
+
+
+
+ + + + + + @context.Value + + + + + + + + + + + +
+ +
+

Some conclusion

+
+
+
+
+ + +@code { + + object? OrderData { get; set; } + + protected override void OnInitialized() + { + base.OnInitialized(); + OrderData = new object[] + { + new { + Date = DateTime.Now.AddDays(3), + Income = "$5", + TransactionId = "POX987532582", + Status = "Finished" + }, + new { + Date = DateTime.Today.AddDays(-2), + Income = "$5", + TransactionId = "POX645646382", + Status = "Finished" + }, + new + { + Date = DateTime.Today.AddDays(-6), + Income = "$8", + TransactionId = "POX645766311", + Status = "Finished" + }, + }; + + + } + +} diff --git a/TIAMSharedUI/Pages/User/Properties.razor b/TIAMSharedUI/Pages/User/Properties.razor deleted file mode 100644 index 110f7581..00000000 --- a/TIAMSharedUI/Pages/User/Properties.razor +++ /dev/null @@ -1,8 +0,0 @@ -@page "/user/properties" -@using TIAMSharedUI.Shared -@layout AdminLayout -

Properties

- -@code { - -} diff --git a/TIAMWebApp/Client/Program.cs b/TIAMWebApp/Client/Program.cs index 0a8c2367..953fa4fa 100644 --- a/TIAMWebApp/Client/Program.cs +++ b/TIAMWebApp/Client/Program.cs @@ -26,6 +26,7 @@ builder.Services.AddBlazoredLocalStorage(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddScoped(); +builder.Services.AddScoped(); //WebSpecific builder.Services.AddScoped(); builder.Services.AddSingleton(x => new ResourceManager("TIAMWebApp.Client.Resources.MyResources", typeof(Program).Assembly)); diff --git a/TIAMWebApp/Client/Services/TransferDataService.cs b/TIAMWebApp/Client/Services/TransferDataService.cs index 02926678..a72ab792 100644 --- a/TIAMWebApp/Client/Services/TransferDataService.cs +++ b/TIAMWebApp/Client/Services/TransferDataService.cs @@ -3,6 +3,7 @@ using TIAM.Entities.TransferDestinations; using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models.ClientSide; +using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; using TIAMWebApp.Shared.Application.Utility; namespace TIAMWebApp.Client.Services @@ -37,5 +38,12 @@ namespace TIAMWebApp.Client.Services var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinationByAddress}"; return await http.GetFromJsonAsync(url); } + + public async Task CreateTransferDestination(TransferDestinationWizardModel model) + { + var url = $"{Setting.BaseUrl}/{APIUrls.CreateTransferDestination}"; + var response = await http.PostAsJsonAsync(url, model); + return response.IsSuccessStatusCode; + } } } diff --git a/TIAMWebApp/Client/Services/WizardProcessor.cs b/TIAMWebApp/Client/Services/WizardProcessor.cs new file mode 100644 index 00000000..1578db08 --- /dev/null +++ b/TIAMWebApp/Client/Services/WizardProcessor.cs @@ -0,0 +1,48 @@ +using TIAM.Entities.TransferDestinations; +using TIAMWebApp.Shared.Application.Interfaces; +using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; + +namespace TIAMWebApp.Client.Services +{ + public class WizardProcessor : IWizardProcessor + { + + public ITransferDataService transferDataService { get; set; } + public IUserDataService userDataService { get; set; } + + public WizardProcessor(ITransferDataService transferDataService, IUserDataService userDataService) + { + this.transferDataService = transferDataService; + this.userDataService = userDataService; + } + + public async Task ProcessWizardAsync(Type type, object data) + { + switch (type.Name) + { + case "TransferDestinationWizardModel": + var result = await transferDataService.CreateTransferDestination((TransferDestinationWizardModel)data); + if (result) + return "Success"; + else + return "Failed"; + + case "ServiceProvider": + default: + return "Not implemented"; + } + } + + public Task ValidateWizardStepAsync(Type type, string fieldName, object fieldValue) + { + //if type is TransferDestination, then validate the field name + //if (type.Name == "TransferDestination") + // return await TransferDataService.ValidateDestination(fieldName); + //if type is ServiceProvider, then validate the field name + //if type is something else, then throw an exception + + + throw new NotImplementedException(); + } + } +} diff --git a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs index 06c98d36..6018e375 100644 --- a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs +++ b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs @@ -12,6 +12,7 @@ using TIAM.Database.DbContexts; using TIAM.Entities.TransferDestinations; using TIAM.Entities.Users; using TIAMWebApp.Shared.Application.Models; +using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; using TIAMWebApp.Shared.Application.Models.PageModels; namespace TIAMWebApp.Server.Controllers @@ -76,32 +77,29 @@ namespace TIAMWebApp.Server.Controllers Console.WriteLine("CreateTransferDestination called!"); if (string.IsNullOrEmpty(SerializedTransferDestinationModel.GetRawText())) { - return BadRequest("SerializedLoginModel is required"); + return BadRequest("SerializedTramsferDestinationWizardModel is required"); } else { - TransferDestination? transferDestination = JObject.Parse(SerializedTransferDestinationModel.GetRawText()).ToObject(); + TransferDestinationWizardModel? transferDestinationModel = JObject.Parse(SerializedTransferDestinationModel.GetRawText()).ToObject(); - - if (transferDestination != null) + if (transferDestinationModel != null) { + var Id = Guid.NewGuid(); - string? Name = transferDestination.Name; - string? Description = transferDestination.Description; - double? Latitude = transferDestination.Latitude; - double? Longitude = transferDestination.Longitude; - string? Address = transferDestination.Address; + TransferDestination transferDestination = new TransferDestination(Id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.Latitude, transferDestinationModel.Longitude, transferDestinationModel.Address); + - if (Id == Guid.Empty || Latitude == null || Longitude == null) + if (string.IsNullOrEmpty(transferDestinationModel.Name) || string.IsNullOrEmpty(transferDestinationModel.Address)) { return BadRequest("Invalid request"); } else { Console.WriteLine($"TransferDestination to be created: {Id}"); - Console.WriteLine($"TransferDestination to be created: {Latitude}"); - Console.WriteLine($"TransferDestination to be created: {Longitude}"); - Console.WriteLine($"TransferDestination to be created: {Address}"); + Console.WriteLine($"TransferDestination to be created: {transferDestination.Latitude}"); + Console.WriteLine($"TransferDestination to be created: {transferDestination.Longitude}"); + Console.WriteLine($"TransferDestination to be created: {transferDestination.Address}"); //await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination); await _transferDestinationDal.CreateTransferDestinationAsync(transferDestination); diff --git a/TIAMWebApp/Shared/Interfaces/ITransferDataService.cs b/TIAMWebApp/Shared/Interfaces/ITransferDataService.cs index aa4aa35e..71c2a96f 100644 --- a/TIAMWebApp/Shared/Interfaces/ITransferDataService.cs +++ b/TIAMWebApp/Shared/Interfaces/ITransferDataService.cs @@ -1,10 +1,14 @@ using TIAM.Entities.TransferDestinations; using TIAMWebApp.Shared.Application.Models; +using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; namespace TIAMWebApp.Shared.Application.Interfaces { public interface ITransferDataService { Task GetDestinationsAsync(); + Task GetTransferDestinationbyCoordinatesAsync(string destinationId); + Task GetTransferDestinationbyAddressAsync(string destinationId); + Task CreateTransferDestination(TransferDestinationWizardModel model); } } diff --git a/TIAMWebApp/Shared/Interfaces/IWizardProcessor.cs b/TIAMWebApp/Shared/Interfaces/IWizardProcessor.cs new file mode 100644 index 00000000..575b1519 --- /dev/null +++ b/TIAMWebApp/Shared/Interfaces/IWizardProcessor.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TIAMWebApp.Shared.Application.Interfaces +{ + public interface IWizardProcessor + { + public Task ProcessWizardAsync(Type type, object data); + + public Task ValidateWizardStepAsync(Type type, string fieldName, object fieldValue); + } +} diff --git a/TIAMWebApp/Shared/Models/APIUrls.cs b/TIAMWebApp/Shared/Models/APIUrls.cs index 347913db..b74e0ffa 100644 --- a/TIAMWebApp/Shared/Models/APIUrls.cs +++ b/TIAMWebApp/Shared/Models/APIUrls.cs @@ -23,6 +23,7 @@ namespace TIAMWebApp.Shared.Application.Models public const string GetTransferDestinations = "api/TransferDataAPI/GetTransferDestinations"; public const string GetTransferDestinationByCoordinates = "api/TransferDataAPI/GetTransferDestinationByCoordinates"; public const string GetTransferDestinationByAddress = "api/TransferDataAPI/GetTransferDestinationByAddress"; + public const string CreateTransferDestination = "api/TransferDataAPI/CreateTransferDestination"; public const string GetServiceProvidersByOwnerId = "api/ServiceProviderAPI/GetServiceProvidersByOwnerId";