improvements, fixes
This commit is contained in:
parent
5355bd09cd
commit
05b76fe8a4
|
|
@ -149,9 +149,10 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
#region TransferDestination
|
||||
|
||||
public Task<List<TransferDestination>> GetTransferDestinationsAsync() => SessionAsync(ctx => ctx.GetTransferDestinations().ToList());
|
||||
|
||||
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId));
|
||||
public Task<TransferDestination?> GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationById(transferDestinationId));
|
||||
public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson());
|
||||
public Task<List<TransferDestination>> GetPublicTransferDestinationsAsync(Guid productId) => SessionAsync(ctx => ctx.GetTransferDestinations().Where(x => !x.ProductId.HasValue || x.ProductId == productId).ToList());
|
||||
|
||||
public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination));
|
||||
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination));
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace TIAM.Entities.Transfers
|
|||
[ForeignKey(nameof(AddressId))]
|
||||
public virtual Address Address { get; set; }
|
||||
|
||||
public Guid? ProductId { get; set; }
|
||||
//public virtual List<Product> Products { get; set; }
|
||||
//public virtual List<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ namespace TIAM.Services.Interfaces;
|
|||
|
||||
public interface ITransferApiControllerClient : ITransferApiControllerCommon
|
||||
{
|
||||
Task GetTransferDestinationsInto(List<TransferDestination> intoDestinationList, Action? callback = null);
|
||||
Task GetTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Action? callback = null);
|
||||
Task GetPublicTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Guid includeProductId, Action? callback = null);
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ public interface ITransferApiControllerCommon
|
|||
|
||||
#region TransferDestination
|
||||
public Task<List<TransferDestination>> GetTransferDestinations();
|
||||
public Task<List<TransferDestination>> GetPublicTransferDestinations(Guid includeProductId);
|
||||
public Task<TransferDestination?> GetTransferDestinationById(Guid transferDestinationId);
|
||||
public Task<TransferDestination?> CreateTransferDestination(TransferDestination transferDestination);
|
||||
public Task<TransferDestination?> UpdateTransferDestination(TransferDestination transferDestination);
|
||||
|
|
|
|||
|
|
@ -100,9 +100,10 @@ public class SignalRTags : AcSignalRTags
|
|||
|
||||
public const int GetTransferDestinationById = 80;
|
||||
public const int GetAllTransferDestinations = 81;
|
||||
public const int CreateTransferDestination = 82;
|
||||
public const int UpdateTransferDestination = 83;
|
||||
public const int RemoveTransferDestination = 84; //set permissions to 0
|
||||
public const int GetAllTransferDestinationsByProductId = 82;
|
||||
public const int CreateTransferDestination = 83;
|
||||
public const int UpdateTransferDestination = 84;
|
||||
public const int RemoveTransferDestination = 85; //set permissions to 0
|
||||
|
||||
public const int CreateTransferDestinationToProduct = 90;
|
||||
public const int UpdateTransferDestinationToProduct = 91;
|
||||
|
|
|
|||
|
|
@ -371,7 +371,8 @@ new HeroSliderItem
|
|||
if (createdUserDetail != null)
|
||||
{
|
||||
createdUserDetail.UserDto.RefferalId = userDetail.UserDto.RefferalId;
|
||||
var updatedNewUser = await _adminSignalRClient.PostDataAsync<UserModelDtoDetail>(SignalRTags.UpdateUserModelDtoDetail, userDetail);
|
||||
|
||||
var updatedNewUser = await _adminSignalRClient.UpdateUserModelDtoDetail(userDetail);
|
||||
if (updatedNewUser != null)
|
||||
{
|
||||
//referral set
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@
|
|||
_isAddressTransferDestination = CheckDestinations(_productProfile.AddressId);
|
||||
}
|
||||
|
||||
AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget();
|
||||
AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
@using TIAMSharedUI.Pages.Components.EditComponents
|
||||
@using TIAMSharedUI.Shared
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Enums
|
||||
@using TIAMWebApp.Shared.Application.Interfaces;
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||
@using TIAMWebApp.Shared.Application.Models.PageModels
|
||||
|
|
@ -38,7 +39,7 @@
|
|||
|
||||
|
||||
<h3>Selected Hotel:</h3>
|
||||
<DxComboBox Data="@Hotels"
|
||||
<DxComboBox Data="@_hotels"
|
||||
@bind-Value="@SelectedHotel"
|
||||
SearchMode="@ListSearchMode.AutoSearch"
|
||||
SearchFilterCondition="@ListSearchFilterCondition.Contains"
|
||||
|
|
@ -50,12 +51,12 @@
|
|||
|
||||
<div class="row py-3">
|
||||
|
||||
<DynamicEditForm Data="Data" CurrentProduct="@SelectedHotel" isEditing="true" IgnoreReflection="TransferIgnorList" OnSubmit="SubmitForm"></DynamicEditForm>
|
||||
<DynamicEditForm Data="_data" CurrentProduct="@SelectedHotel" isEditing="true" IgnoreReflection="TransferIgnorList" OnSubmit="SubmitForm"></DynamicEditForm>
|
||||
</div>
|
||||
|
||||
<div class="row py-3">
|
||||
|
||||
<DxButton RenderStyle="ButtonRenderStyle.Primary" Click="@Reload" Visible="@isReloadVisible">Reload</DxButton>
|
||||
<DxButton RenderStyle="ButtonRenderStyle.Primary" Click="@Reload" Visible="@_isReloadVisible">Reload</DxButton>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -66,60 +67,58 @@
|
|||
|
||||
@code {
|
||||
private LoggerClient<CreateAndManageTransfer> _logger;
|
||||
private TransferWizardModel Data = new();
|
||||
private List<Product> Hotels = new List<Product>();
|
||||
private TransferWizardModel _data = new();
|
||||
private List<Product> _hotels = [];
|
||||
private Product selectedHotel { get; set; }
|
||||
public Product SelectedHotel
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectedHotel;
|
||||
}
|
||||
get => selectedHotel;
|
||||
set
|
||||
{
|
||||
if (selectedHotel == value) return;
|
||||
|
||||
selectedHotel = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
private bool SelectedHotelInitialized = false;
|
||||
public List<string> TransferIgnorList =
|
||||
[
|
||||
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;
|
||||
private bool _selectedHotelInitialized = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<CreateAndManageTransfer>(LogWriters.ToArray());
|
||||
|
||||
if (_sessionService.User != null)
|
||||
{
|
||||
|
||||
if (_sessionService.User.UserModelDto.Products.Count() > 0)
|
||||
if (_sessionService.User.UserModelDto.Products.Any())
|
||||
{
|
||||
if (_sessionService.User.UserModelDto.Products.Any(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel))
|
||||
if (_sessionService.User.UserModelDto.Products.Any(x => x.ProductType == ProductType.Hotel))
|
||||
{
|
||||
Hotels = _sessionService.GetHotels();
|
||||
if (!SelectedHotelInitialized)
|
||||
_hotels = _sessionService.GetHotels();
|
||||
if (!_selectedHotelInitialized)
|
||||
{
|
||||
SelectedHotel = Hotels[0];
|
||||
SelectedHotelInitialized = true;
|
||||
SelectedHotel = _hotels[0];
|
||||
_selectedHotelInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Data = new TransferWizardModel();
|
||||
base.OnInitialized();
|
||||
|
||||
}
|
||||
|
||||
public async Task SubmitForm(object result)
|
||||
|
|
@ -171,13 +170,13 @@
|
|||
|
||||
var saveResult = await _adminSignalRClient.PostDataAsync<Transfer>(SignalRTags.AddTransfer, valami);
|
||||
_logger.Info($"Submitted form: {result.GetType().FullName}, {valami.ToAddress}, {valami.FromAddress}, {valami.ProductId}");
|
||||
isReloadVisible = true;
|
||||
_isReloadVisible = true;
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
Data = new TransferWizardModel();
|
||||
isReloadVisible = false;
|
||||
_data = new TransferWizardModel();
|
||||
_isReloadVisible = false;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@
|
|||
{
|
||||
_logger = new LoggerClient<ProductDetailGridComponent>(LogWriters.ToArray());
|
||||
|
||||
AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget();
|
||||
AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget();
|
||||
//DataSource = new List<Address>();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@
|
|||
{
|
||||
_logger = new LoggerClient<ProductGridComponent>(LogWriters.ToArray());
|
||||
|
||||
AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget();
|
||||
AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget();
|
||||
}
|
||||
|
||||
private bool CheckDestinations(Guid addressId)
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@
|
|||
{
|
||||
_logger = new LoggerClient<TransferDestinationToProductGridComponent>(LogWriters.ToArray());
|
||||
|
||||
AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget();
|
||||
AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget();
|
||||
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
|
||||
|
||||
base.OnInitialized();
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@
|
|||
{
|
||||
_logger = new LoggerClient<TransferDestinationToProductGridComponent>(LogWriters.ToArray());
|
||||
|
||||
AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget();
|
||||
AdminSignalRClient.GetTransferDestinationsAsync(_destinations).Forget();
|
||||
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
|
|
|
|||
|
|
@ -110,37 +110,19 @@
|
|||
// StateHasChanged();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<ComboboxItemSelector>(LogWriters.ToArray());
|
||||
|
||||
Guid? productAddressId = Guid.Empty;
|
||||
if (!ProductId.IsNullOrEmpty())
|
||||
if (ProductId.IsNullOrEmpty()) _adminSignalRClient.GetTransferDestinationsAsync(_destinations, GetTransferDestinationsCallback()).Forget();
|
||||
else _adminSignalRClient.GetPublicTransferDestinationsAsync(_destinations, ProductId.Value, GetTransferDestinationsCallback()).Forget();
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
Action GetTransferDestinationsCallback()
|
||||
{
|
||||
var currentProduct = await _adminSignalRClient.GetByIdAsync<Product>(SignalRTags.GetProductById, ProductId);
|
||||
if (currentProduct != null)
|
||||
{
|
||||
if (!currentProduct.Profile.AddressId.IsNullOrEmpty())
|
||||
{
|
||||
productAddressId = currentProduct.Profile.AddressId;
|
||||
}
|
||||
}
|
||||
return () => { SelectedDestination = ProductId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.ProductId == ProductId); };
|
||||
}
|
||||
|
||||
_adminSignalRClient.GetTransferDestinationsInto(_destinations, () =>
|
||||
{
|
||||
SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId);
|
||||
}).Forget();
|
||||
|
||||
// _adminSignalRClient.GetAllIntoAsync(_destinations, SignalRTags.GetAllTransferDestinations, null, resultData =>
|
||||
// {
|
||||
// if (resultData == null) SelectedDestination = null;
|
||||
// else SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId);
|
||||
|
||||
// return Task.CompletedTask;
|
||||
// }).Forget();
|
||||
|
||||
//await _adminSignalRClient.GetAllIntoAsync(Data, SignalRTags.GetAllTransferDestinations);
|
||||
}
|
||||
|
||||
// RenderFragment GetSelectedItemDescription()
|
||||
|
|
|
|||
|
|
@ -47,9 +47,16 @@ namespace TIAMSharedUI.Shared.Components.BaseComponents
|
|||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Initialize();
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
_logger = new LoggerClient<BasePageComponent>(_logWriters.ToArray());
|
||||
|
||||
var currentUrl = _navManager.ToBaseRelativePath(_navManager.Uri);
|
||||
|
||||
_pageState.AddPageToHistory(currentUrl);
|
||||
_logger.Debug(_pageState.GetGoBackPage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,20 +17,20 @@ namespace TIAMSharedUI.Shared.Components.BaseComponents
|
|||
{
|
||||
[Authorize]
|
||||
public class UserBasePageComponent : BasePageComponent
|
||||
{
|
||||
|
||||
{
|
||||
private LoggerClient<UserBasePageComponent> _logger = null!;
|
||||
|
||||
public UserBasePageComponent()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
_logger = new LoggerClient<UserBasePageComponent>(_logWriters.ToArray());
|
||||
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,17 +24,17 @@
|
|||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if(pageHistoryState.CanGoBack())
|
||||
if (pageHistoryState.CanGoBack())
|
||||
{
|
||||
isBackVisible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GoBack()
|
||||
{
|
||||
@if (pageHistoryState.CanGoBack())
|
||||
{
|
||||
NavManager.NavigateTo(pageHistoryState.GetGoBackPage());
|
||||
}
|
||||
NavManager.NavigateTo(pageHistoryState.GetGoBackPage()!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,13 @@ namespace TIAMWebApp.Server.Controllers
|
|||
return await _adminDal.GetTransferDestinationsAsync();
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
[SignalR(SignalRTags.GetAllTransferDestinationsByProductId)]
|
||||
public async Task<List<TransferDestination>> GetPublicTransferDestinations(Guid includeProductId)
|
||||
{
|
||||
return await _adminDal.GetPublicTransferDestinationsAsync(includeProductId);
|
||||
}
|
||||
|
||||
//[Authorize]
|
||||
//[HttpGet]
|
||||
//[Route(APIUrls.GetTransferDriversByTransferIdRouteName)]
|
||||
|
|
|
|||
|
|
@ -127,9 +127,15 @@ namespace TIAMWebApp.Shared.Application.Services
|
|||
public async Task<List<TransferDestination>> GetTransferDestinations()
|
||||
=> await GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations) ?? [];
|
||||
|
||||
public Task GetTransferDestinationsInto(List<TransferDestination> intoDestinationList, Action? callback = null)
|
||||
|
||||
public Task GetTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Action? callback = null)
|
||||
=> GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinations, null, callback);
|
||||
|
||||
public async Task<List<TransferDestination>> GetPublicTransferDestinations(Guid includeProductId)
|
||||
=> await GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId]) ?? [];
|
||||
|
||||
public Task GetPublicTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Guid includeProductId, Action? callback = null)
|
||||
=> GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId], callback);
|
||||
|
||||
public async Task<TransferDestination?> GetTransferDestinationById(Guid transferDestinationId)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Net;
|
||||
using TIAM.Core.Enums;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Models;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
|
|
@ -23,7 +24,7 @@ public abstract class SessionServiceClientBase : ISessionService
|
|||
|
||||
public virtual List<Product> GetHotels()
|
||||
{
|
||||
return User != null ? User.UserModelDto.Products.Where(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel).ToList() : [];
|
||||
return User != null ? User.UserModelDto.Products.Where(x => x.ProductType == ProductType.Hotel).ToList() : [];
|
||||
}
|
||||
|
||||
public virtual void ClearAll()
|
||||
|
|
|
|||
|
|
@ -8,32 +8,24 @@ namespace TIAMWebApp.Shared.Application.Utility
|
|||
{
|
||||
public class PageHistoryState
|
||||
{
|
||||
private List<string> previousPages;
|
||||
private readonly List<string> _previousPages = [];
|
||||
|
||||
public PageHistoryState()
|
||||
{ }
|
||||
|
||||
public void AddPageToHistory(string pageUrl)
|
||||
{
|
||||
previousPages = new List<string>();
|
||||
}
|
||||
public void AddPageToHistory(string pageName)
|
||||
{
|
||||
previousPages.Add(pageName);
|
||||
_previousPages.Add(pageUrl);
|
||||
}
|
||||
|
||||
public string GetGoBackPage()
|
||||
{
|
||||
if (previousPages.Count > 1)
|
||||
{
|
||||
// You add a page on initialization, so you need to return the 2nd from the last
|
||||
return previousPages.ElementAt(previousPages.Count - 2);
|
||||
}
|
||||
|
||||
// Can't go back because you didn't navigate enough
|
||||
return previousPages.FirstOrDefault();
|
||||
return _previousPages.Count > 1 ? _previousPages[^2] : _previousPages.FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
public bool CanGoBack()
|
||||
{
|
||||
return previousPages.Count > 1;
|
||||
return _previousPages.Count > 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue