Compare commits

..

No commits in common. "4beae9c801f2ea6144bbc5f83e963f3eb952acac" and "1febed99843f07bd257a39cd26c468cdfcbb5ec4" have entirely different histories.

23 changed files with 138 additions and 299 deletions

View File

@ -31,7 +31,6 @@ using DevExpress.Data.Linq.Helpers;
using TIAM.Database.DbSets.Drivers;
using AyCode.Entities.Server.LogItems;
using AyCode.Interfaces.Entities;
using TIAM.Models.Dtos.Users;
namespace TIAM.Database.DataLayers.Admins
{
@ -42,6 +41,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 Task<List<Car>> GetAllCarsbyProductIdAsync(Guid productId) => SessionAsync(ctx => ctx.Cars.Where(x => x.UserProductMapping.ProductId == productId).OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList());
public Car? GetCarById(Guid carId) => Session(ctx => ctx.Cars.FirstOrDefault(x => x.Id == carId));
@ -217,11 +217,9 @@ namespace TIAM.Database.DataLayers.Admins
public Task<bool> UpdateUserAsync(User user) => TransactionAsync(ctx => ctx.UpdateUser(user));
public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId));
#region Product
public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
public Task<Product?> GetProductByIdAsync(Guid contextId, bool includeUsers = true) => SessionAsync(ctx => ctx.GetProductById(contextId, includeUsers));
public Task<List<ProductModelDtoName>> GetProductModelDtoNamesAsync() => SessionAsync(ctx => ctx.Products.Select(x => new ProductModelDtoName(x)).ToList());
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToList());
public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToJson());
@ -230,7 +228,6 @@ namespace TIAM.Database.DataLayers.Admins
public Task<Product?> UpdateProductAsync(Product product) => UpdateSafeAsync(product, (ctx, safeProduct) => ctx.UpdateProduct(safeProduct));
public Task<bool> RemoveProductAsync(Product product) => RemoveProductAsync(product.Id);
public Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId));
#endregion Product
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));

View File

