work in progress commit

This commit is contained in:
Adam 2024-07-14 01:21:36 +02:00
parent 8a0b370dd7
commit 57bacdc5f8
19 changed files with 484 additions and 110 deletions

View File

@ -5,4 +5,5 @@ public enum ProductType : byte
NotDefined = 0, NotDefined = 0,
Transfer = 5, Transfer = 5,
Hotel = 10, Hotel = 10,
Guide = 15,
} }

View File

@ -57,6 +57,7 @@ namespace TIAM.Database.DataLayers.Admins
public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList()); public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<List<Transfer>> GetTransfersByDriverUserIdAsync(Guid driverUserId) => SessionAsync(ctx => ctx.GetTransfersByDriverUserId(driverUserId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList()); public Task<List<Transfer>> GetTransfersByDriverUserIdAsync(Guid driverUserId) => SessionAsync(ctx => ctx.GetTransfersByDriverUserId(driverUserId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<List<Transfer>> GetTransfersByProductIdAsync(Guid productId) => SessionAsync(ctx => ctx.GetTransfersByProductId(productId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<List<Transfer>> GetTransfersByUserProductMappingIdAsync(Guid userProductMappingId) => SessionAsync(ctx => ctx.GetTransfersByUserProductMappingId(userProductMappingId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList()); public Task<List<Transfer>> GetTransfersByUserProductMappingIdAsync(Guid userProductMappingId) => SessionAsync(ctx => ctx.GetTransfersByUserProductMappingId(userProductMappingId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<List<Transfer>> GetTransfersAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList()); public Task<List<Transfer>> GetTransfersAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());

View File

@ -50,6 +50,9 @@ public static class TransferDbSetExtensions
public static IQueryable<Transfer> GetTransfersByDriverUserId(this ITransferDbSet ctx, Guid driverUserId) public static IQueryable<Transfer> GetTransfersByDriverUserId(this ITransferDbSet ctx, Guid driverUserId)
=> ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMapping.UserId == driverUserId)); => ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMapping.UserId == driverUserId));
public static IQueryable<Transfer> GetTransfersByProductId(this ITransferDbSet ctx, Guid productId)
=> ctx.GetTransfers().Where(x => x.ProductId == productId);
public static IQueryable<Transfer> GetTransfersByUserProductMappingId(this ITransferDbSet ctx, Guid userProductMappingId) public static IQueryable<Transfer> GetTransfersByUserProductMappingId(this ITransferDbSet ctx, Guid userProductMappingId)
=> ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMappingId == userProductMappingId)); => ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMappingId == userProductMappingId));

View File

@ -12,6 +12,7 @@ public class SignalRTags : AcSignalRTags
public const int GetTransfersByProductId = 5; public const int GetTransfersByProductId = 5;
public const int GetTransfersByCompanyId = 6; public const int GetTransfersByCompanyId = 6;
public const int GetTransfersByUserProductMappingId = 701; public const int GetTransfersByUserProductMappingId = 701;
public const int GetTransfersByOrderingProductId = 702;
public const int GetTransfersByFilterText = 301; public const int GetTransfersByFilterText = 301;

View File

@ -1,5 +1,6 @@
using System.Net; using System.Net;
using TIAM.Core.Consts; using TIAM.Core.Consts;
using TIAM.Entities.Products;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models;
@ -17,6 +18,14 @@ namespace TIAMMobileApp.Services
public bool IsDriver { get; set; } = false; public bool IsDriver { get; set; } = false;
public bool IsDevAdmin { get; set; } = false; public bool IsDevAdmin { get; set; } = false;
public bool IsSysAdmin { get; set; } = false; public bool IsSysAdmin { get; set; } = false;
public List<Product> GetHotels()
{
if (User.UserModelDto.Products.Count > 0)
{
return User.UserModelDto.Products.Where(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel).ToList();
}
else return new List<Product>();
}
public Guid DriverPersmissionId { get; set; } = Guid.Empty; public Guid DriverPersmissionId { get; set; } = Guid.Empty;
} }

View File

@ -72,7 +72,7 @@
{ {
if (SessionService.User.UserModelDto.Products.Any(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel)) if (SessionService.User.UserModelDto.Products.Any(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel))
{ {
Hotels = SessionService.User.UserModelDto.Products.Where(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel).ToList(); Hotels = SessionService.GetHotels();
SelectedHotel = Hotels[0]; SelectedHotel = Hotels[0];
} }
} }

View File

