This commit is contained in:
Adam 2024-07-03 10:25:47 +02:00
commit 2a3c61c3f3
10 changed files with 34 additions and 19 deletions

View File

@ -55,17 +55,13 @@ namespace TIAM.Database.DataLayers.Admins
#region Transfer #region Transfer
public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.ToList()); public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<List<Transfer>> GetTransfersByDriverUserIdAsync(Guid driverUserId) => SessionAsync(ctx => ctx.GetTransfersByDriverUserId(driverUserId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<List<Transfer>> GetTransfersByDriverUserIdAsync(Guid driverUserId) public Task<List<Transfer>> GetTransfersByUserProductMappingIdAsync(Guid userProductMappingId) => SessionAsync(ctx => ctx.GetTransfersByUserProductMappingId(userProductMappingId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
=> SessionAsync(ctx => ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMapping.UserId == driverUserId)).ToList());
public Task<List<Transfer>> GetTransfersByUserProductMappingIdAsync(Guid userProductMappingId)
=> SessionAsync(ctx => ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMappingId == userProductMappingId)).ToList());
public Task<List<Transfer>> GetTransfersAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList()); public Task<List<Transfer>> GetTransfersAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<string> GetTransfersJsonAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson()); public Task<string> GetTransfersJsonAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
public Task<string> GetTransfersByUserIdJsonAsync(Guid userId) => SessionAsync(ctx => ctx.GetTransfers().Where(x => x.UserId == userId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson()); public Task<string> GetTransfersByUserIdJsonAsync(Guid userId) => SessionAsync(ctx => ctx.GetTransfersByUserId(userId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
public string GetTransfersJson() => Session(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson()); public string GetTransfersJson() => Session(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
public Transfer? GetTransferById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId)); public Transfer? GetTransferById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId));
public string? GetTransferJsonById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId)?.ToJson()); public string? GetTransferJsonById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId)?.ToJson());

View File

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; using DevExpress.Utils.Serializing;
using Microsoft.EntityFrameworkCore;
using TIAM.Core.Enums; using TIAM.Core.Enums;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
@ -43,6 +44,16 @@ public static class TransferDbSetExtensions
#endregion Add, Update, Remove #endregion Add, Update, Remove
public static IQueryable<Transfer> GetTransfersByUserId(this ITransferDbSet ctx, Guid userId)
=> ctx.GetTransfers().Where(x => x.UserId == userId);
public static IQueryable<Transfer> GetTransfersByDriverUserId(this ITransferDbSet ctx, Guid driverUserId)
=> ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMapping.UserId == driverUserId));
public static IQueryable<Transfer> GetTransfersByUserProductMappingId(this ITransferDbSet ctx, Guid userProductMappingId)
=> ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMappingId == userProductMappingId));
public static Transfer? GetTransferById(this ITransferDbSet ctx, Guid transferId) public static Transfer? GetTransferById(this ITransferDbSet ctx, Guid transferId)
=> ctx.Transfers.FirstOrDefault(x => x.Id == transferId); => ctx.Transfers.FirstOrDefault(x => x.Id == transferId);

View File

@ -35,6 +35,13 @@ public class UserProductMapping : IEntityGuid, IUserRelation, IProductRelation,
public UserProductMapping() public UserProductMapping()
{ } { }
public UserProductMapping(UserProductMapping upm) : this(upm.Id, upm.UserId, upm.ProductId, upm.Permissions, upm.JsonDetailModel)
{
IsAdmin = upm.IsAdmin;
Created = upm.Created;
Modified = upm.Modified;
}
public UserProductMapping(Guid userId, Guid productId) : this(Guid.NewGuid(), userId, productId) public UserProductMapping(Guid userId, Guid productId) : this(Guid.NewGuid(), userId, productId)
{ } { }

View File

@ -46,7 +46,7 @@ namespace TIAM.Models.Dtos.Users
foreach (var userProduct in user.UserProductMappings) foreach (var userProduct in user.UserProductMappings)
{ {
UserProductMappings.Add(new UserProductMapping(userProduct.Id, userProduct.UserId, userProduct.ProductId)); UserProductMappings.Add(new UserProductMapping(userProduct));
} }
} }

View File

@ -53,7 +53,7 @@
<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 }"
NewButtonVisible="false"/> CommandColumnVisible="false" />
</DxTabPage> </DxTabPage>
</DxTabs> </DxTabs>

View File