@ -6,7 +6,6 @@ using TIAM.Entities.Emails;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users;
namespace TIAM.Database.DataLayers.Users
{
@ -21,8 +20,6 @@ namespace TIAM.Database.DataLayers.Users
{
}
public Task<List<UserModelDtoEmail>> GetUserModelDtoEmailsAsync() => SessionAsync(ctx => ctx.Users.Select(x => new UserModelDtoEmail(x)).ToList());
public async Task<bool> CreateUserAsync(User user)
{
Context.Users.Add(user);

View File

@ -1,21 +0,0 @@
using AyCode.Interfaces;
using TIAM.Entities.Products;
namespace TIAM.Models.Dtos.Products;
public class ProductModelDtoName : IAcModelDtoBase
{
public Guid Id { get; set; }
public string Name { get; set; }
public ProductModelDtoName()
{ }
public ProductModelDtoName(Product product) : this(product.Id, product.Name)
{ }
public ProductModelDtoName(Guid id, string name) : this()
{
Id = id;
Name = name;
}
}

View File

@ -1,6 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using AyCode.Core.Interfaces;
using AyCode.Interfaces;
using AyCode.Models.Users;
using TIAM.Entities.Products;

View File

@ -1,22 +0,0 @@
using AyCode.Interfaces;
using AyCode.Interfaces.Users;
using TIAM.Entities.Users;
namespace TIAM.Models.Dtos.Users;
public class UserModelDtoEmail : IAcEmailAddress, IAcModelDtoBase
{
public Guid Id { get; set; }
public string EmailAddress { get; set; }
public UserModelDtoEmail()
{ }
public UserModelDtoEmail(User user) : this(user.Id, user.EmailAddress)
{ }
public UserModelDtoEmail(Guid id, string emailAddress) : this()
{
Id = id;
EmailAddress = emailAddress;
}
}

View File

@ -85,8 +85,6 @@ public class SignalRTags : AcSignalRTags
public const int RemoveProduct = 75;
public const int GetProductsById = 76;
public const int GetAllProducts = 77;
public const int GetAllProductModelDtoNames = 78;
public const int GetTransferDestinationById = 80;
public const int GetAllTransferDestinations = 81;
@ -103,8 +101,6 @@ public class SignalRTags : AcSignalRTags
public const int GetTransferDestinationToProductsByTransferDestinationId = 96;
public const int GetAllUsers = 120;
public const int GetAllUserModelDtoDetails = 121;
public const int GetAllUserModelDtoEmails = 125;
public const int GetAllLogItemsByFilterText = 1000;
}

View File

@ -9,8 +9,6 @@
@using TIAMSharedUI.Pages.Components;
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using AyCode.Core.Helpers
@using AyCode.Core.Consts
@inject NavigationManager NavManager
@inject IUserDataService UserDataService;
@inject IJSRuntime jsRuntime;
@ -463,12 +461,10 @@ new HeroSliderItem
{
//if not, create user
// Random random = new Random();
// string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// string password = new string(Enumerable.Repeat(chars, 10)
// .Select(s => s[random.Next(s.Length)]).ToArray());
var password = AcCharsGenerator.NewPassword(AcConst.MinPasswordLength, 16);
Random random = new Random();
string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
string password = new string(Enumerable.Repeat(chars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
RegistrationModel regModel = new RegistrationModel
{

View File

@ -32,31 +32,33 @@
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card">
<div class="d-flex flex-column mb-4 pb-2">
<CarGridComponent ContextId="DriverId" GetAllTag="SignalRTags.GetCarsForUserProductMapping"
NewButtonVisible="true" DeleteButtonVisible="false" EditButtonVisible="true" DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Never" />
<CarDetailGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ContextId="driverId" GetAllTag="SignalRTags.GetCarsForUserProductMapping"></CarDetailGridComponent>
</div>
</div>
</Animation>
</div>
<div class=" col-12 col-xl-6">
</div>
</div>
</div>
@code {
[Parameter] public Guid DriverId { get; set; }
[Parameter] public Guid driverId { get; set; }
private LoggerClient<DriverManageCars> _logger;
protected override void OnInitialized()
{
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<DriverManageCars>(LogWriters.ToArray());
base.OnInitialized();
}

View File

@ -100,7 +100,7 @@
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn Visible="false" Width="80" MinWidth="80" FixedPosition="GridColumnFixedPosition.Left" />
<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>
@ -150,15 +150,11 @@
</Columns>
<DetailRowTemplate>
<DxTabs>
@{
var transfer = ((Transfer)context.DataItem);
}
<DxTabPage Text="Messages">
<MessageDetailGridComponent ContextId="transfer.Id" />
<MessageDetailGridComponent ContextId="((Transfer)context.DataItem).Id" />
</DxTabPage>
<DxTabPage Text="Driver">
<TransferToDriverGridComponent ContextId="transfer.Id" ParentData="transfer" DriverId="driverId" NewButtonVisible="false" DeleteButtonVisible="false" />
<TransferToDriverGridComponent ContextId="((Transfer)context.DataItem).Id" ParentData="(Transfer)context.DataItem" />
</DxTabPage>
</DxTabs>
</DetailRowTemplate>

View File

@ -50,10 +50,10 @@
</Columns>
<DetailRowTemplate>
@{
// TODO: ide max a transferek kellenek, nem a UserProductMapping! - J.
<DxTabs>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingsById" ContextIds="new[] { ((Car)context.DataItem).UserProductMappingId }"/>
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingsById" ContextIds="new[] { ((Car)context.DataItem).UserProductMappingId }" />
</DxTabPage>
</DxTabs>

View File

@ -20,7 +20,6 @@
<CarGrid Logger="_logger"
GetAllMessageTag="GetAllTag"
ContextIds="@(ContextId.IsNullOrEmpty() ? null : [ContextId])"
SignalRClient="AdminSignalRClient"
PageSize="10"
ValidationEnabled="false"
@ -30,8 +29,7 @@
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left"
Visible="CommandColumnVisible" NewButtonVisible="NewButtonVisible" EditButtonVisible="EditButtonVisible" DeleteButtonVisible="DeleteButtonVisible" />
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="UserProductMappingId" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@{
@ -51,12 +49,13 @@
</Columns>
<DetailRowTemplate>
@{
// TODO: ide max a transferek kellenek, nem a UserProductMapping! - J.
<DxTabs>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingsById" ContextIds="new[] { ((Car)context.DataItem).UserProductMappingId }"
CommandColumnVisible="false" />
</DxTabPage>
</DxTabs>
}
</DetailRowTemplate>
@ -96,16 +95,10 @@
</CarGrid>
@code {
[Parameter] public Guid ContextId { get; set; }
//[Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public bool CommandColumnVisible { get; set; } = true;
[Parameter] public bool NewButtonVisible { get; set; } = false;
[Parameter] public bool EditButtonVisible { get; set; } = true;
[Parameter] public bool DeleteButtonVisible { get; set; } = false;
private LoggerClient<CarGridComponent> _logger = null!;
protected override void OnInitialized()

View File

@ -168,7 +168,7 @@
_takeCount = value;
_contextParams[0] = _takeCount;
await _logViewerGrid.ReloadDataSourceAsync();
await _logViewerGrid.LoadDataSourceAsync();
}
private async Task OnValueChangedStartDate(DateTime value)
@ -181,7 +181,7 @@
_contextParams[1] = _fromDate;
if (_fromDate.Date > _toDate.Date) return;
await _logViewerGrid.ReloadDataSourceAsync();
await _logViewerGrid.LoadDataSourceAsync();
}
private async Task OnValueChangedEndDate(DateTime value)
@ -192,7 +192,7 @@
_contextParams[2] = _toDate;
if (_fromDate.Date > _toDate.Date) return;
await _logViewerGrid.ReloadDataSourceAsync();
await _logViewerGrid.LoadDataSourceAsync();
}
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)

View File

@ -10,8 +10,6 @@
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@using AyCode.Core.Helpers
@using AyCode.Core.Consts
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> Localizer
@ -121,13 +119,11 @@
var registration = new RegistrationModel();
//TODO: Refractor to userDataService
// var random = new Random();
// const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// var password = new string(Enumerable.Repeat(chars, 10)
// .Select(s => s[random.Next(s.Length)]).ToArray());
var random = new Random();
const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
var password = new string(Enumerable.Repeat(chars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
var password = AcCharsGenerator.NewPassword(AcConst.MinPasswordLength, 16);
registration.Email = userModelDtoDetail.UserDto.EmailAddress;
registration.PhoneNumber = userModelDtoDetail.UserDto.PhoneNumber;
registration.Password = password;

View File

@ -10,8 +10,6 @@
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@using AyCode.Core.Helpers
@using AyCode.Core.Consts
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> Localizer
@ -102,12 +100,10 @@
var registration = new RegistrationModel();
//TODO: Refractor to userDataService
// var random = new Random();
// const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// var password = new string(Enumerable.Repeat(chars, 10)
// .Select(s => s[random.Next(s.Length)]).ToArray());
var password = AcCharsGenerator.NewPassword(AcConst.MinPasswordLength, 16);
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;

View File

@ -10,8 +10,6 @@
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@using AyCode.Core.Helpers
@using AyCode.Core.Consts
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> Localizer
@ -121,12 +119,10 @@
var registration = new RegistrationModel();
//TODO: Refractor to userDataService
// var random = new Random();
// const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// var password = new string(Enumerable.Repeat(chars, 10)
// .Select(s => s[random.Next(s.Length)]).ToArray());
var password = AcCharsGenerator.NewPassword(AcConst.MinPasswordLength, 16);
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;

View File

@ -11,16 +11,12 @@
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@using AyCode.Core
@using AyCode.Core.Consts
@using AyCode.Core.Helpers
@using TIAMWebApp.Shared.Application.Services
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> Localizer
@inject ISessionService SessionService
@inject IWizardProcessor WizardProcessor
@inject IUserDataService UserDataService
@inject AdminSignalRClient AdminSignalRClient;
<PageTitle>Users</PageTitle>
<div class="text-center m-5">
@ -189,7 +185,7 @@
MessageWizardModel.ReceiverId = item.Id;
MessageWizardModel.ReceiverEmailAddress = item.UserDto.EmailAddress;
MessageWizardModel.SenderId = SessionService.User?.UserId ?? throw new NullReferenceException("SessionService.User == null");
MessageWizardModel.SenderId = SessionService.User.UserId;
MessageWizardModel.SenderEmailAddress = "info@anataworld.com";
// _logger.Info($"Sending mail to {MessageWizardModel.ReceiverEmailAddress} from {MessageWizardModel.SenderId}");
@ -265,6 +261,8 @@
userEditModel.ServiceProviders = [];
userEditModel.UserProductMappings = [];
}
}
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
@ -276,17 +274,14 @@
var registration = new RegistrationModel();
//TODO: Refractor to userDataService
// var random = new Random();
// const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// var password = new string(Enumerable.Repeat(chars, 10)
// .Select(s => s[random.Next(s.Length)]).ToArray());
var 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.Password = AcCharsGenerator.NewPassword(AcConst.MinPasswordLength, 16);
registration.Password = password;
registration.ReferralId = null;
await UserDataService.CreateGuestUser(registration);
@ -323,8 +318,7 @@
async Task UpdateDataAsync()
{
//refresh grid
//UserData = (await UserDataService.GetUsersWithDetailsAsync()).OrderBy(x => x.ProfileDto?.Name).ToList();
UserData = await AdminSignalRClient.GetAllAsync<List<UserModelDtoDetail>>(SignalRTags.GetAllUserModelDtoDetails) ?? [];
UserData = (await UserDataService.GetUsersWithDetailsAsync()).OrderBy(x => x.ProfileDto?.Name).ToList();
_logger.Info("UserData grid refreshed");
}
@ -332,7 +326,7 @@
{
_logger = new LoggerClient<ManageUsers>(LogWriters.ToArray());
await UpdateDataAsync();
UserData = (await UserDataService.GetUsersWithDetailsAsync()).OrderBy(x => x.ProfileDto?.Name).ToList();
base.OnInitialized();
}

View File

@ -34,26 +34,15 @@
EditMode="GridEditMode.EditRow"
ColumnResizeMode="GridColumnResizeMode.NextColumn">
<Columns>
<DxGridCommandColumn Width="150" MinWidth="150" FixedPosition="GridColumnFixedPosition.Left"
Visible="CommandColumnVisible" NewButtonVisible="NewButtonVisible" DeleteButtonVisible="DeleteButtonVisible" EditButtonVisible="EditButtonVisible" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" ReadOnly="true" />
<DxGridCommandColumn Width="150" MinWidth="150" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@{
var userEmailFieldName = $"{nameof(TransferToDriver.UserProductMapping)}.{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}";
var userEmailFieldNameComboItem = $"{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}";
var userNameFieldNameComboItem = $"{nameof(UserProductMapping.User)}.{nameof(User.FullName)}";
}
<DxGridDataColumn FieldName="@userEmailFieldName" Caption="Driver" SortIndex="0" ReadOnly="!DriverId.IsNullOrEmpty()" Visible="DriverId.IsNullOrEmpty()">
<CellDisplayTemplate>
@{
var email = string.Empty;
var transferToDriverDataItem = ((TransferToDriver)context.DataItem);
if (HasReadPermission(transferToDriverDataItem.UserProductMappingId))
email = transferToDriverDataItem.UserProductMapping.User.EmailAddress;
}
<text>@email</text>
</CellDisplayTemplate>
<DxGridDataColumn FieldName="@userEmailFieldName" Caption="Driver" SortIndex="0">
<CellEditTemplate>
@{
var transferToDriverEditModel = (TransferToDriver)context.EditModel;
@ -62,7 +51,6 @@
<DxComboBox Data="@_drivers"
TData="@UserProductMapping"
TValue="@UserProductMapping"
ReadOnly="!DriverId.IsNullOrEmpty()"
TextFieldName="@userEmailFieldNameComboItem"
Value="@_drivers.FirstOrDefault(x => x.Id == transferToDriverEditModel.UserProductMappingId)"
ValueChanged="v => transferToDriverEditModel.UserProductMappingId = v.Id"
@ -77,11 +65,11 @@
</CellEditTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="CarId" Caption="Car" ReadOnly="!_hasEditPermission">
<DxGridDataColumn FieldName="CarId" Caption="Car">
<CellDisplayTemplate>
@{
var transferToDriverDataItem = (TransferToDriver)context.DataItem;
<text>@_cars.FirstOrDefault(x => x.Id == transferToDriverDataItem.CarId)?.LicencePlate</text>
var transferToDriver = (TransferToDriver)context.DataItem;
<text>@_cars.FirstOrDefault(x => x.Id == transferToDriver.CarId)?.LicencePlate</text>
}
</CellDisplayTemplate>
<CellEditTemplate>
@ -92,7 +80,6 @@
<DxComboBox Data="@_cars.Where(x=>x.UserProductMappingId == transferToDriverEditModel.UserProductMappingId)"
TData="@Car"
TValue="@Car"
ReadOnly="!_hasEditPermission"
TextFieldName="LicencePlate"
Value="@_cars.FirstOrDefault(x => x.Id == transferToDriverEditModel.CarId)"
ValueChanged="v => { transferToDriverEditModel.CarId = v?.Id ?? Guid.Empty; transferToDriverEditModel.LicencePlate = v?.LicencePlate ?? string.Empty; }"
@ -135,43 +122,18 @@
</DxGridDataColumn>*@
<DxGridDataColumn FieldName="Price" ReadOnly="!_hasEditPermission">
<CellDisplayTemplate>
@{
var price = string.Empty;
var transferToDriverDataItem = ((TransferToDriver)context.DataItem);
if (HasReadPermission(transferToDriverDataItem.UserProductMappingId))
price = transferToDriverDataItem.Price.ToString("N0");
}
<text>@price</text>
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="Price" />
@* <DxGridDataColumn FieldName="LicencePlate" ReadOnly="true" /> *@
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true" />
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true"/>
<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" />
</Columns>
</TransferToDriversDetailGrid>
@code {
/// <summary>
/// UserProductMappingId! Not required...
/// </summary>
[Parameter] public Guid? DriverId { get; set; } = null;
[Parameter] public Guid ContextId { get; set; }
[Parameter] public ITransferToDriversRelation ParentData { get; set; } = null!;
[Parameter] public EventCallback<TransferToDriver> OnTransferToDriverChanged { get; set; }
[Parameter] public bool CommandColumnVisible { get; set; } = true;
[Parameter] public bool NewButtonVisible { get; set; } = true;
[Parameter] public bool EditButtonVisible { get; set; } = true;
[Parameter] public bool DeleteButtonVisible { get; set; } = true;
private bool _hasEditPermission = true;
private bool HasReadPermission(Guid userProductMappingId) => DriverId.IsNullOrEmpty() || DriverId == userProductMappingId;
private TransferToDriversDetailGrid _transferToDriversGrid = null!;
private LoggerClient<TransferToDriverGridComponent> _logger = null!;
@ -184,42 +146,11 @@
_logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}");
await base.OnInitializedAsync();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
LoadComboBoxItems().Forget();
}
await base.OnAfterRenderAsync(firstRender);
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
_hasEditPermission = HasReadPermission(((TransferToDriver)e.DataItem).UserProductMappingId);
if (!e.IsNew) return;
var newDriver = (TransferToDriver)e.EditModel;
newDriver.Id = Guid.NewGuid();
newDriver.CarId = Guid.Empty;
newDriver.LicencePlate = "";
newDriver.Car = new Car();
newDriver.Price = 0;
newDriver.TransferId = ParentData.Id;
}
private Task LoadComboBoxItems()
{
// _cars.AddRange((await AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])) ?? []);
// _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
//AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])
//TODO: CarModelDtoMin-t megcsinálni és azt lekérni a ComboBox-hoz! - J.
return AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, async response =>
AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, async response =>
{
if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
{
@ -228,13 +159,35 @@
}
_cars.Clear();
_cars.AddRange(response.ResponseData);
_drivers.Clear();
_cars.AddRange(response.ResponseData);
_drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
await InvokeAsync(StateHasChanged);
}, [TiamConstClient.TransferProductId]);
}, [TiamConstClient.TransferProductId]).Forget();
await base.OnInitializedAsync();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
// _transferToDriversGrid.BeginUpdate();
// _cars.AddRange((await AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCars))!);
// _transferToDriversGrid.EndUpdate();
// AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCars, response =>
// {
// if (response is { Status: SignalResponseStatus.Success, ResponseData: not null })
// _cars.AddRange(response.ResponseData);
// return Task.CompletedTask;
// }).Forget();
}
await base.OnAfterRenderAsync(firstRender);
}
private void DataItemChanged(GridDataItemChangedEventArgs<TransferToDriver> args)
@ -269,4 +222,17 @@
{
_logger.Debug($"DataItemDeleting");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
var newDriver = (TransferToDriver)e.EditModel;
newDriver.Id = Guid.NewGuid();
newDriver.CarId = Guid.Empty;
newDriver.LicencePlate = "";
newDriver.Car = new Car();
newDriver.Price = 0;
newDriver.TransferId = ParentData.Id;
}
}