@ -1,4 +1,4 @@
@page "/user/hoteladmin/{id}" @page "/user/hoteladmin/{id:guid}"
@using TIAMSharedUI.Shared @using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces; @using TIAMWebApp.Shared.Application.Interfaces;
@layout AdminLayout @layout AdminLayout
@ -15,7 +15,7 @@
<div class="container"> <div class="container">
<HotelComponent Id="@Guid.Parse(id)"></HotelComponent> <HotelComponent Id="@id"></HotelComponent>
<!-- Stats admin--> <!-- Stats admin-->
<hr /> <hr />
@ -24,7 +24,7 @@
@code { @code {
[Parameter] public string id { get; set; } [Parameter] public Guid id { get; set; }
bool isUserLoggedIn; bool isUserLoggedIn;
int userType = 0; int userType = 0;
@ -35,7 +35,7 @@
{ {
return; return;
} }
var check = SessionService.User.UserModelDto.UserProductMappings.Any(x => x.ProductId == Guid.Parse(id)); var check = SessionService.User.UserModelDto.UserProductMappings.Any(x => x.ProductId == id);
if (!check) if (!check)
{ {
return; return;

View File

@ -1,8 +1,15 @@
@using BlazorAnimation @using AyCode.Core
@using AyCode.Core.Extensions
@using BlazorAnimation
@using TIAM.Entities.Transfers
@using TIAMSharedUI.Pages.User.SysAdmins
@using TIAMSharedUI.Shared @using TIAMSharedUI.Shared
@using TIAMSharedUI.Shared.Components.Grids
@using TIAMWebApp.Shared.Application.Models; @using TIAMWebApp.Shared.Application.Models;
@using TIAMWebApp.Shared.Application.Interfaces; @using TIAMWebApp.Shared.Application.Interfaces;
@using TIAMSharedUI.Pages.User; @using TIAMSharedUI.Pages.User;
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
@using TIAM.Services
@ -41,9 +48,9 @@
</div> </div>
<div class="d-flex flex-column mb-4 pb-2"> <div class="d-flex flex-column mb-4 pb-2">
<h4> Hotel name: <span class="small text-muted"> Example hotel </span></h4> <h4> Hotel name: <span class="small text-muted"> @hotelName </span></h4>
<h4> Address: <span class="small text-muted"> Budapest, Minta u. 46 </span></h4> <h4> Address: <span class="small text-muted"> @hotelAddress </span></h4>
<h4> Phone number: <span class="small text-muted"> +36 1 123 4567</span></h4> <h4> Contact name: <span class="small text-muted"> @hotelContactName</span></h4>
</div> </div>
</div> </div>
<div class="card-footer py-2 px-4"> <div class="card-footer py-2 px-4">
@ -58,7 +65,7 @@
</div> </div>
</Animation> </Animation>
</div> </div>
<div class=" col-12 col-xl-3"> <div class=" col-12 col-xl-9">
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)"> <Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card glass card-admin" style="border-radius: 16px;"> <div class="card glass card-admin" style="border-radius: 16px;">
<div class="card-header py-2 px-4"> <div class="card-header py-2 px-4">
@ -75,19 +82,66 @@
<div class="card-body card-admin-body py-2 px-4"> <div class="card-body card-admin-body py-2 px-4">
<div class="d-flex flex-row mb-4 pb-2"> <div class="d-flex flex-row mb-4 pb-2">
<DxGrid Data="@OrderData"> <TransferGrid Logger="_logger"
<Columns> SignalRClient="adminSignalRClient"
<DxGridDataColumn FieldName="Date" DisplayFormat="D" MinWidth="100"> ContextIds="@(Id.IsNullOrEmpty() ? null : [Id])"
<CellDisplayTemplate> GetAllMessageTag="@SignalRTags.GetTransfersByOrderingProductId"
<a class="d-block text-left" href="transferdetails">@context.Value</a> CustomizeElement="Grid_CustomizeElement"
</CellDisplayTemplate> EditMode="GridEditMode.EditRow"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
PageSize="13"
ShowFilterRow="true"
DetailRowDisplayMode="GridDetailRowDisplayMode.Never">
<Columns>
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="AcDomain.IsDeveloperVersion" Width="80" MinWidth="80" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="OrderId" Caption="Order" SortIndex="1" SortOrder="GridColumnSortOrder.Descending" Width="70">
<CellDisplayTemplate>
@{
var idKeyField = ((Transfer)context.DataItem).Id.ToString("N");
var editUri = $"mytransfers/{idKeyField}";
<NavLink href="@editUri">
<text>@context.Value</text>
</NavLink>
}
</CellDisplayTemplate>
</DxGridDataColumn> </DxGridDataColumn>
<DxGridDataColumn FieldName="Income" Width="15%" />
<DxGridDataColumn FieldName="TransactionId" Width="15%" /> <DxGridDataColumn FieldName="Revenue" Caption="Revenue" Width="70" CaptionAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="Status" Width="10%" /> <DxGridDataColumn FieldName="FullName" />
<DxGridDataColumn FieldName="ContactPhone" Width="120" />
<DxGridDataColumn FieldName="ContactEmail" Width="120">
</DxGridDataColumn>
<DxGridDataColumn FieldName="PaymentId" DisplayFormat="N" Visible="false" />
<DxGridDataColumn Caption="Paid" FieldName="Paid" Width="75" TextAlignment="GridTextAlignment.Center" CaptionAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="TransferStatusType" Caption="Status" SortIndex="0" Width="120" SortOrder="GridColumnSortOrder.Ascending" SortMode="GridColumnSortMode.Value">
<CellDisplayTemplate>
@{
TransferStatusModel keyField = Statuses.FirstOrDefault(x => x.StatusValue == (byte)context.Value)!;
string transferStatusText = keyField.StatusName;
<text>@transferStatusText</text>
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="ReferralId" DisplayFormat="N" Visible="false" />
<DxGridDataColumn FieldName="Comment" Caption="Comment" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="125" Visible="false" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
</Columns> </Columns>
</DxGrid> <DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Messages">
<MessageDetailGridComponent ContextId="((Transfer)context.DataItem).Id" />
</DxTabPage>
<DxTabPage Text="Driver">
<TransferToDriverGridComponent ContextId="((Transfer)context.DataItem).Id" ParentData="(Transfer)context.DataItem" />
</DxTabPage>
</DxTabs>
</DetailRowTemplate>
</TransferGrid>
@ -109,7 +163,7 @@
</div> </div>
</Animation> </Animation>
</div> </div>
<div class=" col-12 col-xl-3"> <div class=" col-12 col-xl-6">
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)"> <Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card glass card-admin" style="border-radius: 16px;"> <div class="card glass card-admin" style="border-radius: 16px;">
<div class="card-header py-2 px-4"> <div class="card-header py-2 px-4">
@ -175,13 +229,13 @@
</Animation> </Animation>
</div> </div>
<div class=" col-12 col-xl-3"> <div class="col-12 col-xl-6" hidden="@accessDenied">
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)"> <Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card glass card-admin" style="border-radius: 16px;"> <div class="card glass card-admin" style="border-radius: 16px;">
<div class="card-header py-2 px-4"> <div class="card-header py-2 px-4">
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div> <div>
<span class="fw-bold text-body">Panel title</span> <span class="fw-bold text-body">Income</span>
<p class="text-muted mb-0">Subtitle</p> <p class="text-muted mb-0">Subtitle</p>
</div> </div>
<div> <div>
@ -191,30 +245,36 @@
</div> </div>
<div class="card-body card-admin-body py-2 px-4"> <div class="card-body card-admin-body py-2 px-4">
<div class="d-flex flex-row mb-4 pb-2"> <div class="d-flex flex-row mb-4 pb-2">
<div class="flex-fill"> <TransferGrid Logger="_logger"
<h5 class="bold">Some info</h5> SignalRClient="adminSignalRClient"
<p class="text-muted"> Budapest, Dózsa György út 35, 1146</p> ContextIds="@(Id.IsNullOrEmpty() ? null : [Id])"
</div> GetAllMessageTag="@SignalRTags.GetTransfersByOrderingProductId"
<div> ColumnResizeMode="GridColumnResizeMode.NextColumn"
<!--img class="align-self-center img-fluid" PageSize="13"
src="https://mdbcdn.b-cdn.net/img/Photos/Horizontal/E-commerce/Products/6.webp" width="250"--> ShowFilterRow="true"
DetailRowDisplayMode="GridDetailRowDisplayMode.Never">
<Columns>
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="OrderId" Caption="Order" SortIndex="1" SortOrder="GridColumnSortOrder.Descending" Width="70">
<CellDisplayTemplate>
@{
var idKeyField = ((Transfer)context.DataItem).Id.ToString("N");
var editUri = $"mytransfers/{idKeyField}";
<NavLink href="@editUri">
<text>@context.Value</text>
</NavLink>
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn Caption="Paid" FieldName="Paid" Width="75" TextAlignment="GridTextAlignment.Center" CaptionAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="Revenue" Caption="Revenue" Width="70" CaptionAlignment="GridTextAlignment.Center" />
</Columns>
</TransferGrid>
</div> </div>
</div> </div>
<ul id="progressbar-1" class="mx-0 mt-0 mb-5 px-0 pt-0 pb-4">
<li class="step0 active" id="step1">
<span style="margin-left: 22px; margin-top: 12px;">PLACED</span>
</li>
<li class="step0 active text-center" id="step2"><span>WAITING FOR PICK UP</span></li>
<li class="step0 text-muted text-end" id="step3">
<span style="margin-right: 22px;">FINISHED</span>
</li>
</ul>
<div class="d-flex flex-row mb-4 pb-2">
<h4> Some <span class="small text-muted"> conclusion </span></h4>
</div>
</div>
<div class="card-footer py-2 px-4"> <div class="card-footer py-2 px-4">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">

View File

@ -1,13 +1,15 @@
using Microsoft.AspNetCore.Components; using AyCode.Services.Loggers;
using SkiaSharp; using DevExpress.Blazor;
using System; using Microsoft.AspNetCore.Components;
using System.Buffers.Text; using System.Runtime.CompilerServices;
using System.Collections.Generic; using TIAM.Core.Enums;
using System.Linq; using TIAM.Entities.Products;
using System.Text; using TIAM.Services;
using System.Threading.Tasks;
using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models;
using TIAMWebApp.Shared.Application.Models.ClientSide.UI;
using TIAMWebApp.Shared.Application.Services;
using TIAMWebApp.Shared.Application.Utility;
namespace TIAMSharedUI.Pages.User.Hotels namespace TIAMSharedUI.Pages.User.Hotels
{ {
@ -17,6 +19,9 @@ namespace TIAMSharedUI.Pages.User.Hotels
[Parameter] [Parameter]
public Guid Id { get; set; } public Guid Id { get; set; }
[Parameter] public bool ShowSeriesPointMarkers { get; set; }
[Parameter] public bool ShowSeriesLabels { get; set; }
[Inject] [Inject]
ISupplierService SupplierService { get; set; } ISupplierService SupplierService { get; set; }
@ -26,6 +31,17 @@ namespace TIAMSharedUI.Pages.User.Hotels
[Inject] [Inject]
IServiceProviderDataService ServiceProviderDataService { get; set; } IServiceProviderDataService ServiceProviderDataService { get; set; }
[Inject]
AdminSignalRClient adminSignalRClient { get; set; }
[Inject]
IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; }
[Inject]
ISessionService SessionService { get; set; }
private LoggerClient<HotelComponent> _logger;
object? OrderData { get; set; } object? OrderData { get; set; }
object? AffiliateData { get; set; } object? AffiliateData { get; set; }
@ -33,8 +49,71 @@ namespace TIAMSharedUI.Pages.User.Hotels
public string ImageSource { get; set; } = ""; public string ImageSource { get; set; } = "";
public Guid productId { get; set; }
private Product? hotel;
private string hotelName;
private string hotelAddress = "No address set";
private string hotelContactName = "No contact name set yet";
private bool isProductAdmin;
private bool accessDenied = true;
protected override void OnParametersSet()
{
productId = Id;
base.OnParametersSet();
}
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_logger = new LoggerClient<HotelComponent>(LogWriters.ToArray());
hotel = await adminSignalRClient.GetByIdAsync<Product>(SignalRTags.GetProductById, Id);
if (hotel != null)
{
if (hotel.Name != null)
{
hotelName = hotel.Name;
}
if (hotel.Profile != null)
{
if (hotel.Profile.Address != null)
{
if (string.IsNullOrEmpty(hotel.Profile.Address.AddressText))
{
hotelAddress = hotel.Profile.Address.AddressText;
}
else
{
hotelAddress = "Address is empty";
}
}
else
{
hotelAddress = "No address found";
}
if (hotel.Profile.FullName != null)
{
hotelContactName = hotel.Profile.FullName;
}
else
{
hotelContactName = "No contact name has been set yet";
}
}
else
{
hotelAddress = "No profile found";
}
}
//TEMPORARY
isProductAdmin = SessionService.User.UserModelDto.UserProductMappings.Any(m => m.ProductId == Id && m.Permissions == 1);
accessDenied = !isProductAdmin;
_logger.Debug($"{hotel.Name}, {isProductAdmin}");
base.OnInitialized(); base.OnInitialized();
OrderData = new object[] OrderData = new object[]
@ -101,9 +180,60 @@ namespace TIAMSharedUI.Pages.User.Hotels
}); });
//SKBitmap bitmap = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid()); //SKBitmap bitmap = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid());
ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid()); ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Id);
} }
[Parameter] public bool ShowSeriesPointMarkers { get; set; }
[Parameter] public bool ShowSeriesLabels { get; set; } void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{
try
{
if (e.ElementType == GridElementType.HeaderCell)
{
e.Style = "background-color: rgba(0, 0, 0, 0.08)";
e.CssClass = "header-bold";
}
if (e.ElementType != GridElementType.DataRow) return;
var transferStatus = e.Grid?.GetRowValue(e.VisibleIndex, "TransferStatusType");
if (transferStatus == null) return;
var transferStatusByte = (byte)transferStatus;
switch (transferStatusByte)
{
case 5:
e.CssClass = "bg-important";
break;
case > 5 and < 35:
e.CssClass = "bg-attention";
break;
case 35:
e.CssClass = "bg-finished";
break;
case > 35:
e.CssClass = "bg-cancel";
break;
}
}
catch (Exception ex)
{
_logger.Error($"Grid_CustomizeElement; {ex.Message}", ex);
}
}
private static readonly List<TransferStatusModel> Statuses =
[
new(Convert.ToByte(TransferStatusType.OrderSubmitted), "Order submitted"),
new(Convert.ToByte(TransferStatusType.OrderConfirmed), "Order confirmed"),
new(Convert.ToByte(TransferStatusType.AssignedToDriver), "Assigned to driver"),
new(Convert.ToByte(TransferStatusType.DriverConfirmed), "Driver confirmed"),
new(Convert.ToByte(TransferStatusType.DriverEnRoute), "Driver enroute"),
new(Convert.ToByte(TransferStatusType.PassengerPickup), "Passenger in car"),
new(Convert.ToByte(TransferStatusType.Finished), "Finished"),
new(Convert.ToByte(TransferStatusType.UserCanceled), "User cancelled"),
new(Convert.ToByte(TransferStatusType.AdminDenied), "Admin cancelled")
];
} }
} }

