Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm
This commit is contained in:
commit
24ae96df0c
|
|
@ -0,0 +1,190 @@
|
||||||
|
@page "/public/transfer/{referralId:guid}/{productId:guid}"
|
||||||
|
@using AyCode.Core.Consts
|
||||||
|
@using AyCode.Core.Helpers
|
||||||
|
@using TIAM.Entities.Products
|
||||||
|
@using TIAM.Entities.ServiceProviders
|
||||||
|
@using TIAM.Entities.Transfers
|
||||||
|
@using TIAM.Services
|
||||||
|
@using TIAMSharedUI.Pages.Components.EditComponents
|
||||||
|
@using TIAMSharedUI.Shared
|
||||||
|
@using AyCode.Services.Loggers
|
||||||
|
@using TIAMWebApp.Shared.Application.Interfaces;
|
||||||
|
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
|
@using TIAMWebApp.Shared.Application.Models.PageModels
|
||||||
|
@using TIAMWebApp.Shared.Application.Services
|
||||||
|
@using TIAMWebApp.Shared.Application.Utility
|
||||||
|
@using AyCode.Core.Extensions
|
||||||
|
@layout AdminLayout
|
||||||
|
@inject IPopulationStructureDataProvider DataProvider
|
||||||
|
@inject ISessionService SessionService
|
||||||
|
@inject IUserDataService UserDataService
|
||||||
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||||
|
@inject AdminSignalRClient _adminSignalRClient
|
||||||
|
@inject NavigationManager navManager
|
||||||
|
|
||||||
|
<PageTitle>Create transfer</PageTitle>
|
||||||
|
|
||||||
|
<div class="text-center m-5">
|
||||||
|
<h1>Create transfer</h1>
|
||||||
|
<h2 style="font-size:small">Order a new transfer here!</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--We need to check if the user is owner of a swerviceprovider-->
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
|
||||||
|
<div class="row d-flex justify-content-center">
|
||||||
|
<div class="col-12 col-md-6">
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Partner:</h3>
|
||||||
|
<p>@SelectedHotel</p>
|
||||||
|
|
||||||
|
<div class="row py-3">
|
||||||
|
|
||||||
|
<DynamicEditForm Data="Data" isEditing="true" IgnoreReflection="TransferIgnorList" OnSubmit="SubmitForm"></DynamicEditForm>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row py-3">
|
||||||
|
|
||||||
|
<DxButton RenderStyle="ButtonRenderStyle.Primary" Click="@Reload" Visible="@isReloadVisible">Reload</DxButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid referralId { get; set; }
|
||||||
|
[Parameter] public Guid productId { get; set; }
|
||||||
|
|
||||||
|
private LoggerClient<PublicCreateAndManageTransfer> _logger;
|
||||||
|
private TransferWizardModel Data = new();
|
||||||
|
|
||||||
|
private Product SelectedHotel;
|
||||||
|
public List<string> TransferIgnorList = new List<string>
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
_logger = new LoggerClient<PublicCreateAndManageTransfer>(LogWriters.ToArray());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Data = new TransferWizardModel();
|
||||||
|
base.OnInitialized();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
if(productId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
var result = await _adminSignalRClient.GetByIdAsync<Product>(SignalRTags.GetCompaniesById, productId);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
SelectedHotel = result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedHotel = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!referralId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//check if storage has some other referralId already TODO
|
||||||
|
//if not, store referralId in device for 30 days (?)
|
||||||
|
|
||||||
|
|
||||||
|
//check if user is logged in
|
||||||
|
if (SessionService.IsAuthenticated)
|
||||||
|
{
|
||||||
|
if (SessionService.User != null)
|
||||||
|
{
|
||||||
|
if(SessionService.User.UserModelDto.UserDto.RefferalId == null)
|
||||||
|
{
|
||||||
|
//update user referralId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SubmitForm(object result)
|
||||||
|
{
|
||||||
|
var valami = ((TransferWizardModel)result).CopyToTransfer();
|
||||||
|
valami.Id = Guid.NewGuid();
|
||||||
|
valami.ProductId = SelectedHotel.Id;
|
||||||
|
var user = await UserDataService.GetUserByEmailAsync(valami.ContactEmail);
|
||||||
|
if (user != null && user.Id != Guid.Empty)
|
||||||
|
{
|
||||||
|
//user exists already
|
||||||
|
var userDetail = await UserDataService.GetUserDetailByIdAsync(user.Id);
|
||||||
|
valami.ReferralId = userDetail.UserDto.RefferalId;
|
||||||
|
valami.UserId = userDetail.Id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//create a guest user and set referralId
|
||||||
|
var registration = new RegistrationModel();
|
||||||
|
//TODO: Refractor to userDataService
|
||||||
|
|
||||||
|
// var random = new Random();
|
||||||
|
// const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||||
|
// var password = new string(Enumerable.Repeat(chars, 10)
|
||||||
|
// .Select(s => s[random.Next(s.Length)]).ToArray());
|
||||||
|
|
||||||
|
var password = AcCharsGenerator.NewPassword(AcConst.MinPasswordLength, 16);
|
||||||
|
|
||||||
|
registration.Email = valami.ContactEmail;
|
||||||
|
registration.PhoneNumber = valami.ContactPhone;
|
||||||
|
registration.Password = password;
|
||||||
|
//get list with one member!
|
||||||
|
var productOwner = await _adminSignalRClient.GetByIdAsync<List<Company>>(SignalRTags.GetCompaniesById, SelectedHotel.ServiceProviderId);
|
||||||
|
|
||||||
|
registration.ReferralId = productOwner[0].AffiliateId;
|
||||||
|
|
||||||
|
var createResult = await UserDataService.CreateGuestUser(registration);
|
||||||
|
if(createResult.isSuccess)
|
||||||
|
{
|
||||||
|
if (createResult.user != null)
|
||||||
|
{
|
||||||
|
valami.UserId = createResult.user.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.Info("New user created added");
|
||||||
|
}
|
||||||
|
//valami.ProductId = SessionService.User.UserId; //TODO ProductID!
|
||||||
|
// await WizardProcessor.ProcessWizardAsync<TransferDestinationWizardModel>(result.GetType(), result);
|
||||||
|
|
||||||
|
var saveResult = await _adminSignalRClient.PostDataAsync<Transfer>(SignalRTags.AddTransfer, valami);
|
||||||
|
_logger.Info($"Submitted form: {result.GetType().FullName}, {valami.ToAddress}, {valami.FromAddress}, {valami.ProductId}");
|
||||||
|
isReloadVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reload()
|
||||||
|
{
|
||||||
|
Data = new TransferWizardModel();
|
||||||
|
isReloadVisible = false;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -31,18 +31,20 @@
|
||||||
<div class="col-12 col-md-6">
|
<div class="col-12 col-md-6">
|
||||||
@RenderDetailsItem("fa-solid fa-key", "Password", Context.UserDto.Password)
|
@RenderDetailsItem("fa-solid fa-key", "Password", Context.UserDto.Password)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-9 col-md-4">
|
<div class="col-9 col-md-4">
|
||||||
<DxTextBox
|
<DxTextBox @bind-Text="@OldPassword"
|
||||||
@bind-Text="@NewPassword"
|
NullText="Old password"
|
||||||
NullText="New password"
|
Password="true"
|
||||||
BindValueMode="BindValueMode.OnDelayedInput"
|
CssClass="form-field" />
|
||||||
InputDelay="300"
|
<DxTextBox @bind-Text="@NewPassword"
|
||||||
Password="true"
|
NullText="New password"
|
||||||
CssClass="form-field"
|
BindValueMode="BindValueMode.OnDelayedInput"
|
||||||
/>
|
InputDelay="300"
|
||||||
|
Password="true"
|
||||||
|
CssClass="form-field" />
|
||||||
<DxTextBox @bind-Text="@ConfirmNewPassword"
|
<DxTextBox @bind-Text="@ConfirmNewPassword"
|
||||||
ReadOnly="@PasswordNotSet"
|
ReadOnly="@PasswordNotSet"
|
||||||
NullText="Confirm new password"
|
NullText="Confirm new password"
|
||||||
BindValueMode="BindValueMode.OnDelayedInput"
|
BindValueMode="BindValueMode.OnDelayedInput"
|
||||||
InputDelay="300"
|
InputDelay="300"
|
||||||
|
|
@ -52,7 +54,7 @@
|
||||||
<div class="col-3 col-md-2">
|
<div class="col-3 col-md-2">
|
||||||
<DxButton CssClass="btn btn-primary" Click="SetPassword" Enabled="@isSaveActive"> Save</DxButton>
|
<DxButton CssClass="btn btn-primary" Click="SetPassword" Enabled="@isSaveActive"> Save</DxButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>@msg</p>
|
<p>@msg</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -107,8 +109,8 @@
|
||||||
|
|
||||||
void OnPasswordConfirmed(string password)
|
void OnPasswordConfirmed(string password)
|
||||||
{
|
{
|
||||||
if(NewPassword == ConfirmNewPassword)
|
if (NewPassword == ConfirmNewPassword)
|
||||||
{
|
{
|
||||||
PasswordNotConfirmed = false;
|
PasswordNotConfirmed = false;
|
||||||
isSaveActive = true;
|
isSaveActive = true;
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +119,7 @@
|
||||||
isSaveActive = false;
|
isSaveActive = false;
|
||||||
msg = "Password and confirmation not matching!";
|
msg = "Password and confirmation not matching!";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task SetPassword()
|
protected async Task SetPassword()
|
||||||
|
|
@ -130,9 +132,9 @@
|
||||||
var result = await AdminSignalRClient.PostDataAsync(SignalRTags.UserChangePassword, changePasswordDto);
|
var result = await AdminSignalRClient.PostDataAsync(SignalRTags.UserChangePassword, changePasswordDto);
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
msg = $"Password saved";
|
msg = $"Password saved";
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -151,8 +153,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
await base.OnParametersSetAsync();
|
await base.OnParametersSetAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
<AddressDetailGridComponent ParentData="resultCompany.Profile" />
|
<AddressDetailGridComponent ParentData="resultCompany.Profile" />
|
||||||
</DxTabPage>
|
</DxTabPage>
|
||||||
<DxTabPage Text="Services">
|
<DxTabPage Text="Services">
|
||||||
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsByOwnerId" ContextId="@resultCompany.Id" ParentData="@resultCompany" />
|
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsByOwnerId" ShowManageButtons="true" ContextId="@resultCompany.Id" ParentData="@resultCompany" />
|
||||||
</DxTabPage>
|
</DxTabPage>
|
||||||
</DxTabs>
|
</DxTabs>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
<DxTabs>
|
<DxTabs>
|
||||||
<DxTabPage Text="Products">
|
<DxTabPage Text="Products">
|
||||||
<ProductDetailGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ParentData="(Company)context.DataItem" ContextId="((Company)context.DataItem).Id" />
|
<ProductDetailGridComponent ShowManageButtons="true" DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ParentData="(Company)context.DataItem" ContextId="((Company)context.DataItem).Id" />
|
||||||
</DxTabPage>
|
</DxTabPage>
|
||||||
|
|
||||||
</DxTabs>
|
</DxTabs>
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
<DxGridDataColumn FieldName="@nameof(Product.ServiceProvider.Name)" Caption="Company name" />
|
<DxGridDataColumn FieldName="@nameof(Product.ServiceProvider.Name)" Caption="Company name" />
|
||||||
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductName) FieldName="Name" SortIndex="0"/>
|
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductName) FieldName="Name" SortIndex="0"/>
|
||||||
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductType) FieldName="ProductType" Width="130" />
|
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductType) FieldName="ProductType" Width="130" />
|
||||||
<DxGridDataColumn FieldName="Id" Width="180">
|
<DxGridDataColumn FieldName="Id" Visible="@ShowManageButtons" Width="180">
|
||||||
<CellDisplayTemplate>
|
<CellDisplayTemplate>
|
||||||
@{
|
@{
|
||||||
Product product = (Product)context.DataItem;
|
Product product = (Product)context.DataItem;
|
||||||
|
|
@ -61,6 +61,19 @@
|
||||||
</CellDisplayTemplate>
|
</CellDisplayTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="100" />
|
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="100" />
|
||||||
|
<DxGridDataColumn Caption="ReferralLink" FieldName="Id" Width="100" >
|
||||||
|
<CellDisplayTemplate>
|
||||||
|
@*
|
||||||
|
/public/transfer/{referralId:guid}/{productId:guid}
|
||||||
|
*@
|
||||||
|
@{
|
||||||
|
Product product = (Product)context.DataItem;
|
||||||
|
|
||||||
|
<p>@Setting.BaseUrl/public/transfer/@product.ServiceProvider.AffiliateId/@product.Id</p>
|
||||||
|
|
||||||
|
}
|
||||||
|
</CellDisplayTemplate>
|
||||||
|
</DxGridDataColumn>
|
||||||
<DxGridDataColumn Caption="Options">
|
<DxGridDataColumn Caption="Options">
|
||||||
<CellDisplayTemplate>
|
<CellDisplayTemplate>
|
||||||
@{
|
@{
|
||||||
|
|
@ -132,6 +145,7 @@
|
||||||
[Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; }
|
[Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; }
|
||||||
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByOwnerId;
|
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByOwnerId;
|
||||||
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
|
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
|
||||||
|
[Parameter] public bool ShowManageButtons { get; set; } = false;
|
||||||
|
|
||||||
private List<TransferDestination> destinations = [];
|
private List<TransferDestination> destinations = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ExchangeRate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
<ExchangeRate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
<EURtoHUF>380</EURtoHUF>
|
<EURtoHUF>390</EURtoHUF>
|
||||||
</ExchangeRate>
|
</ExchangeRate>
|
||||||
Loading…
Reference in New Issue