View File

@ -17,7 +17,6 @@
@using AyCode.Models.Users
@using AyCode.Services.SignalRs
@using TIAM.Core.Consts
@using TIAM.Models.Dtos.Products
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient
@ -25,7 +24,6 @@
<UserProductMappingGrid Logger="_logger"
ContextIds="ContextIds?.Cast<object>().ToArray()"
DataSource="_userProductMapping"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
@ -50,7 +48,7 @@
var userProductMappingEditModel = (UserProductMapping)context.EditModel;
}
<DxComboBox Data="@_productModelDtoNames" TextFieldName="Name" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.ProductId" ReadOnly="@(!_isNewState!.Value)"
<DxComboBox Data="@_products" TextFieldName="Name" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.ProductId" ReadOnly="@(!_isNewState!.Value)"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox>
</CellEditTemplate>
@ -65,15 +63,15 @@
var userProductMappingEditModel = (UserProductMapping)context.EditModel;
}
<DxComboBox Data="@_userModelDtoEmails" TextFieldName="EmailAddress" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.UserId" ReadOnly="@(!_isNewState!.Value)"
<DxComboBox Data="@_users" TextFieldName="EmailAddress" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.UserId" ReadOnly="@(!_isNewState!.Value)"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox>
</CellEditTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="Permissions" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true" />
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true" />
<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" />
</Columns>
<DetailRowTemplate>
@{
@ -102,32 +100,22 @@
private bool? _isNewState = null;
private LoggerClient<UserProductMappingGridComponent> _logger;
private List<UserProductMapping> _userProductMapping = []; //TODO: kell a UserProductMappingDetailGridComponent és utána ez is static lehet! - J.
private static List<UserModelDtoEmail> _userModelDtoEmails = [];
private static List<ProductModelDtoName> _productModelDtoNames = [];
private static List<User> _users = [];
private static List<Product> _products = [];
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
AdminSignalRClient.GetAllIntoAsync(_users, SignalRTags.GetAllUsers).Forget();
await base.OnInitializedAsync();
}
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
AdminSignalRClient.GetAllIntoAsync(_userModelDtoEmails, SignalRTags.GetAllUserModelDtoEmails).Forget();
AdminSignalRClient.GetAllIntoAsync(_productModelDtoNames, SignalRTags.GetAllProductModelDtoNames).Forget();
}
base.OnAfterRender(firstRender);
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
_isNewState = e.IsNew;
if (!e.IsNew) return;
// var newProductMapping = new UserProductMapping