View File

@ -3,6 +3,7 @@
@using TIAM.Entities.ServiceProviders @using TIAM.Entities.ServiceProviders
@using TIAM.Resources @using TIAM.Resources
@using TIAM.Services @using TIAM.Services
@using TIAMSharedUI.Pages.User.SysAdmins
@using TIAMSharedUI.Shared @using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces @using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@ -45,7 +46,7 @@
GetAllMessageTag="SignalRTags.GetCompaniesByContextId" GetAllMessageTag="SignalRTags.GetCompaniesByContextId"
PageSize="12" PageSize="12"
ValidationEnabled="false" ValidationEnabled="false"
DetailRowDisplayMode="GridDetailRowDisplayMode.Always" DetailRowDisplayMode="GridDetailRowDisplayMode.Auto"
CustomizeEditModel="Grid_CustomizeEditModel" CustomizeEditModel="Grid_CustomizeEditModel"
EditMode="GridEditMode.EditRow"> EditMode="GridEditMode.EditRow">
<Columns> <Columns>
@ -65,6 +66,14 @@
@{ @{
<p>Address: @(((Company)context.DataItem).Profile.Address.AddressText)</p> <p>Address: @(((Company)context.DataItem).Profile.Address.AddressText)</p>
} }
<DxTabs>
<DxTabPage Text="Products">
<ProductDetailGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ParentData="(Company)context.DataItem" ContextId="((Company)context.DataItem).Id" />
</DxTabPage>
</DxTabs>
</DetailRowTemplate> </DetailRowTemplate>
</CompanyGrid> </CompanyGrid>
</div> </div>

