This commit is contained in:
Loretta 2024-06-24 14:00:03 +02:00
commit 2847f3ad2f
30 changed files with 1693 additions and 127 deletions

View File

@ -33,6 +33,7 @@ namespace TIAM.Database.DataLayers.Admins
}
#region Car
public Task<List<Car>> GetAllCarsAsync() => SessionAsync(ctx => ctx.Cars.OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList());
public Car? GetCarById(Guid carId) => Session(ctx => ctx.Cars.FirstOrDefault(x => x.Id == carId));
public List<Car> GetCarByUserProductMappingId(Guid userProductMappingId) => Session(ctx => ctx.Cars.Where(x => x.UserProductMappingId == userProductMappingId).ToList());
public Task<bool> AddCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Add(car).State == EntityState.Added);
@ -128,6 +129,7 @@ namespace TIAM.Database.DataLayers.Admins
public Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId));
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public List<UserProductMapping>? GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList();
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public List<PermissionContextMapping> GetPermissionContextsView(Guid subjectId, Guid contextId)

View File

@ -46,14 +46,19 @@ public class SignalRTags : AcSignalRTags
//public const int AddAddress = 39;
//public const int RemoveAddress = 40;
public const int CreateUserProductMapping = 47;
public const int UpdateUserProductMapping = 48;
public const int DeleteUserProductMapping = 49; //set permissions to 0
public const int CreateUserProductMapping = 40;
public const int UpdateUserProductMapping = 41;
public const int DeleteUserProductMapping = 42; //set permissions to 0
public const int GetAllUserProductMappings = 43;
public const int GetUserProductMappingsByProductId = 44;
public const int GetUserProductMappingsByUserId = 45;
public const int GetUserProductMappingById = 46;
public const int GetCarsForUserProductMapping = 50;
public const int CreateCar = 51;
public const int UpdateCar = 52;
public const int DeleteCar = 53;
public const int GetAllCars = 54;
public const int GetMessagesByContextId = 60;
public const int GetAllMessages = 61;
@ -67,4 +72,5 @@ public class SignalRTags : AcSignalRTags
public const int UpdateProduct = 73;
public const int AddProduct = 74;
public const int RemoveProduct = 75;
public const int GetProductsById = 76;
}

View File

@ -26,46 +26,47 @@
<div class="container">
<div class="w-100 ch-220">
<CompanyGrid @ref="_gridCompany"
Logger="_logger"
SignalRClient="AdminSignalRClient"
AutoCollapseDetailRow="false"
KeyboardNavigationEnabled="true"
CustomizeElement="Grid_CustomizeElement"
CustomizeEditModel="Grid_CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true"
KeyFieldName="Id">
<CompanyByIdDetailGrid @ref="_gridCompany"
Context="myContext"
ContextIds="@CompanyId"
Logger="_logger"
SignalRClient="AdminSignalRClient"
AutoCollapseDetailRow="false"
KeyboardNavigationEnabled="true"
CustomizeElement="Grid_CustomizeElement"
CustomizeEditModel="Grid_CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true"
KeyFieldName="Id">
<Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="Name" />
<DxGridDataColumn FieldName="AffiliateId" DisplayFormat="N" />
<DxGridDataColumn FieldName="CommissionPercent" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" />
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" />
@* <DxGridDataColumn FieldName="ContactEmail">
</DxGridDataColumn> *@
</DxGridDataColumn> *@
</Columns>
@* <DetailRowTemplate>
<CompaniesNestedUserProductMapping CurrentCompany="(TIAM.Entities.ServiceProviders.Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DetailRowTemplate> *@
<CompaniesNestedUserProductMapping CurrentCompany="(TIAM.Entities.ServiceProviders.Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DetailRowTemplate> *@
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Profile">
<ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
<ProfileGridComponent ParentData="((Company)myContext.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Products">
<ProductDetailGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
<ProductDetailGridComponent ParentData="((Company)myContext.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />
<AddressDetailGridComponent ParentData="((Company)myContext.DataItem).Profile" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
</DetailRowTemplate>
@ -82,32 +83,21 @@
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</CompanyGrid>
<DxTabs>
@* <DxTabPage Text="Profile">
<ProfileComponent></ProfileComponent>
</DxTabPage> *@
@* <DxTabPage Text="Profile 2">
<ProfileGridComponent ProfileId="((Company)context.DataItem).ProfileId" KeyboardNavigationEnabled="true" />
</DxTabPage> *@
<DxTabPage Text="Products">
<ProductDetailGridComponent ContextId="@CompanyId" KeyboardNavigationEnabled="true" />
</DxTabPage>
@* <DxTabPage Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />
</DxTabPage> *@
</DxTabs>
</CompanyByIdDetailGrid>
</div>
</div>
@code {
[Parameter]
public string Id { get; set; }
private Guid CompanyId;
private Guid[] CompanyId = new Guid[1];
private CompanyGrid _gridCompany;
private CompanyByIdDetailGrid _gridCompany;
public string ProfileUrl => $"/images/serviceprovider/{Id}.png";
@ -127,7 +117,7 @@
}
else
{
CompanyId = Guid.Parse(Id);
CompanyId[0] = Guid.Parse(Id);
}
base.OnParametersSet();
}

View File

@ -24,9 +24,7 @@
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditModelSaving="EditModelSaving"
DataItemDeleting="DataItemDeleting"
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">

View File