View File

@ -85,13 +85,7 @@ namespace TIAMSharedUI.Shared.Components.Cards
return _dataSource!;
}
set
{
_dataSourceParam = value;
if (_dataSource != null! && _dataSourceParam is List<TDataItem> workingReferenceList)
_dataSource.SetWorkingReferenceList(workingReferenceList);
}
set => _dataSourceParam = value;
}
protected override async Task OnInitializedAsync()
@ -131,7 +125,7 @@ namespace TIAMSharedUI.Shared.Components.Cards
if (firstRender)
{
if (_dataSourceParam != null!) await _dataSource.LoadDataSource(_dataSourceParam, true, true);
if (_dataSourceParam.Count > 0) await _dataSource.LoadDataSource(_dataSourceParam);
else _dataSource.LoadDataSourceAsync(true).Forget();
}
}

View File

@ -46,7 +46,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
if (_dataSource != null! && _dataSource.FilterText != value)
{
_dataSource.FilterText = value;
ReloadDataSourceAsync().Forget();
LoadDataSourceAsync().Forget();
}
}
}
@ -89,13 +89,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
return _dataSource!;
}
set
{
_dataSourceParam = value;
if (_dataSource != null! && _dataSourceParam is List<TDataItem> workingReferenceList)
_dataSource.SetWorkingReferenceList(workingReferenceList);
}
set => _dataSourceParam = value;
}
protected override async Task OnInitializedAsync()
@ -148,13 +142,13 @@ namespace TIAMSharedUI.Shared.Components.Grids
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
if (_dataSourceParam != null!) await _dataSource.LoadDataSource(_dataSourceParam, true, true);
if (_dataSourceParam.Count > 0) await _dataSource.LoadDataSource(_dataSourceParam);
else _dataSource.LoadDataSourceAsync(true).Forget();
}
await base.OnAfterRenderAsync(firstRender);
}
public Task AddDataItem(TDataItem dataItem)
@ -332,7 +326,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
return _dataSource.Remove(dataItem, true);
}
public Task ReloadDataSourceAsync()
public Task LoadDataSourceAsync()
{
return _dataSource.LoadDataSourceAsync(false);
}