View File

@ -44,12 +44,45 @@
<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">
<CellDisplayTemplate>
@{
Product product = (Product)context.DataItem;
if (product.ProductType == TIAM.Core.Enums.ProductType.Hotel)
{
<a class="btn btn-primary" href="user/hoteladmin/@context.Value">Manage hotel</a>
}
else if (product.ProductType == TIAM.Core.Enums.ProductType.Transfer)
{
<a class="btn btn-primary" href="user/transferadmin/@context.Value">Manage transfer service </a>
}
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="100" /> <DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="100" />
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductDescription) FieldName="Description" /> <DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductDescription) FieldName="Description" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{
//check if has transferdestination
var AddressId = ((Product)context.DataItem).Profile.AddressId;
var result = CheckDestinations(AddressId);
//if not, display button
if(!result)
{ <p>Address:</p>
<p>@(((Product)context.DataItem).Profile.Address.AddressText)</p>
<DxButton Click="() => SaveAsDestination(((Product)context.DataItem).Profile.Address, (Product)context.DataItem)" Text="Save as destination" RenderStyle="ButtonRenderStyle.Primary" />
}
else
{
<p>Address:</p>
<p>@(((Product)context.DataItem).Profile.Address.AddressText)</p>
}
}
<DxTabs> <DxTabs>
<DxTabPage Text="Permissions"> <DxTabPage Text="Permissions">
<UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Never" ContextIds="new [] {((Product)context.DataItem).Id}" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"> <UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Never" ContextIds="new [] {((Product)context.DataItem).Id}" GetAllTag="SignalRTags.GetUserProductMappingsByProductId">
@ -94,6 +127,8 @@
[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;
private List<TransferDestination>? destinations = null;
private ProductDetailGrid _productGrid = null!; private ProductDetailGrid _productGrid = null!;
private LoggerClient<ProductDetailGridComponent> _logger = null!; private LoggerClient<ProductDetailGridComponent> _logger = null!;
protected override void OnInitialized() protected override void OnInitialized()
@ -103,6 +138,53 @@
} }
private bool CheckDestinations(Guid addressId)
{
if(destinations!=null)
{
if (destinations.Any(d => d.AddressId == addressId))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
private async Task SaveAsDestination(Address address, Product product)
{
TransferDestination transferDestination = new TransferDestination();
transferDestination.Id = Guid.NewGuid();
transferDestination.Name = product.Name;
if (!string.IsNullOrEmpty(product.Profile.Description))
{
transferDestination.Description = product.Profile.Description;
}
else
{
transferDestination.Description = "No description available";
}
transferDestination.AddressId = address.Id;
transferDestination.AddressString = address.AddressText;
var result = await AdminSignalRClient.PostDataAsync<TransferDestination>(SignalRTags.CreateTransferDestination, transferDestination);
_productGrid.Reload();
}
protected override async Task OnInitializedAsync()
{
destinations = await AdminSignalRClient.GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations);
await base.OnInitializedAsync();
}
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
// if (ParentData != null) // if (ParentData != null)

View File

@ -13,7 +13,7 @@
@using Address = TIAM.Entities.Addresses.Address @using Address = TIAM.Entities.Addresses.Address
@using Profile = TIAM.Entities.Profiles.Profile @using Profile = TIAM.Entities.Profiles.Profile
@using TIAMSharedUI.Shared.Components.Grids @using TIAMSharedUI.Shared.Components.Grids
@using TIAMSharedUI.Pages.Components.EditComponents
@using TIAMWebApp.Shared.Application.Services @using TIAMWebApp.Shared.Application.Services
@using AyCode.Interfaces.Addresses @using AyCode.Interfaces.Addresses
@using AyCode.Core @using AyCode.Core
@ -38,7 +38,21 @@
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N"/> <DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N"/>
<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 FieldName="Id" Width="180">
<CellDisplayTemplate>
@{
Product product = (Product)context.DataItem;
if (product.ProductType==TIAM.Core.Enums.ProductType.Hotel)
{
<a class="btn btn-primary" href="user/hoteladmin/@context.Value">Manage hotel</a>
}
else if (product.ProductType == TIAM.Core.Enums.ProductType.Transfer)
{
<a class="btn btn-primary" href="user/transferadmin/@context.Value">Manage transfer service </a>
}
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductType) FieldName="ProductType" Width="130" /> <DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductType) FieldName="ProductType" Width="130" />
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="100" /> <DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="100" />
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductDescription) FieldName="Description" /> <DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductDescription) FieldName="Description" />