@ -0,0 +1,186 @@
@using TIAM.Entities.Products
@using TIAM.Entities.Transfers
@using TIAM.Entities.Drivers
@using TIAM.Entities.Users
@using TIAM.Models.Dtos.Users
@using TIAM.Services
@using TIAMSharedUI.Shared.Components.Grids
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Services
@using TIAMWebApp.Shared.Application.Utility
@using TIAM.Core.Loggers
@using AyCode.Core.Loggers
@using AyCode.Services.Loggers
@using AyCode.Core
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient
<CarDetailGrid Logger="_logger"
ContextIds="ContextIds"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserProductMappingId" />
<DxGridDataColumn FieldName="CountryCode"/>
<DxGridDataColumn FieldName="LicencePlate"/>
<DxGridDataColumn FieldName="Color"/>
<DxGridDataColumn FieldName="Manufacture"/>
<DxGridDataColumn FieldName="CarModel"/>
<DxGridDataColumn FieldName="YearOfMake"/>
<DxGridDataColumn FieldName="SeatNumber"/>
<DxGridDataColumn FieldName="CarMotorType"/>
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingById" ContextId="((Car)context.DataItem).UserProductMappingId" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
}
}
</DetailRowTemplate>
<EditFormTemplate Context="UserEditFormContext">
@{
var car = (Car)UserEditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Country code" ColSpanMd="4">
@UserEditFormContext.GetEditor("CountryCode")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("LicencePlate")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Color" ColSpanMd="4">
@UserEditFormContext.GetEditor("Color")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4">
@UserEditFormContext.GetEditor("Manufacture")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Car model" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarModel")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Year of make" ColSpanMd="4">
@UserEditFormContext.GetEditor("YearOfMake")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Seat number" ColSpanMd="4">
@UserEditFormContext.GetEditor("SeatNumber")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Motor type" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarMotorType")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</CarDetailGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars;
[Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<CarDetailGridComponent> _logger;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<CarDetailGridComponent>(LogWriters.ToArray());
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (e.IsNew)
{
var newCar = new Car
{
Id = Guid.NewGuid(),
UserProductMappingId = (Guid)ContextId,
CountryCode = 1,
LicencePlate = "ABC123",
Color = "White",
Manufacture = "Manufacturer",
CarModel = "Car model",
YearOfMake = DateTime.Now.Year,
SeatNumber = 5,
CarMotorType = TIAM.Core.Enums.CarMotorType.Electric
};
e.EditModel = newCar;
}
else
{
//
}
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
}

View File

@ -0,0 +1,171 @@
@using TIAM.Entities.Products
@using TIAM.Entities.Transfers
@using TIAM.Entities.Drivers
@using TIAM.Entities.Users
@using TIAM.Models.Dtos.Users
@using TIAM.Services
@using TIAMSharedUI.Shared.Components.Grids
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Services
@using TIAMWebApp.Shared.Application.Utility
@using TIAM.Core.Loggers
@using AyCode.Core.Loggers
@using AyCode.Services.Loggers
@using AyCode.Core
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient
<CarGrid Logger="_logger"
ContextIds="ContextIds"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserProductMappingId" />
<DxGridDataColumn FieldName="CountryCode"/>
<DxGridDataColumn FieldName="LicencePlate"/>
<DxGridDataColumn FieldName="Color"/>
<DxGridDataColumn FieldName="Manufacture"/>
<DxGridDataColumn FieldName="CarModel"/>
<DxGridDataColumn FieldName="YearOfMake"/>
<DxGridDataColumn FieldName="SeatNumber"/>
<DxGridDataColumn FieldName="CarMotorType"/>
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingById" ContextId="((Car)context.DataItem).UserProductMappingId" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
}
}
</DetailRowTemplate>
<EditFormTemplate Context="UserEditFormContext">
@{
var car = (Car)UserEditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Country code" ColSpanMd="4">
@UserEditFormContext.GetEditor("CountryCode")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("LicencePlate")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Color" ColSpanMd="4">
@UserEditFormContext.GetEditor("Color")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4">
@UserEditFormContext.GetEditor("Manufacture")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarModel")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("YearOfMake")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("SeatNumber")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarMotorType")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</CarGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars;
[Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<CarGridComponent> _logger;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<CarGridComponent>(LogWriters.ToArray());
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
// var newProductMapping = new UserProductMapping
// {
// ProductId = Guid.NewGuid(),
// UserId = UserModelDtoDetail.Id,
// Permissions = 1
// };
//e.EditModel = newProductMapping;
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
}

View File