@ -44,12 +44,12 @@
DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto"
ShowFilterRow="true"> ShowFilterRow="true">
<Columns> <Columns>
<DxGridDataColumn FieldName="TimeStampUtc" Caption="TimeStampUtc" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" DisplayFormat="g" Width="130" /> <DxGridDataColumn FieldName="TimeStampUtc" Caption="TimeStampUtc" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" DisplayFormat="yyyy-MM-dd HH:mm:ss.fff" Width="165" />
<DxGridDataColumn FieldName="AppType" Caption="AppType" Width="80px" /> <DxGridDataColumn FieldName="AppType" Caption="AppType" Width="80px" />
<DxGridDataColumn FieldName="LogLevel" Caption="LogLevel" Width="80px" /> <DxGridDataColumn FieldName="LogLevel" Caption="LogLevel" Width="80px" />
<DxGridDataColumn FieldName="ThreadId" Caption="ThId" Width="55px" /> <DxGridDataColumn FieldName="ThreadId" Caption="ThId" Width="55px" />
<DxGridDataColumn FieldName="CategoryName" Width="170" /> <DxGridDataColumn FieldName="CategoryName" Width="170" />
<DxGridDataColumn FieldName="CallerName" Width="200" /> <DxGridDataColumn FieldName="CallerName" Width="220" />
<DxGridDataColumn FieldName="Text" /> <DxGridDataColumn FieldName="Text" />
<DxGridDataColumn FieldName="Exception" Width="200" /> <DxGridDataColumn FieldName="Exception" Width="200" />
<DxGridDataColumn FieldName="ErrorType" Visible="false" /> <DxGridDataColumn FieldName="ErrorType" Visible="false" />

View File

@ -92,7 +92,6 @@
CustomizeEditModel="Grid_CustomizeEditModel" CustomizeEditModel="Grid_CustomizeEditModel"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
AllowSelectRowByClick="true"
PageSize="13" PageSize="13"
ShowFilterRow="true"> ShowFilterRow="true">

View File

@ -28,7 +28,7 @@
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"> DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode">
<Columns> <Columns>
<DxGridCommandColumn Width="135" MinWidth="135" NewButtonVisible="NewButtonVisible" DeleteButtonVisible="AcDomain.IsDeveloperVersion" EditButtonVisible="AcDomain.IsDeveloperVersion" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn Width="135" MinWidth="135" Visible="CommandColumnVisible" NewButtonVisible="NewButtonVisible" EditButtonVisible="EditButtonVisible" DeleteButtonVisible="DeleteButtonVisible" 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="UserId" Caption="UserId" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="UserId" Caption="UserId" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@{ @{
@ -80,7 +80,10 @@
</UserProductMappingGrid> </UserProductMappingGrid>
@code { @code {
[Parameter] public bool CommandColumnVisible { get; set; } = true;
[Parameter] public bool NewButtonVisible { get; set; } = true; [Parameter] public bool NewButtonVisible { get; set; } = true;
[Parameter] public bool EditButtonVisible { get; set; } = true;
[Parameter] public bool DeleteButtonVisible { get; set; } = true;
[Parameter] public IProductRelation ParentData { get; set; } = null!; [Parameter] public IProductRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings; [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;

View File

@ -104,8 +104,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
} }
var crudTags = new SignalRCrudTags(GetAllMessageTag, GetItemMessageTag, AddMessageTag, UpdateMessageTag, RemoveMessageTag); var crudTags = new SignalRCrudTags(GetAllMessageTag, GetItemMessageTag, AddMessageTag, UpdateMessageTag, RemoveMessageTag);
_dataSource = new SignalRDataSource<TDataItem>(SignalRClient, crudTags, ContextIds); _dataSource = new SignalRDataSource<TDataItem>(SignalRClient, crudTags, ContextIds) { FilterText = FilterText };
_dataSource.FilterText = FilterText;
Data = _dataSource; Data = _dataSource;

View File

@ -23,7 +23,7 @@ namespace TIAMWebApp.Shared.Application.Models
UserType = userType; UserType = userType;
UserModelDto = userModelDto; UserModelDto = userModelDto;
HasProperties = hasProperties; HasProperties = hasProperties;
//UserRoles = userRoles; UserRoles = userRoles;
//UserRolesDictionary = new Dictionary<int, string>(); //UserRolesDictionary = new Dictionary<int, string>();
//UserModelDto.ServiceProviders[0]. //UserModelDto.ServiceProviders[0].