240 lines
7.7 KiB
C#
240 lines
7.7 KiB
C#
using AyCode.Services.Loggers;
|
|
using DevExpress.Blazor;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Runtime.CompilerServices;
|
|
using TIAM.Core.Enums;
|
|
using TIAM.Entities.Products;
|
|
using TIAM.Services;
|
|
using TIAMWebApp.Shared.Application.Interfaces;
|
|
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
|
|
{
|
|
public partial class HotelComponent : ComponentBase
|
|
{
|
|
|
|
[Parameter]
|
|
public Guid Id { get; set; }
|
|
|
|
[Parameter] public bool ShowSeriesPointMarkers { get; set; }
|
|
[Parameter] public bool ShowSeriesLabels { get; set; }
|
|
|
|
[Inject]
|
|
ISupplierService SupplierService { get; set; }
|
|
|
|
[Inject]
|
|
IUserDataService UserDataService { get; set; }
|
|
|
|
[Inject]
|
|
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? AffiliateData { get; set; }
|
|
|
|
object? Data { 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()
|
|
{
|
|
_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();
|
|
|
|
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"
|
|
},
|
|
};
|
|
|
|
AffiliateData = new object[]
|
|
{
|
|
new {
|
|
AffiliateId = 1,
|
|
IncomeThisMonth = "$5",
|
|
IncomeAlltime = "9425",
|
|
CompanyName = "Upgen Ltd.",
|
|
Status = "Active"
|
|
},
|
|
new {
|
|
AffiliateId = 2,
|
|
IncomeThisMonth = "$538",
|
|
IncomeAlltime = "13425",
|
|
CompanyName = "Kovacs hotel Ltd.",
|
|
Status = "Active"
|
|
},
|
|
new {
|
|
AffiliateId = 3,
|
|
IncomeThisMonth = "$0",
|
|
IncomeAlltime = "134200",
|
|
CompanyName = "Innosaurus Ltd.",
|
|
Status = "Passive"
|
|
},
|
|
};
|
|
|
|
|
|
var suppliers = await SupplierService.GetSuppliersAsync();
|
|
Data = suppliers.Select(s =>
|
|
{
|
|
return new
|
|
{
|
|
s.CompanyName,
|
|
s.ContactName,
|
|
s.ContactTitle,
|
|
s.Country,
|
|
s.City,
|
|
s.Address,
|
|
s.Phone
|
|
};
|
|
});
|
|
|
|
//SKBitmap bitmap = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid());
|
|
ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Id);
|
|
}
|
|
|
|
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")
|
|
];
|
|
}
|
|
}
|