@ -0,0 +1,297 @@
@using TIAM.Entities.Products
@using TIAM.Entities.Transfers
@using TIAM.Entities.Drivers
@using TIAM.Entities.Users
@using TIAM.Models.Dtos.Users
@using TIAM.Services
@using TIAMSharedUI.Shared.Components.Grids
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Services
@using TIAMWebApp.Shared.Application.Utility
@using TIAM.Core.Loggers
@using AyCode.Core.Loggers
@using AyCode.Services.Loggers
@using AyCode.Core
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient
@inject IWizardProcessor WizardProcessor
@inject IUserDataService UserDataService
<DxPopup CssClass="popup-demo-events"
@bind-Visible="@PopupVisible"
ShowFooter="true"
CloseOnEscape="true"
CloseOnOutsideClick="false"
ShowCloseButton="false"
HeaderText="Select driver"
Closing="SelectDriverPopupClosing"
Closed="SelectDriverPopupClosed">
<BodyContentTemplate>
<label for="emailID" class="demo-text mt-4 mb-1">
Put user email here
</label>
<DxMaskedInput @ref="emailInput"
@bind-Value="@Email"
CssClass="cw-320"
Mask="@EmailMask"
InputId="emailID"
MaskMode="MaskMode.RegEx" />
<DxButton @ref="button1" CssClass="popup-button my-1 ms-2" Visible="true" RenderStyle="ButtonRenderStyle.Primary" Text="Find user" Click="@FindUser" />
<div style="@errorCss" @ref="errorMessage"><p>User not found, type another email please</p></div>
<DxGrid Data="@FoundUsers" RowClick="@OnRowClick">
<Columns>
<DxGridDataColumn FieldName="Id" Caption="ID" />
</Columns>
</DxGrid>
</BodyContentTemplate>
<FooterContentTemplate Context="PopupContext">
<div class="popup-demo-events-footer">
<!--DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Primary" Text="OK" Click="Context.CloseCallback" /-->
<DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Secondary" Text="Cancel" Click="CancelCreateClick" />
</div>
</FooterContentTemplate>
</DxPopup>
<UserProductMappingDriverGrid Logger="_logger"
@ref="_driverGrid"
ContextIds="ContextIds"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeElement="Grid_CustomizeElement"
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" />
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Products">
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Cars">
<CarDetailGridComponent GetAllTag="SignalRTags.GetCarsForUserProductMapping" ContextId="((UserProductMapping)context.DataItem).Id" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
}
}
</DetailRowTemplate>
<EditFormTemplate Context="UserEditFormContext">
@{
var transfer2 = (UserProductMapping)UserEditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="UserId" ColSpanLg="6" ColSpanMd="12">
@transfer2.UserId
@{
var a = UserEditFormContext.GetEditor("UserId");
}
@* <DxButton Click="() => ShowPopup((UserProductMapping)UserEditFormContext.EditModel)" Context="ButtonContext">Select user</DxButton> *@
<DxButton Click="@(async (MouseEventArgs e) => await ShowPopup((UserProductMapping)UserEditFormContext.EditModel))" Context="ButtonContext">Select user</DxButton>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
@UserEditFormContext.GetEditor("Permissions")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</UserProductMappingDriverGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public IProductRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
[Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<UserProductMappingGridComponent> _logger;
List<Product> _availableProducts;
private UserProductMappingDriverGrid _driverGrid;
private UserProductMapping tempProductMapping;
bool PopupVisible { get; set; }
private DxMaskedInput<string> emailInput;
private DxButton button1;
private ElementReference errorMessage;
private string errorCss = "display: none;";
private List<UserModelDto> FoundUsers { get; set; } = new List<UserModelDto>();
private string Email { get; set; } = "email@email.com";
string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}";
UserModelDto ChosenUser = null;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
UserProductMapping newUPM = (UserProductMapping)e.EditModel;
newUPM.ProductId = (Guid)ContextId!;
var newProductMapping = new UserProductMapping
{
Id = Guid.NewGuid(),
ProductId = (Guid)ContextId,
Permissions = 2
};
//e.EditModel = newProductMapping;
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
async Task FindUser()
{
var userModelDto = await UserDataService.GetUserByEmailAsync(Email);
if (userModelDto != null)
{
ChosenUser = userModelDto;
FoundUsers.Add(ChosenUser);
emailInput.Enabled = false;
button1.Visible = false;
}
else
{
emailInput.Value = "email@email.com";
errorCss = "display: block";
}
}
void CancelCreateClick()
{
PopupVisible = false;
}
void SelectDriverPopupClosed()
{
//cancel clicked
}
void SelectDriverPopupClosing(PopupClosingEventArgs args)
{
//myModel = new TransferWizardModel();
}
public async Task SubmitForm(object result)
{
_logger.Info($"Submitted nested form: {result.GetType().FullName}");
}
public async Task ShowPopup(UserProductMapping emptyProductMapping)
{
tempProductMapping = emptyProductMapping;
PopupVisible = true;
}
private async Task OnUserSelected(Guid userId)
{
// Logic after the user is selected
await Task.Run(() => Console.WriteLine($"Selected User ID: {userId}"));
}
private async Task OnRowClick(GridRowClickEventArgs e)
{
await SelectUser((Guid)e.Grid.GetRowValue(e.VisibleIndex, "Id"));
}
private async Task SelectUser(Guid id)
{
PopupVisible = false;
tempProductMapping.UserId = id;
await OnUserSelected(id);
}
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{
if (e.ElementType == GridElementType.DataRow && (int)e.Grid.GetRowValue(e.VisibleIndex, "Permissions") == 1)
{
e.Style="display: none";
}
// else if (e.ElementType == GridElementType.HeaderCell)
// {
// e.Style = "background-color: rgba(0, 0, 0, 0.08); font-style=bold";
// }
}
}

View File

@ -0,0 +1,186 @@
@page "/sysadmin/cars"
@using BlazorAnimation
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAM.Services
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> Localizer
@inject ISessionService SessionService
@inject IWizardProcessor WizardProcessor
@inject IUserDataService UserDataService
<PageTitle>Car list</PageTitle>
<div class="text-center m-5">
<h1>Car list</h1>
<h2 style="font-size:small">Manage cars here!</h2>
</div>
<div class="container">
<div class="row">
<div class=" col-12">
<Animation Effect="@Effect.FadeInUp" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card">
<div class="d-flex flex-column mb-4 pb-2">
<div class="align-self-end pl-2 pb-2">
<DxButton Text="Column Chooser"
RenderStyle="ButtonRenderStyle.Secondary"
IconCssClass="btn-column-chooser"
Click="ColumnChooserButton_Click" />
</div>
<CarGridComponent ShowNestedRows="true" GetAllTag="SignalRTags.GetAllCars"></CarGridComponent>
</div>
</div>
</Animation>
</div>
<div class=" col-12 col-xl-6">
</div>
</div>
</div>
@code {
private LoggerClient<ManageUserProductMappings> _logger;
//public UserModelDtoDetail UserModelDtoDetail = new();
bool PopupVisible { get; set; }
IGrid Grid { get; set; }
//object? MasterGridData { get; set; }
bool AutoCollapseDetailRow { get; set; }
public List<string> IgnoreList =
[
"ReceiverEmailAddress",
"ReceiverId",
"SenderEmailAddress",
"SenderId",
"ContextId"
];
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{
if (e.ElementType == GridElementType.DataRow && e.VisibleIndex % 2 == 1)
{
e.CssClass = "bg-alt";
}
else if (e.ElementType == GridElementType.HeaderCell)
{
e.Style = "background-color: rgba(0, 0, 0, 0.08); font-style=bold";
}
}
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
var userEditModel = (UserModelDtoDetail)e.EditModel; //TODO not valid cast
userEditModel.Id = Guid.NewGuid();
userEditModel.UserDto = new UserDtoDetail
{
AffiliateId = Guid.NewGuid(),
EmailAddress = "",
PhoneNumber = ""
};
userEditModel.ProfileDto = new TIAM.Entities.Profiles.Profile
{
Name = "New user"
};
userEditModel.Products = [];
userEditModel.ServiceProviders = [];
userEditModel.UserProductMappings = [];
}
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
{
var userModelDtoDetail = ((UserModelDtoDetail)e.EditModel);
if (e.IsNew)
{
//add new orderData to orderData array
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());
registration.Email = userModelDtoDetail.UserDto.EmailAddress;
registration.PhoneNumber = userModelDtoDetail.UserDto.PhoneNumber;
registration.Password = password;
registration.ReferralId = null;
await UserDataService.CreateGuestUser(registration);
_logger.Info("New user created added");
}
else
{
_logger.Info("orderData updated at id " + userModelDtoDetail.Id);
//await transferDataService.UpdateTransferAsync((TransferWizardModel)e.EditModel);
//modify transferData where transferData.Id == e.EditModel.Id
}
//get transfer from TransferData by Id
// foreach (var transferToModify in (List<Transfer>)TransferData)
// {
// myModel = (Transfer)e.EditModel;
// if (transferToModify.Id == myModel.Id)
// {
// //transferToModify.Driver = myModel.Driver;
// }
// }
//TODO: ne a teljes grid-et refresh-eljük, elég lenne csak az adott sort! - J.
await UpdateDataAsync();
}
async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
//remove orderData from orderData array
_logger.Info("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<ManageUserProductMappings>(LogWriters.ToArray());
base.OnInitialized();
}
void ColumnChooserButton_Click()
{
Grid.ShowColumnChooser();
}
}