View File

@ -25,22 +25,22 @@ namespace TIAMWebApp.Client.Services
{
switch (type.Name)
{
case nameof(TransferDestinationWizardModel):
case "TransferDestinationWizardModel":
var result = await TransferDataService.CreateTransferDestination((TransferDestination)data);
return result as TModelType;
case nameof(TransferWizardModel):
case "TransferWizardModel":
Console.WriteLine(@"TransferWizardModel");
var transferResult = await TransferDataService.CreateTransfer((TransferWizardModel)data);
return transferResult as TModelType;
case nameof(MessageWizardModel):
case "MessageWizardModel":
EmailMessage emailMessage = ((MessageWizardModel)data).CopyToEmailMessage();
var messageResult = await MessageSenderService.SendNoticeAsync(emailMessage, 1);
return messageResult as TModelType;
//case nameof(ServiceProvider):
// return null;
case "ServiceProvider":
return null;
default:
return null;
}

View File

@ -19,8 +19,6 @@ using AyCode.Utils.Extensions;
using TIAM.Entities.Drivers;
using TIAM.Services;
using TIAM.Entities.Products;
using TIAM.Models.Dtos.Products;
using TIAM.Models.Dtos.Users;
namespace TIAMWebApp.Server.Controllers
{
@ -457,15 +455,6 @@ namespace TIAMWebApp.Server.Controllers
return products;
}
[NonAction]
[SignalR(SignalRTags.GetAllProductModelDtoNames)]
public async Task<List<ProductModelDtoName>> GetProductModelDtoNames()
{
_logger.Info("GetUserModelDtoEmails called");
return await adminDal.GetProductModelDtoNamesAsync();
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetProductByIdRouteName)]

