Compare commits

...

5 Commits

Author SHA1 Message Date
Loretta 4beae9c801 improvements, fixes... 2024-07-06 08:24:00 +02:00
Loretta 0aaa907c20 fixes 2024-07-06 07:24:00 +02:00
Loretta adb855843c improvements, fixes, etc... 2024-07-06 07:21:10 +02:00
Loretta 42b351262a Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm 2024-07-05 15:39:22 +02:00
Loretta 0bce3c9fd2 imprvements, fixes, etc... 2024-07-05 15:39:14 +02:00
23 changed files with 299 additions and 138 deletions

View File

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

View File

@ -6,6 +6,7 @@ using TIAM.Entities.Emails;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users;
namespace TIAM.Database.DataLayers.Users namespace TIAM.Database.DataLayers.Users
{ {
@ -20,6 +21,8 @@ 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) public async Task<bool> CreateUserAsync(User user)
{ {
Context.Users.Add(user); Context.Users.Add(user);

View File

@ -0,0 +1,21 @@
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,5 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using AyCode.Core.Interfaces;
using AyCode.Interfaces; using AyCode.Interfaces;
using AyCode.Models.Users; using AyCode.Models.Users;
using TIAM.Entities.Products; using TIAM.Entities.Products;

View File

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

View File

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

View File

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

View File

@ -100,7 +100,7 @@
ShowFilterRow="true"> ShowFilterRow="true">
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="AcDomain.IsDeveloperVersion" Width="80" MinWidth="80" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn Visible="false" Width="80" MinWidth="80" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="OrderId" Caption="Order" SortIndex="1" SortOrder="GridColumnSortOrder.Descending" Width="70"> <DxGridDataColumn FieldName="OrderId" Caption="Order" SortIndex="1" SortOrder="GridColumnSortOrder.Descending" Width="70">
<CellDisplayTemplate> <CellDisplayTemplate>
@ -150,11 +150,15 @@
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
<DxTabs> <DxTabs>
@{
var transfer = ((Transfer)context.DataItem);
}
<DxTabPage Text="Messages"> <DxTabPage Text="Messages">
<MessageDetailGridComponent ContextId="((Transfer)context.DataItem).Id" /> <MessageDetailGridComponent ContextId="transfer.Id" />
</DxTabPage> </DxTabPage>
<DxTabPage Text="Driver"> <DxTabPage Text="Driver">
<TransferToDriverGridComponent ContextId="((Transfer)context.DataItem).Id" ParentData="(Transfer)context.DataItem" /> <TransferToDriverGridComponent ContextId="transfer.Id" ParentData="transfer" DriverId="driverId" NewButtonVisible="false" DeleteButtonVisible="false" />
</DxTabPage> </DxTabPage>
</DxTabs> </DxTabs>
</DetailRowTemplate> </DetailRowTemplate>

View File

@ -50,10 +50,10 @@
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{ @{
// TODO: ide max a transferek kellenek, nem a UserProductMapping! - J.
<DxTabs> <DxTabs>
<DxTabPage Text="Driving permissions assigned"> <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> </DxTabPage>
</DxTabs> </DxTabs>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,15 +34,26 @@
EditMode="GridEditMode.EditRow" EditMode="GridEditMode.EditRow"
ColumnResizeMode="GridColumnResizeMode.NextColumn"> ColumnResizeMode="GridColumnResizeMode.NextColumn">
<Columns> <Columns>
<DxGridCommandColumn Width="150" MinWidth="150" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn Width="150" MinWidth="150" FixedPosition="GridColumnFixedPosition.Left"
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> Visible="CommandColumnVisible" NewButtonVisible="NewButtonVisible" DeleteButtonVisible="DeleteButtonVisible" EditButtonVisible="EditButtonVisible" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" ReadOnly="true" />
@{ @{
var userEmailFieldName = $"{nameof(TransferToDriver.UserProductMapping)}.{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}"; var userEmailFieldName = $"{nameof(TransferToDriver.UserProductMapping)}.{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}";
var userEmailFieldNameComboItem = $"{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}"; var userEmailFieldNameComboItem = $"{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}";
var userNameFieldNameComboItem = $"{nameof(UserProductMapping.User)}.{nameof(User.FullName)}"; var userNameFieldNameComboItem = $"{nameof(UserProductMapping.User)}.{nameof(User.FullName)}";
} }
<DxGridDataColumn FieldName="@userEmailFieldName" Caption="Driver" SortIndex="0"> <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>
<CellEditTemplate> <CellEditTemplate>
@{ @{
var transferToDriverEditModel = (TransferToDriver)context.EditModel; var transferToDriverEditModel = (TransferToDriver)context.EditModel;
@ -51,6 +62,7 @@
<DxComboBox Data="@_drivers" <DxComboBox Data="@_drivers"
TData="@UserProductMapping" TData="@UserProductMapping"
TValue="@UserProductMapping" TValue="@UserProductMapping"
ReadOnly="!DriverId.IsNullOrEmpty()"
TextFieldName="@userEmailFieldNameComboItem" TextFieldName="@userEmailFieldNameComboItem"
Value="@_drivers.FirstOrDefault(x => x.Id == transferToDriverEditModel.UserProductMappingId)" Value="@_drivers.FirstOrDefault(x => x.Id == transferToDriverEditModel.UserProductMappingId)"
ValueChanged="v => transferToDriverEditModel.UserProductMappingId = v.Id" ValueChanged="v => transferToDriverEditModel.UserProductMappingId = v.Id"
@ -65,11 +77,11 @@
</CellEditTemplate> </CellEditTemplate>
</DxGridDataColumn> </DxGridDataColumn>
<DxGridDataColumn FieldName="CarId" Caption="Car"> <DxGridDataColumn FieldName="CarId" Caption="Car" ReadOnly="!_hasEditPermission">
<CellDisplayTemplate> <CellDisplayTemplate>
@{ @{
var transferToDriver = (TransferToDriver)context.DataItem; var transferToDriverDataItem = (TransferToDriver)context.DataItem;
<text>@_cars.FirstOrDefault(x => x.Id == transferToDriver.CarId)?.LicencePlate</text> <text>@_cars.FirstOrDefault(x => x.Id == transferToDriverDataItem.CarId)?.LicencePlate</text>
} }
</CellDisplayTemplate> </CellDisplayTemplate>
<CellEditTemplate> <CellEditTemplate>
@ -80,6 +92,7 @@
<DxComboBox Data="@_cars.Where(x=>x.UserProductMappingId == transferToDriverEditModel.UserProductMappingId)" <DxComboBox Data="@_cars.Where(x=>x.UserProductMappingId == transferToDriverEditModel.UserProductMappingId)"
TData="@Car" TData="@Car"
TValue="@Car" TValue="@Car"
ReadOnly="!_hasEditPermission"
TextFieldName="LicencePlate" TextFieldName="LicencePlate"
Value="@_cars.FirstOrDefault(x => x.Id == transferToDriverEditModel.CarId)" Value="@_cars.FirstOrDefault(x => x.Id == transferToDriverEditModel.CarId)"
ValueChanged="v => { transferToDriverEditModel.CarId = v?.Id ?? Guid.Empty; transferToDriverEditModel.LicencePlate = v?.LicencePlate ?? string.Empty; }" ValueChanged="v => { transferToDriverEditModel.CarId = v?.Id ?? Guid.Empty; transferToDriverEditModel.LicencePlate = v?.LicencePlate ?? string.Empty; }"
@ -122,18 +135,43 @@
</DxGridDataColumn>*@ </DxGridDataColumn>*@
<DxGridDataColumn FieldName="Price" /> <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="LicencePlate" ReadOnly="true" /> *@ @* <DxGridDataColumn FieldName="LicencePlate" ReadOnly="true" /> *@
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true" />
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true"/>
</Columns> </Columns>
</TransferToDriversDetailGrid> </TransferToDriversDetailGrid>
@code { @code {
/// <summary>
/// UserProductMappingId! Not required...
/// </summary>
[Parameter] public Guid? DriverId { get; set; } = null;
[Parameter] public Guid ContextId { get; set; } [Parameter] public Guid ContextId { get; set; }
[Parameter] public ITransferToDriversRelation ParentData { get; set; } = null!; [Parameter] public ITransferToDriversRelation ParentData { get; set; } = null!;
[Parameter] public EventCallback<TransferToDriver> OnTransferToDriverChanged { get; set; } [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 TransferToDriversDetailGrid _transferToDriversGrid = null!;
private LoggerClient<TransferToDriverGridComponent> _logger = null!; private LoggerClient<TransferToDriverGridComponent> _logger = null!;
@ -146,11 +184,42 @@
_logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}"); _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])) ?? []); // _cars.AddRange((await AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])) ?? []);
// _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); // _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
//AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId]) //AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [TiamConstClient.TransferProductId])
AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, async response =>
//TODO: CarModelDtoMin-t megcsinálni és azt lekérni a ComboBox-hoz! - J.
return AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, async response =>
{ {
if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
{ {
@ -159,35 +228,13 @@
} }
_cars.Clear(); _cars.Clear();
_drivers.Clear();
_cars.AddRange(response.ResponseData); _cars.AddRange(response.ResponseData);
_drivers.Clear();
_drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
}, [TiamConstClient.TransferProductId]).Forget(); }, [TiamConstClient.TransferProductId]);
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) private void DataItemChanged(GridDataItemChangedEventArgs<TransferToDriver> args)
@ -222,17 +269,4 @@
{ {
_logger.Debug($"DataItemDeleting"); _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,6 +17,7 @@
@using AyCode.Models.Users @using AyCode.Models.Users
@using AyCode.Services.SignalRs @using AyCode.Services.SignalRs
@using TIAM.Core.Consts @using TIAM.Core.Consts
@using TIAM.Models.Dtos.Products
@inject IServiceProviderDataService ServiceProviderDataService @inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient @inject AdminSignalRClient AdminSignalRClient
@ -24,6 +25,7 @@
<UserProductMappingGrid Logger="_logger" <UserProductMappingGrid Logger="_logger"
ContextIds="ContextIds?.Cast<object>().ToArray()" ContextIds="ContextIds?.Cast<object>().ToArray()"
DataSource="_userProductMapping"
GetAllMessageTag="GetAllTag" GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
PageSize="10" PageSize="10"
@ -48,7 +50,7 @@
var userProductMappingEditModel = (UserProductMapping)context.EditModel; var userProductMappingEditModel = (UserProductMapping)context.EditModel;
} }
<DxComboBox Data="@_products" TextFieldName="Name" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.ProductId" ReadOnly="@(!_isNewState!.Value)" <DxComboBox Data="@_productModelDtoNames" TextFieldName="Name" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.ProductId" ReadOnly="@(!_isNewState!.Value)"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch"> SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox> </DxComboBox>
</CellEditTemplate> </CellEditTemplate>
@ -63,15 +65,15 @@
var userProductMappingEditModel = (UserProductMapping)context.EditModel; var userProductMappingEditModel = (UserProductMapping)context.EditModel;
} }
<DxComboBox Data="@_users" TextFieldName="EmailAddress" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.UserId" ReadOnly="@(!_isNewState!.Value)" <DxComboBox Data="@_userModelDtoEmails" TextFieldName="EmailAddress" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.UserId" ReadOnly="@(!_isNewState!.Value)"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch"> SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox> </DxComboBox>
</CellEditTemplate> </CellEditTemplate>
</DxGridDataColumn> </DxGridDataColumn>
<DxGridDataColumn FieldName="Permissions" /> <DxGridDataColumn FieldName="Permissions" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true" />
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" ReadOnly="true" />
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{ @{
@ -100,22 +102,32 @@
private bool? _isNewState = null; private bool? _isNewState = null;
private LoggerClient<UserProductMappingGridComponent> _logger; private LoggerClient<UserProductMappingGridComponent> _logger;
private static List<User> _users = []; private List<UserProductMapping> _userProductMapping = []; //TODO: kell a UserProductMappingDetailGridComponent és utána ez is static lehet! - J.
private static List<Product> _products = []; private static List<UserModelDtoEmail> _userModelDtoEmails = [];
private static List<ProductModelDtoName> _productModelDtoNames = [];
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray()); _logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
AdminSignalRClient.GetAllIntoAsync(_users, SignalRTags.GetAllUsers).Forget();
await base.OnInitializedAsync(); 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) void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{ {
_isNewState = e.IsNew; _isNewState = e.IsNew;
if (!e.IsNew) return; if (!e.IsNew) return;
// var newProductMapping = new UserProductMapping // var newProductMapping = new UserProductMapping

View File

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

View File

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

View File

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

View File

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

View File

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