View File

@ -0,0 +1,78 @@
@page "/sysadmin/drivers"
@using BlazorAnimation
@using TIAM.Entities.Users
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAM.Services
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> Localizer
@inject ISessionService SessionService
<PageTitle>User permissions</PageTitle>
<div class="text-center m-5">
<h1>Drivers</h1>
<h2 style="font-size:small">Manage drivers here!</h2>
</div>
<div class="container">
<div class="row">
<div class=" col-12">
<Animation Effect="@Effect.FadeInUp" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card">
<div class="d-flex flex-column mb-4 pb-2">
<div class="align-self-end pl-2 pb-2">
<DxButton Text="Column Chooser"
RenderStyle="ButtonRenderStyle.Secondary"
IconCssClass="btn-column-chooser"
Click="ColumnChooserButton_Click" />
</div>
<DriverGridComponent ShowNestedRows="true" ContextId="Guid.Parse(TransferProductId)" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"></DriverGridComponent>
</div>
</div>
</Animation>
</div>
<div class=" col-12 col-xl-6">
</div>
</div>
</div>
@code {
private LoggerClient<ManageUserProductMappings> _logger;
//public UserModelDtoDetail UserModelDtoDetail = new();
private string TransferProductId = "814b5495-c2e9-4f1d-a73f-37cd5d353078";
IGrid Grid { get; set; }
//object? MasterGridData { get; set; }
bool AutoCollapseDetailRow { get; set; }
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<ManageUserProductMappings>(LogWriters.ToArray());
base.OnInitialized();
}
void ColumnChooserButton_Click()
{
Grid.ShowColumnChooser();
}
}

View File

@ -1,4 +1,6 @@
@page "/user/products"
@* Deprecated *@
@page "/user/products"
@using TIAM.Resources
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels

View File

@ -1,7 +1,8 @@
@page "/user/companies"
@page "/sysadmin/companies"
@using BlazorAnimation
@using TIAM.Entities.ServiceProviders
@using TIAM.Resources
@using TIAM.Services
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@ -27,8 +28,8 @@
<PageTitle>Admin - Companies</PageTitle>
<div class="text-center m-5">
<h1>Company management</h1>
<h2 style="font-size:small">Manage transfers here!</h2>
<h1>Partners</h1>
<h2 style="font-size:small">Manage partners here!</h2>
</div>
<DxPopup @bind-Visible="@_setOwnerPopupVisible"
@ -83,9 +84,9 @@
<Animation Effect="@Effect.Pulse" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card">
<CompanyGrid @ref="_gridCompany"
Logger="_logger"
SignalRClient="AdminSignalRClient"
AutoCollapseDetailRow="_autoCollapseDetailRow"
KeyboardNavigationEnabled="true"
CustomizeElement="Grid_CustomizeElement"
@ -133,11 +134,7 @@
<ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Products">
<ProductDetailGridComponent @ref="_productDetailGridComponent"
OnGridEditModelSaving="OnProductGridItemSaving"
ParentData="(Company)context.DataItem"
DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto"
KeyboardNavigationEnabled="true" />
<ProductDetailGridComponent @ref="_productDetailGridComponent" DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetProductsByOwnerId" OnGridEditModelSaving="OnProductGridItemSaving" ContextId="((Company)context.DataItem).Id" ParentData="(Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />
@ -201,7 +198,7 @@
DateTime StartDate { get; set; } = DateTime.Today;
DxSchedulerDataStorage _dataStorage = new();
void SendMail(Company item)
{
@ -228,7 +225,7 @@
var userModelDto = await userDataService.GetUserByEmailAsync(Email);
//overwrite ServiceProvider ownerid
//var target = await serviceProviderDataService.GetServiceProviderByIdAsync(CompanyToSetOwner.Id);
//var target = await serviceProviderDataService.GetServiceProviderByIdAsync(CompanyToSetOwner.Id);
if (_companyToSetOwner == null)
{
return null;
@ -325,7 +322,7 @@
{
_logger.Error($"OnProductGridItemSaving; company == null || company.OwnerId.IsNullOrEmpty(); company.OwnerId: {company?.OwnerId}");
return;
}
}
var product = ((Product)e.EditModel);

View File

@ -1,4 +1,4 @@
@page "/user/transfers"
@page "/sysadmin/transfers"
@using BlazorAnimation
@using TIAM.Core.Enums
@using TIAM.Entities.Emails
@ -121,6 +121,7 @@
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="PaymentId" DisplayFormat="N"/>
<DxGridDataColumn Caption="Paid" FieldName="Payed"/>
<DxGridDataColumn FieldName="FromAddress"/>
<DxGridDataColumn FieldName="ToAddress"/>
<DxGridDataColumn FieldName="Appointment" DisplayFormat="g" Width="140"/>
@ -187,6 +188,10 @@
@EditFormContext.GetEditor("PassengerCount")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Paid:" ColSpanMd="6">
@EditFormContext.GetEditor("Payed")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Status:" ColSpanMd="6">
@EditFormContext.GetEditor("TransferStatusType")
</DxFormLayoutItem>

View File

@ -0,0 +1,186 @@
@page "/sysadmin/userproductmappings"
@using BlazorAnimation
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAM.Services
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> Localizer
@inject ISessionService SessionService
@inject IWizardProcessor WizardProcessor
@inject IUserDataService UserDataService
<PageTitle>User permissions</PageTitle>
<div class="text-center m-5">
<h1>User permissions</h1>
<h2 style="font-size:small">Manage transfers here!</h2>
</div>
<div class="container">
<div class="row">
<div class=" col-12">
<Animation Effect="@Effect.FadeInUp" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card">
<div class="d-flex flex-column mb-4 pb-2">
<div class="align-self-end pl-2 pb-2">
<DxButton Text="Column Chooser"
RenderStyle="ButtonRenderStyle.Secondary"
IconCssClass="btn-column-chooser"
Click="ColumnChooserButton_Click" />
</div>
<UserProductMappingGridComponent ShowNestedRows="true" GetAllTag="SignalRTags.GetAllUserProductMappings"></UserProductMappingGridComponent>
</div>
</div>
</Animation>
</div>
<div class=" col-12 col-xl-6">
</div>
</div>
</div>
@code {
private LoggerClient<ManageUserProductMappings> _logger;
//public UserModelDtoDetail UserModelDtoDetail = new();
bool PopupVisible { get; set; }
IGrid Grid { get; set; }
//object? MasterGridData { get; set; }
bool AutoCollapseDetailRow { get; set; }
public List<string> IgnoreList =
[
"ReceiverEmailAddress",
"ReceiverId",
"SenderEmailAddress",
"SenderId",
"ContextId"
];
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{
if (e.ElementType == GridElementType.DataRow && e.VisibleIndex % 2 == 1)
{
e.CssClass = "bg-alt";
}
else if (e.ElementType == GridElementType.HeaderCell)
{
e.Style = "background-color: rgba(0, 0, 0, 0.08); font-style=bold";
}
}
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
var userEditModel = (UserModelDtoDetail)e.EditModel; //TODO not valid cast
userEditModel.Id = Guid.NewGuid();
userEditModel.UserDto = new UserDtoDetail
{
AffiliateId = Guid.NewGuid(),
EmailAddress = "",
PhoneNumber = ""
};
userEditModel.ProfileDto = new TIAM.Entities.Profiles.Profile
{
Name = "New user"
};
userEditModel.Products = [];
userEditModel.ServiceProviders = [];
userEditModel.UserProductMappings = [];
}
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
{
var userModelDtoDetail = ((UserModelDtoDetail)e.EditModel);
if (e.IsNew)
{
//add new orderData to orderData array
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());
registration.Email = userModelDtoDetail.UserDto.EmailAddress;
registration.PhoneNumber = userModelDtoDetail.UserDto.PhoneNumber;
registration.Password = password;
registration.ReferralId = null;
await UserDataService.CreateGuestUser(registration);
_logger.Info("New user created added");
}
else
{
_logger.Info("orderData updated at id " + userModelDtoDetail.Id);
//await transferDataService.UpdateTransferAsync((TransferWizardModel)e.EditModel);
//modify transferData where transferData.Id == e.EditModel.Id
}
//get transfer from TransferData by Id
// foreach (var transferToModify in (List<Transfer>)TransferData)
// {
// myModel = (Transfer)e.EditModel;
// if (transferToModify.Id == myModel.Id)
// {
// //transferToModify.Driver = myModel.Driver;
// }
// }
//TODO: ne a teljes grid-et refresh-eljük, elég lenne csak az adott sort! - J.
await UpdateDataAsync();
}
async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
//remove orderData from orderData array
_logger.Info("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<ManageUserProductMappings>(LogWriters.ToArray());
base.OnInitialized();
}
void ColumnChooserButton_Click()
{
Grid.ShowColumnChooser();
}
}