View File

@ -289,10 +289,10 @@ namespace TIAMWebApp.Server.Controllers
if (user != null)
{
//var random = new Random();
//var chars = "1234567890";
//var nameExtension = new string(Enumerable.Repeat(chars, 10)
// .Select(s => s[random.Next(s.Length)]).ToArray());
var random = new Random();
var chars = "1234567890";
var nameExtension = new string(Enumerable.Repeat(chars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
var userId = Guid.NewGuid();
@ -348,23 +348,22 @@ namespace TIAMWebApp.Server.Controllers
[AllowAnonymous]
[HttpGet]
[Route("GetUsers")]
public async Task<List<UserModelDto>> GetUsers()
public Task<List<UserModelDto>> GetUsers()
{
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
//return users;
return await userDal.GetAllUserModelDtoAsync<UserModelDto>();
return userDal.GetAllUserModelDtoAsync<UserModelDto>();
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetUsersWithDetailsRouteName)]
[SignalR(SignalRTags.GetAllUserModelDtoDetails)]
public async Task<List<UserModelDtoDetail>> GetUsersWithDetails()
public Task<List<UserModelDtoDetail>> GetUsersWithDetails()
{
_logger.Info("GetUsersWithDetails called");
var users = await userDal.GetAllUserModelDtoAsync<UserModelDtoDetail>();
return users;
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
//return users;
return userDal.GetAllUserModelDtoAsync<UserModelDtoDetail>();
}
[NonAction]
@ -372,32 +371,26 @@ namespace TIAMWebApp.Server.Controllers
public async Task<List<User>> GetAllUsers()
{
_logger.Info("GetAllUsers called");
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
//return users;
return await userDal.GetUsersAsync();
}
[NonAction]
[SignalR(SignalRTags.GetAllUserModelDtoEmails)]
public async Task<List<UserModelDtoEmail>> GetUserModelDtoEmails()
{
_logger.Info("GetUserModelDtoEmails called");
return await userDal.GetUserModelDtoEmailsAsync();
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetUserByEmailRouteName + "/{email}")]
public async Task<UserModelDto>? GetUserByEmail(string email)
{
_logger.Info($"GetUserByEmail called with email: {email}");
var result = await userDal.GetUserModelDtoByEmailAsync<UserModelDto>(email, false);
if (result == null)
var result = userDal.GetUserModelDtoByEmailAsync<UserModelDto>(email, false);
if (result.Result == null)
{
UserModelDto resultDto = new UserModelDto();
return resultDto;
}
else
{
return result;
return result.Result;
}
}
@ -405,10 +398,10 @@ namespace TIAMWebApp.Server.Controllers
[AllowAnonymous]
[HttpPost]
[Route("GetUserById")]
public async Task<UserModelDto?> GetUserById([FromBody] Guid id)
public Task<UserModelDto?> GetUserById([FromBody] Guid id)
{
_logger.Info($"GetUserById called with id: {id}");
return await userDal.GetUserModelDtoByIdAsync<UserModelDto>(id, true);
return userDal.GetUserModelDtoByIdAsync<UserModelDto>(id, true);
}
[AllowAnonymous]