View File

@ -6,6 +6,8 @@ namespace TIAMSharedUI.Shared.Components.Grids;
public class TransferGrid : TiamGrid<Transfer> public class TransferGrid : TiamGrid<Transfer>
{ {
public TransferGrid() : base() public TransferGrid() : base()
{ {
GetAllMessageTag = SignalRTags.GetTransfersByFilterText;//SignalRTags.GetTransfers; GetAllMessageTag = SignalRTags.GetTransfersByFilterText;//SignalRTags.GetTransfers;

View File

@ -100,7 +100,7 @@
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<AuthorizeView> @* <AuthorizeView>
<Authorized> <Authorized>
@if(hasProperty) @if(hasProperty)
{ {
@ -117,7 +117,7 @@
} }
</Authorized> </Authorized>
</AuthorizeView> </AuthorizeView> *@
@if(enableLogin) @if(enableLogin)
{ {
if (!myUser && enableLogin) if (!myUser && enableLogin)

View File

@ -19,11 +19,12 @@
DisplayMode="DisplayMode"> DisplayMode="DisplayMode">
<Items> <Items>
<DxMenuItem NavigateUrl="/" Text="Home" IconCssClass="menu-icon-home menu-icon" /> <DxMenuItem NavigateUrl="/" Text="Home" IconCssClass="menu-icon-home menu-icon" />
<DxMenuItem NavigateUrl="user/properties" Text="My companies" IconCssClass="menu-icon-home menu-icon" /> <DxMenuItem NavigateUrl="user/properties" Text="My companies" IconCssClass="fa-solid fa-building" />
<DxMenuItem NavigateUrl="user/createAndManageTransfer" IconCssClass="fa-solid fa-route" Text="Transfer" />
<DxMenuItem NavigateUrl="user/media" Text="Media" IconCssClass="menu-icon-home menu-icon" /> <DxMenuItem NavigateUrl="user/media" Text="Media" IconCssClass="menu-icon-home menu-icon" />
<DxMenuItem NavigateUrl="user/messages" Text="Media" IconCssClass="menu-icon-home menu-icon" /> <DxMenuItem NavigateUrl="user/messages" Text="Messages" IconCssClass="fa-solid fa-envelope" />
<DxMenuItem Text="Driver" Visible="@IsDriver" IconCssClass="menu-icon-products menu-icon"> <DxMenuItem Text="Driver" Visible="@IsDriver" IconCssClass="fa-solid fa-id-card">
<Items> <Items>
<DxMenuItem NavigateUrl="driver/dashboard" Text="Dashboard" /> <DxMenuItem NavigateUrl="driver/dashboard" Text="Dashboard" />
@ -38,7 +39,7 @@
</Items> </Items>
</DxMenuItem> </DxMenuItem>
<DxMenuItem Text="SysAdmin" Visible="@IsSysAdmin" IconCssClass="menu-icon-products menu-icon"> <DxMenuItem Text="SysAdmin" Visible="@IsSysAdmin" IconCssClass="fa-solid fa-unlock-keyhole">
<Items> <Items>
<DxMenuItem NavigateUrl="user/sysadmin" Text="Dashboard" /> <DxMenuItem NavigateUrl="user/sysadmin" Text="Dashboard" />
<DxMenuItem NavigateUrl="sysadmin/transfers" Text="Transfers" /> <DxMenuItem NavigateUrl="sysadmin/transfers" Text="Transfers" />
@ -54,18 +55,41 @@
</Items> </Items>
</DxMenuItem> </DxMenuItem>
<DxMenuItem Text="DevAdmin" Visible="@IsDevAdmin" IconCssClass="menu-icon-products menu-icon"> <DxMenuItem Text="DevAdmin" Visible="@IsDevAdmin" IconCssClass="fa-solid fa-shield-halved">
<Items> <Items>
<DxMenuItem NavigateUrl="sysadmin/logs" Text="Logs" /> <DxMenuItem NavigateUrl="sysadmin/logs" Text="Logs" />
</Items> </Items>
</DxMenuItem> </DxMenuItem>
<DxMenuItem Text="HotelAdmin" IconCssClass="menu-icon-support menu-icon"> <!--DxMenuItem Text="HotelAdmin" IconCssClass="menu-icon-support menu-icon">
<Items> <Items>
<DxMenuItem NavigateUrl="user/hoteladmin" Text="Dashboard" /> <DxMenuItem NavigateUrl="user/hoteladmin/" Text="Dashboard" />
<DxMenuItem NavigateUrl="user/createAndManageTransfer" Text="Transfers" /> <DxMenuItem NavigateUrl="user/createAndManageTransfer" Text="Transfers" />
<DxMenuItem NavigateUrl="user/serviceprovider/5453-a87f77787d-khj899" Text="Manage hotel" /> <DxMenuItem NavigateUrl="user/serviceprovider/5453-a87f77787d-khj899" Text="Manage hotel" />
</Items> </Items>
</DxMenuItem-->
<DxMenuItem CssClass="notoggle" Position="ItemPosition.End">
<TextTemplate>
<div class="fa-solid fa-user" />
</TextTemplate>
<SubMenuTemplate>
<div class="w-100 user-profile p-3">
<div class="flex-column align-items-center justify-content-center">
<div class="logo-container d-flex align-items-center justify-content-center">
<div class="menu-icon-large">
<i class="fa-solid fa-user"></i>
</div>
</div>
<div class="user-name-container bm-3 mb-2">
<div class="tm-8 text-center">@SessionService.User.Email</div>
<div class="text-center">@SessionService.User.UserModelDto.ProfileDto.FullName</div>
</div>
<div class="d-flex justify-content-center log-off-btn">
<DxButton Text="Log Off" RenderStyle="@ButtonRenderStyle.Secondary"></DxButton>
</div>
</div>
</div>
</SubMenuTemplate>
</DxMenuItem> </DxMenuItem>
</Items> </Items>
</DxMenu> </DxMenu>

View File

@ -1,4 +1,5 @@
using System.Net; using System.Net;
using TIAM.Entities.Products;
using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models;
@ -15,6 +16,15 @@ namespace TIAMWebApp.Client.Services
public bool IsDevAdmin { get; set; } = false; public bool IsDevAdmin { get; set; } = false;
public bool IsSysAdmin { get; set; } = false; public bool IsSysAdmin { get; set; } = false;
public List<Product> GetHotels()
{
if(User.UserModelDto.Products.Count > 0)
{
return User.UserModelDto.Products.Where(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel).ToList();
}
else return new List<Product>();
}
public Guid DriverPersmissionId { get; set; } = Guid.Empty; public Guid DriverPersmissionId { get; set; } = Guid.Empty;
} }
} }

View File

@ -30,6 +30,7 @@ using DevExpress.Data.Linq.Helpers;
using System; using System;
using TIAM.Database.DbSets.Transfers; using TIAM.Database.DbSets.Transfers;
using TIAM.Services.Interfaces; using TIAM.Services.Interfaces;
using TIAM.Entities.Products;
namespace TIAMWebApp.Server.Controllers namespace TIAMWebApp.Server.Controllers
{ {
@ -485,10 +486,25 @@ namespace TIAMWebApp.Server.Controllers
var from = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.FromAddress); var from = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.FromAddress);
var to = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.ToAddress); var to = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.ToAddress);
Product? product = null;
//TODO //TODO
if (!transfer.ProductId.IsNullOrEmpty()) if (!transfer.ProductId.IsNullOrEmpty())
{
product = await _adminDal.GetProductByIdAsync((Guid)transfer.ProductId);
transfer.Price = _transferBackendService.GetTransferPrice(transfer.ProductId.Value, from, to, transfer.PassengerCount); transfer.Price = _transferBackendService.GetTransferPrice(transfer.ProductId.Value, from, to, transfer.PassengerCount);
}
if(transfer.Price != null && transfer.Price > 0 && product != null)
{
if(product.ServiceProvider.CommissionPercent!=null)
{
transfer.Revenue = transfer.Price * product.ServiceProvider.CommissionPercent;
}
else
{
transfer.Revenue=0;
}
}
transfer.TransferStatusType = TransferStatusType.OrderSubmitted; transfer.TransferStatusType = TransferStatusType.OrderSubmitted;
@ -666,6 +682,16 @@ namespace TIAMWebApp.Server.Controllers
return result; return result;
} }
[NonAction]
[SignalR(SignalRTags.GetTransfersByOrderingProductId)]
public async Task<List<Transfer>> GetTransfersByProductId(Guid productId)
{
_logger.Debug($"GetTransfersByProductId called; productId: {productId}");
var result = await _adminDal.GetTransfersByProductIdAsync(productId);
return result;
}
[Authorize] [Authorize]
[HttpGet] [HttpGet]
[Route(APIUrls.GetTransfersByUserProductMappingIdRouteName)] [Route(APIUrls.GetTransfersByUserProductMappingIdRouteName)]

View File

@ -1,4 +1,5 @@
using System.Net; using System.Net;
using TIAM.Entities.Products;
using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models;
namespace TIAMWebApp.Shared.Application.Interfaces namespace TIAMWebApp.Shared.Application.Interfaces
@ -13,6 +14,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces
public bool IsDriver { get; set; } public bool IsDriver { get; set; }
public bool IsDevAdmin { get; set; } public bool IsDevAdmin { get; set; }
public bool IsSysAdmin { get; set; } public bool IsSysAdmin { get; set; }
public List<Product> GetHotels();
public Guid DriverPersmissionId { get; set; } public Guid DriverPersmissionId { get; set; }
} }
} }

View File

@ -206,7 +206,7 @@ namespace TIAMWebApp.Shared.Application.Services
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
var result = await response.Content.ReadAsStringAsync(); var result = await response.Content.ReadAsStringAsync();
_logger.Debug("SKBitmap width: " + result);
return result; return result;
} }
else else