View File

@ -1,4 +1,4 @@
@page "/user/users"
@page "/sysadmin/users"
@using BlazorAnimation
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@ -15,7 +15,7 @@
@inject ISessionService SessionService
@inject IWizardProcessor WizardProcessor
@inject IUserDataService UserDataService
<PageTitle>Transfers</PageTitle>
<PageTitle>Users</PageTitle>
<div class="text-center m-5">
<h1>User management</h1>
@ -82,17 +82,18 @@
<DxGridDataColumn Name="@Localizer.GetString("Created")" FieldName="UserDto.Created" />
<DxGridDataColumn Name="@Localizer.GetString("EmailConfirmed")" FieldName="UserDto.EmailConfirmed" />
<DxGridDataColumn FieldName="UserDto.RefferalId" />
<DxGridDataColumn FieldName="UserDto.EmailAddress">
<DxGridDataColumn Width="240px" FieldName="UserDto.EmailAddress"/>
<DxGridDataColumn Width="110px" FieldName="UserDto.EmailAddress">
<CellDisplayTemplate>
@{
var keyField = context.Value;
var keyItem = (UserModelDtoDetail)context.DataItem;
var buttonText = "Contact";
<p>@keyField </p><DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
var keyItem = (UserModelDtoDetail)context.DataItem;
var buttonText = "Contact";
<DxButton Click="() => SendMail(keyItem)" IconCssClass="btn-icon-envelope" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
}
</CellDisplayTemplate>
</DxGridDataColumn>
</DxGridDataColumn>
</Columns>
<DetailRowTemplate>
<DxTabs>

View File

@ -5,6 +5,7 @@
@using TIAM.Entities.Users
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAM.Services
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@ -27,6 +28,7 @@
<ProductDetailGrid @ref="_productGrid"
ContextIds="new[] {ContextId}"
DataSource="ParentData.Products"
GetAllMessageTag="GetAllTag"
Logger="_logger"
SignalRClient="AdminSignalRClient"
OnGridEditModelSaving="DataItemSaving"
@ -51,6 +53,10 @@
</Columns>
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Permissions">
<UserProductMappingGridComponent ShowNestedRows="false" ContextId="((Product)context.DataItem).Id" GetAllTag="SignalRTags.GetUserProductMappingsByProductId">
</UserProductMappingGridComponent>
</DxTabPage>
<DxTabPage Text="Profile">
<ProfileGridComponent ParentData="((Product)context.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage>
@ -85,18 +91,56 @@
[Parameter] public Guid ContextId { get; set; }
[Parameter] public IProductsRelation ParentData { get; set; } = null!;
[Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; }
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByContextId;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private ProductDetailGrid _productGrid = null!;
private ProductDetailGrid _productGrid;
private List<Product> productList = new List<Product>();
private LoggerClient<ProductDetailGridComponent> _logger = null!;
protected override void OnInitialized()
{
{
_logger = new LoggerClient<ProductDetailGridComponent>(LogWriters.ToArray());
//DataSource = new List<Address>();
}
protected override async Task OnParametersSetAsync()
{
// if (ParentData != null)
// {
// productList.AddRange(ParentData.Products);
// }
// else if (ContextId != null)
// {
// //_productGrid.ContextIds = new Guid[1];
// //_productGrid.ContextIds[0] = (Guid)ContextId;
// var data = await serviceProviderDataService.GetProductByIdAsync((Guid)ContextId);
// List<Product> result = new List<Product>();
// result.Add(data);
// _productGrid.DataSource = result;
// }
// else
base.OnParametersSet();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
// if(firstRender)
// {
// _productGrid.GetAllMessageTag = GetAllTag;
// // if (ParentData != null)
// // {
// // _productGrid.DataSource = new List<Product>();
// // _productGrid.DataSource = ParentData.Products;
// // }
// }
}
private void DataItemChanged(GridDataItemChangedEventArgs<Product> args)
{
_logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}");

View File

@ -18,7 +18,7 @@
<CompanyDetailGrid Data="_detailGridData"
Logger="_logger"
SignalRClient="AdminSignalRClient"
ContextIds="new[] {ContextId}"
ContextIds="ContextIds"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
@ -36,11 +36,15 @@
<DxGridDataColumn FieldName="CommissionPercent" />
</Columns>
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Products">
<ProductDetailGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
<ProductDetailGridComponent ParentData="(Company)context.DataItem" ContextId="((Company)context.DataItem).Id" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
</DetailRowTemplate>
<EditFormTemplate Context="EditFormContext">
@{
@ -65,7 +69,9 @@
@code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public UserModelDtoDetail UserModelDtoDetail { get; set; }
[Parameter] public Guid ContextId { get; set; }
[Parameter] public Guid? ContextId { get; set; }
public Guid[]? ContextIds = new Guid[1];
List<Company> _detailGridData;
@ -80,12 +86,18 @@
_logger = new LoggerClient<ServiceProviderGridComponent>(LogWriters.ToArray());
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
_detailGridData = UserModelDtoDetail.ServiceProviders ?? [];
//_detailGridData = UserModelDtoDetail.ServiceProviders ?? [];
//_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync();
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
}
protected override void OnParametersSet()
{
ContextIds[0] = (Guid)ContextId!;
base.OnParametersSet();
}
// void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
// {
// if (!e.IsNew) return;
@ -122,6 +134,6 @@
// {
// //refresh grid
// _logger.Info("orderData grid refreshed");
// }
// }
}

View File

@ -3,7 +3,10 @@
@using TIAM.Entities.Drivers
@using TIAM.Entities.Users
@using TIAM.Models.Dtos.Users
@using TIAM.Services
@using TIAMSharedUI.Shared.Components.Grids
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Services
@using TIAMWebApp.Shared.Application.Utility
@using TIAM.Core.Loggers
@using AyCode.Core.Loggers
@ -11,27 +14,45 @@
@using AyCode.Core
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient
<DxGrid Data="_detailGridData"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditModelSaving="EditModelSaving"
DataItemDeleting="DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<UserProductMappingGrid Logger="_logger"
ContextIds="ContextIds"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" />
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Products">
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
}
}
</DetailRowTemplate>
<EditFormTemplate Context="UserEditFormContext">
@{
var transfer2 = (UserProductMapping)UserEditFormContext.EditModel;
@ -52,47 +73,65 @@
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
</UserProductMappingGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter]
public UserModelDtoDetail UserModelDtoDetail { get; set; }
[Parameter] public IProductRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
[Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<UserProductMappingGridComponent> _logger;
List<UserProductMapping> _detailGridData;
List<Product> _availableProducts;
private ProductDetailGridComponent bleh;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
_detailGridData = UserModelDtoDetail.UserProductMappings ?? new List<UserProductMapping>();
_availableProducts = await ServiceProviderDataService.GetAllProductsAsync();
_logger.Info($"DetailGridData: {_detailGridData.Count}");
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
var newProductMapping = new UserProductMapping
{
ProductId = Guid.NewGuid(),
UserId = UserModelDtoDetail.Id,
Permissions = 1
};
// var newProductMapping = new UserProductMapping
// {
// ProductId = Guid.NewGuid(),
// UserId = UserModelDtoDetail.Id,
// Permissions = 1
// };
e.EditModel = newProductMapping;
//e.EditModel = newProductMapping;
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
//add new orderData to orderData array
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
@ -102,9 +141,9 @@
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//remove orderData from orderData array
_logger.Info("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.Drivers;
using TIAM.Entities.Products;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class CarDetailGrid : CarGrid
{
public CarDetailGrid() : base()
{
GetAllMessageTag = SignalRTags.GetAllCars;
AddMessageTag = SignalRTags.CreateCar;
UpdateMessageTag = SignalRTags.UpdateCar;
RemoveMessageTag = SignalRTags.DeleteCar;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.Drivers;
using TIAM.Entities.Products;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class CarGrid : TiamGrid<Car>
{
public CarGrid() : base()
{
GetAllMessageTag = SignalRTags.GetAllCars;
AddMessageTag = SignalRTags.CreateCar;
UpdateMessageTag = SignalRTags.UpdateCar;
RemoveMessageTag = SignalRTags.DeleteCar;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Components;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class CompanyByIdDetailGrid : CompanyGrid
{
public CompanyByIdDetailGrid() : base()
{
GetAllMessageTag = SignalRTags.GetCompany;
AddMessageTag = SignalRTags.AddCompany;
UpdateMessageTag = SignalRTags.UpdateCompany;
RemoveMessageTag = SignalRTags.RemoveCompany;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
var isFirst = IsFirstInitializeParameters;
return base.SetParametersAsyncCore(parameters);
if (isFirst)
{
}
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class UserProductMappingDriverGrid : TiamGrid<UserProductMapping>
{
public UserProductMappingDriverGrid() : base()
{
GetAllMessageTag = SignalRTags.GetAllUserProductMappings;
AddMessageTag = SignalRTags.CreateUserProductMapping;
UpdateMessageTag = SignalRTags.UpdateUserProductMapping;
RemoveMessageTag = SignalRTags.DeleteUserProductMapping;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class UserProductMappingGrid : TiamGrid<UserProductMapping>
{
public UserProductMappingGrid() : base()
{
GetAllMessageTag = SignalRTags.GetAllUserProductMappings;
AddMessageTag = SignalRTags.CreateUserProductMapping;
UpdateMessageTag = SignalRTags.UpdateUserProductMapping;
RemoveMessageTag = SignalRTags.DeleteUserProductMapping;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class UserProductMappingProductDetailGrid : UserProductMappingGrid
{
public UserProductMappingProductDetailGrid() : base()
{
GetAllMessageTag = SignalRTags.GetUserProductMappingsByProductId;
AddMessageTag = SignalRTags.CreateUserProductMapping;
UpdateMessageTag = SignalRTags.UpdateUserProductMapping;
RemoveMessageTag = SignalRTags.DeleteUserProductMapping;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class UserProductMappingUserDetailGrid : UserProductMappingGrid
{
public UserProductMappingUserDetailGrid() : base()
{
GetAllMessageTag = SignalRTags.GetUserProductMappingsByUserId;
AddMessageTag = SignalRTags.CreateUserProductMapping;
UpdateMessageTag = SignalRTags.UpdateUserProductMapping;
RemoveMessageTag = SignalRTags.DeleteUserProductMapping;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -15,9 +15,13 @@
<DxMenuItem Text="SysAdmin" IconCssClass="menu-icon-products menu-icon">
<Items>
<DxMenuItem NavigateUrl="user/sysadmin" Text="Dashboard" />
<DxMenuItem NavigateUrl="user/transfers" Text="Transfers" />
<DxMenuItem NavigateUrl="user/companies" Text="Companies" />
<DxMenuItem NavigateUrl="user/users" Text="Users" />
<DxMenuItem NavigateUrl="sysadmin/transfers" Text="Transfers" />
<DxMenuItem NavigateUrl="sysadmin/companies" Text="Companies" />
<DxMenuItem NavigateUrl="sysadmin/drivers" Text="Drivers" />
<DxMenuItem NavigateUrl="sysadmin/cars" Text="Cars" />
<DxMenuItem NavigateUrl="sysadmin/userproductmappings" Text="Permissions" />
<DxMenuItem NavigateUrl="sysadmin/users" Text="Users" />
<DxMenuItem NavigateUrl="user/destinations" Text="Destinations" />
</Items>
</DxMenuItem>

View File

@ -210,8 +210,8 @@ select {
.dxbl-tabs.dxbl-tabs-top {
--dxbl-tabs-bg: #ffffff45;
background-color: #ffffff45;
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 );
backdrop-filter: blur( 6px );
/*box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 );
backdrop-filter: blur( 6px );*/
-webkit-backdrop-filter: blur( 6px );
border-radius: 10px;
}

View File

@ -114,14 +114,24 @@ namespace TIAMWebApp.Server.Controllers
[HttpPost]
[Route(APIUrls.GetServiceProviderByIdRouteName)]
[SignalR(SignalRTags.GetCompany)]
public async Task<Company?> GetServiceProviderById([FromBody] Guid id)
public async Task<string> GetServiceProviderById([FromBody] Guid id)
{
_logger.Info($@"GetServiceProviderById called with id: {id}");
return await adminDal.GetCompanyByIdAsync(id);
}
[HttpPost]
[Route(APIUrls.GetServiceProvidersByIdRouteName)]
[SignalR(SignalRTags.GetCompanys)]
public async Task<string> GetServiceProvidersById([FromBody] Guid id)
{
_logger.Info($@"GetServiceProviderById called with id: {id}");
List<Company> compList = new List<Company>();
var result = await adminDal.GetServiceProviderByIdAsync(id);
compList.Add(result);
return compList.ToJson();
}
//17.
[Authorize]
[HttpPost]
@ -211,30 +221,90 @@ namespace TIAMWebApp.Server.Controllers
//23.
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetUserProductMappingsForProductRouteName)]
public async Task<Dictionary<Guid, string>> GetUserProductMappingsForProduct(Guid serviceProviderId)
[Route(APIUrls.GetUserProductMappingsByProductIdRouteName)]
[SignalR(SignalRTags.GetUserProductMappingsByProductId)]
public async Task<string> GetUserProductMappingsByProductId(Guid productId)
{
_logger.Info($@"GetUserProductMappingsForServiceProvider called with serviceProviderId: {serviceProviderId}");
_logger.Info($@"GetUserProductMappingsByUserId called with serviceProviderId: {productId}");
var userProductMappingDictionary = new Dictionary<Guid, string>();
var userProductMappings = adminDal.GetAllUserProductMappings();
var serviceProviders = await adminDal.GetCompaniesAsync();
var myServiceproviders = serviceProviders.Where(x => x.Id == serviceProviderId).ToDictionary(x => x.Id, x => x.Name);
var myUserProductMappings = userProductMappings.Where(x => x.ProductId == productId).ToList();
//put serviceprovider id and name into a dictionary
return myServiceproviders;
return myUserProductMappings.ToJson();
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetUserProductMappingsByUserIdRouteName)]
[SignalR(SignalRTags.GetUserProductMappingsByUserId)]
public async Task<string> GetUserProductMappingsByUserId(Guid userId)
{
_logger.Info($@"GetUserProductMappingsByUserId called with userId: {userId}");
var userProductMappings = adminDal.GetAllUserProductMappings();
var myUserProductMappings = userProductMappings.Where(x => x.UserId == userId).OrderBy(x => x.ProductId).ToList();
//put serviceprovider id and name into a dictionary
return myUserProductMappings.ToJson();
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetUserProductMappingByIdRouteName)]
[SignalR(SignalRTags.GetUserProductMappingById)]
public async Task<string> GetUserProductMappingById(Guid id)
{
_logger.Info($@"GetUserProductMappingsByUserId called with userId: {id}");
var userProductMappings = adminDal.GetAllUserProductMappings();
var myUserProductMappings = userProductMappings.Where(x => x.Id == id).ToList();
//put serviceprovider id and name into a dictionary
return myUserProductMappings.ToJson();
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetAllUserProductMappingsRouteName)]
[SignalR(SignalRTags.GetAllUserProductMappings)]
public async Task<string> GetAllUserProductMappings()
{
_logger.Info($@"GetAllUserProductMappings called");
var serviceProviders = adminDal.GetAllUserProductMappings()!.OrderBy(x => x.ProductId);
//put serviceprovider id and name into a dictionary
return serviceProviders.ToJson();
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetCarsForUserProductMappingRouteName + "/{userProductMappingId}")]
[SignalR(SignalRTags.GetCarsForUserProductMapping)]
public async Task<List<Car>> GetCarsForUserProductMapping(string userProductMappingId)
public async Task<List<Car>> GetCarsForUserProductMapping(Guid userProductMappingId)
{
_logger.Info($@"GetCarsForUserProductMapping called with userProductMappingId: {userProductMappingId}");
var cars = adminDal.GetCarByUserProductMappingId(Guid.Parse(userProductMappingId));
var cars = adminDal.GetCarByUserProductMappingId(userProductMappingId);
return cars;
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetAllCarsRouteName)]
[SignalR(SignalRTags.GetAllCars)]
public async Task<List<Car>> GetAllCars()
{
_logger.Info($@"GetAllCars called ");
var cars = await adminDal.GetAllCarsAsync();
return cars;
}
@ -277,8 +347,13 @@ namespace TIAMWebApp.Server.Controllers
[Tags("Finished", "Cars")]
[EndpointSummary("Create car")]
[SignalR(SignalRTags.CreateCar)]
public async Task<IActionResult> CreateCar(Car car)
=> await CarDataChanging(car, TrackingState.Add) ? Ok(car) : BadRequest("Invalid request");
public async Task<Car> CreateCar(Car car)
{
var result = await CarDataChanging(car, TrackingState.Add);
if (result)
return car;
else return null;
}
[AllowAnonymous]
[HttpPost]
@ -286,8 +361,14 @@ namespace TIAMWebApp.Server.Controllers
[Tags("Finished", "Cars")]
[EndpointSummary("Update car")]
[SignalR(SignalRTags.UpdateCar)]
public async Task<IActionResult> UpdateCar(Car car)
=> await CarDataChanging(car, TrackingState.Update) ? Ok(car) : BadRequest("Invalid request");
public async Task<Car> UpdateCar(Car car)
{
var result = await CarDataChanging(car, TrackingState.Update);
if (result)
return car;
else return null;
}
[AllowAnonymous]
[HttpPost]
@ -399,5 +480,37 @@ namespace TIAMWebApp.Server.Controllers
return null;
}
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetProductByIdRouteName)]
[Tags("In-Progress", "Product")]
[SignalR(SignalRTags.GetProductById)]
public async Task<Product> GetProductById(Guid productId)
{
_logger.Info("GetAllProducts called");
var products = adminDal.GetProductById(productId);
return products;
}
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.GetProductsById)]
public async Task<List<Product>> GetProductsById(Guid productId)
{
_logger.Info("GetAllProducts called");
var product = await GetProductById(productId);
var products = new List<Product>();
if (product != null) {
products.Add(product);
}
return products;
}
}
}

View File

@ -49,6 +49,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces
public Task<IEnumerable<Product>> GetProductsForServiceProviderAsync(Guid serviceProviderId);
public Task<List<Product>> GetAllProductsAsync();
public Task<Product> GetProductByIdAsync(Guid id);
}
}

View File

@ -135,6 +135,12 @@ namespace TIAMWebApp.Shared.Application.Models
public const string GetAllProductsRouteName = "GetAllProducts/";
public const string GetAllProducts = ServiceProviderAPI + GetAllProductsRouteName;
public const string GetProductByIdRouteName = "GetProductById/";
public const string GetProductById = ServiceProviderAPI + GetProductByIdRouteName;
public const string GetProductsByIdRouteName = "GetProductsById/";
public const string GetProductsById = ServiceProviderAPI + GetProductsByIdRouteName;
public const string GetProductsByServiceProviderIdRouteName = "GetProductsByServiceProviderId";
public const string GetProductsByServiceProviderId = ServiceProviderAPI + GetProductsByServiceProviderIdRouteName;
@ -150,8 +156,17 @@ namespace TIAMWebApp.Shared.Application.Models
public const string GetServiceProvidersRouteName = "GetServiceProviders";
public const string GetServiceProviders = ServiceProviderAPI + GetServiceProvidersRouteName;
public const string GetUserProductMappingsForProductRouteName = "GetUserProductMappingsForProduct";
public const string GetUserProductMappingsForProduct = ServiceProviderAPI + GetUserProductMappingsForProductRouteName;
public const string GetAllUserProductMappingsRouteName = "GetAllUserProductMappings";
public const string GetAllUserProductMappings = ServiceProviderAPI + GetAllUserProductMappingsRouteName;
public const string GetUserProductMappingsByProductIdRouteName = "GetUserProductMappingsByProductId";
public const string GetUserProductMappingsByProductId = ServiceProviderAPI + GetUserProductMappingsByProductIdRouteName;
public const string GetUserProductMappingsByUserIdRouteName = "GetUserProductMappingsByUserId";
public const string GetUserProductMappingsByUserId = ServiceProviderAPI + GetUserProductMappingsByUserIdRouteName;
public const string GetUserProductMappingByIdRouteName = "GetUserProductMappingById";
public const string GetUserProductMappingById = ServiceProviderAPI + GetUserProductMappingByIdRouteName;
public const string GetCarsForUserProductMappingRouteName = "GetCarsForUserProductMapping";
public const string GetCarsForUserProductMapping = ServiceProviderAPI + GetCarsForUserProductMappingRouteName;
@ -165,6 +180,9 @@ namespace TIAMWebApp.Shared.Application.Models
public const string DeleteCarRouteName = "DeleteCar";
public const string DeleteCar = ServiceProviderAPI + DeleteCarRouteName;
public const string GetAllCarsRouteName = "GetAllCars";
public const string GetAllCars = ServiceProviderAPI + GetAllCarsRouteName;
public const string GetProfileByIdRouteName = "GetProfileById";
public const string GetProfileById = ProfileAPI + GetProfileByIdRouteName;

View File

@ -246,5 +246,23 @@ namespace TIAMWebApp.Shared.Application.Services
return null;
}
}
public async Task<Product> GetProductByIdAsync(Guid id)
{
var result = await _adminSignalRClient.GetByIdAsync<Product>(SignalRTags.GetProductById);
//var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetProductById}";
//var response = await http.GetFromJsonAsync(url, typeof(Product));
//if (response != null)
//{
// return (Product)response;
//}
//else
//{
// return null;
//}
return result;
}
}
}