Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm
This commit is contained in:
commit
7cb502fdaf
|
|
@ -138,6 +138,7 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
#region TransferToDriver
|
#region TransferToDriver
|
||||||
|
|
||||||
public Task<TransferToDriver?> GetTransferToDriverByIdAsync(Guid transferToDriverId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriverById(transferToDriverId, autoInclude));
|
public Task<TransferToDriver?> GetTransferToDriverByIdAsync(Guid transferToDriverId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriverById(transferToDriverId, autoInclude));
|
||||||
|
public Task<List<TransferToDriver>> GetTransferToDriversByUpmId(Guid upmId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByUpmId(upmId, autoInclude).ToList());
|
||||||
public Task<List<TransferToDriver>> GetTransferToDriversByTransferIdAsync(Guid transferId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByTransferId(transferId, autoInclude).ToList());
|
public Task<List<TransferToDriver>> GetTransferToDriversByTransferIdAsync(Guid transferId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByTransferId(transferId, autoInclude).ToList());
|
||||||
|
|
||||||
public Task<bool> AddTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.AddTransferToDriver(transferToDriver));
|
public Task<bool> AddTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.AddTransferToDriver(transferToDriver));
|
||||||
|
|
@ -251,8 +252,7 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
|
|
||||||
#region UserProductMapping
|
#region UserProductMapping
|
||||||
|
|
||||||
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping)
|
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping) => TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping));
|
||||||
=> TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping));
|
|
||||||
|
|
||||||
public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
|
public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
|
||||||
{
|
{
|
||||||
|
|
@ -643,7 +643,7 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
#region UserProductMappings
|
#region UserProductMappings
|
||||||
|
|
||||||
//24 . (IServiceProviderDataService) Remove Assigned Users By Product Id
|
//24 . (IServiceProviderDataService) Remove Assigned Users By Product Id
|
||||||
public Task RemoveUserProductMappingsByContextId(Guid productId)
|
public Task RemoveUserProductMappingsByProductId(Guid productId)
|
||||||
{
|
{
|
||||||
using (var transaction = Context.Database.BeginTransaction())
|
using (var transaction = Context.Database.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,5 +65,7 @@ namespace TIAM.Database.DbContexts.ServiceProviders
|
||||||
//modelBuilder.Entity<TransferDestinationToProduct>().HasOne(e => e.TransferDestination);
|
//modelBuilder.Entity<TransferDestinationToProduct>().HasOne(e => e.TransferDestination);
|
||||||
//modelBuilder.Entity<TransferDestinationToProduct>().Navigation(e => e.TransferDestination).AutoInclude(true);
|
//modelBuilder.Entity<TransferDestinationToProduct>().Navigation(e => e.TransferDestination).AutoInclude(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DbSet<TransferToDriver> TransferToDrivers { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ public static class TransferToDriverDbSetExtensions
|
||||||
public static IQueryable<TransferToDriver> GetTransferToDriversByTransferId(this ITransferToDriverDbSet ctx, Guid transferId, bool autoInclude = true)
|
public static IQueryable<TransferToDriver> GetTransferToDriversByTransferId(this ITransferToDriverDbSet ctx, Guid transferId, bool autoInclude = true)
|
||||||
=> ctx.TransferToDrivers.Where(x => x.TransferId == transferId);
|
=> ctx.TransferToDrivers.Where(x => x.TransferId == transferId);
|
||||||
|
|
||||||
|
public static IQueryable<TransferToDriver> GetTransferToDriversByUpmId(this ITransferToDriverDbSet ctx, Guid upmId, bool autoInclude = true)
|
||||||
|
=> ctx.TransferToDrivers.Where(x => x.UserProductMappingId == upmId);
|
||||||
|
|
||||||
public static bool AddTransferToDriver(this ITransferDbSet ctx, TransferToDriver transferToDriver)
|
public static bool AddTransferToDriver(this ITransferDbSet ctx, TransferToDriver transferToDriver)
|
||||||
{
|
{
|
||||||
ctx.UpdateTransferStatus(transferToDriver.TransferId, TransferStatusType.AssignedToDriver);
|
ctx.UpdateTransferStatus(transferToDriver.TransferId, TransferStatusType.AssignedToDriver);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using TIAM.Database.DbSets.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
namespace TIAM.Database.DbSets.Users;
|
namespace TIAM.Database.DbSets.Users;
|
||||||
|
|
||||||
public interface IUserProductMappingDbSet
|
public interface IUserProductMappingDbSet : ITransferToDriverDbSet
|
||||||
{
|
{
|
||||||
public DbSet<UserProductMapping> UserProductMappings { get; set; }
|
public DbSet<UserProductMapping> UserProductMappings { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using AyCode.Core.Extensions;
|
using AyCode.Core.Extensions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using TIAM.Database.DbSets.Transfers;
|
||||||
using TIAM.Entities.Drivers;
|
using TIAM.Entities.Drivers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
|
|
||||||
|
|
@ -69,6 +70,9 @@ public static class UserProductMappingDbSetExtensions
|
||||||
{
|
{
|
||||||
if (userProductMapping == null) return false;
|
if (userProductMapping == null) return false;
|
||||||
|
|
||||||
|
if (ctx.GetTransferToDriversByUpmId(userProductMapping.Id).Any())
|
||||||
|
return false;
|
||||||
|
|
||||||
return ctx.UserProductMappings.Remove(userProductMapping).State == EntityState.Deleted;
|
return ctx.UserProductMappings.Remove(userProductMapping).State == EntityState.Deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,8 @@
|
||||||
private TransferToDriversDetailGrid _transferToDriversGrid = null!;
|
private TransferToDriversDetailGrid _transferToDriversGrid = null!;
|
||||||
private LoggerClient<TransferToDriverGridComponent> _logger = null!;
|
private LoggerClient<TransferToDriverGridComponent> _logger = null!;
|
||||||
|
|
||||||
private List<Car> _cars = [];
|
private static List<Car> _cars = [];
|
||||||
private List<UserProductMapping> _drivers = [];
|
private static List<UserProductMapping> _drivers = [];
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
|
@ -146,23 +146,26 @@
|
||||||
|
|
||||||
_logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}");
|
_logger.Info($"DetailGridData: {ParentData.TransferToDrivers.Count}");
|
||||||
|
|
||||||
_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, response =>
|
AdminSignalRClient.GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, async response =>
|
||||||
// {
|
{
|
||||||
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
||||||
// {
|
{
|
||||||
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
|
_logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
|
||||||
// return Task.CompletedTask;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// _cars.AddRange(response.ResponseData);
|
_cars.Clear();
|
||||||
// _drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
|
_drivers.Clear();
|
||||||
|
|
||||||
// return Task.CompletedTask;
|
_cars.AddRange(response.ResponseData);
|
||||||
// }, [TiamConstClient.TransferProductId]).Forget();
|
_drivers.AddRange(_cars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping));
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}, [TiamConstClient.TransferProductId]).Forget();
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
@using AyCode.Core.Loggers
|
@using AyCode.Core.Loggers
|
||||||
@using AyCode.Services.Loggers
|
@using AyCode.Services.Loggers
|
||||||
@using AyCode.Core
|
@using AyCode.Core
|
||||||
|
@using AyCode.Core.Enums
|
||||||
@using AyCode.Core.Helpers
|
@using AyCode.Core.Helpers
|
||||||
@using AyCode.Models.Users
|
@using AyCode.Models.Users
|
||||||
@using AyCode.Services.SignalRs
|
@using AyCode.Services.SignalRs
|
||||||
|
|
@ -32,7 +33,8 @@
|
||||||
EditMode="GridEditMode.EditRow"
|
EditMode="GridEditMode.EditRow"
|
||||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||||
OnGridEditModelSaving="OnGridEditModelSaving"
|
OnGridEditModelSaving="OnGridEditModelSaving"
|
||||||
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode">
|
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
|
||||||
|
OnGridItemChanged="OnGridItemChanged">
|
||||||
<Columns>
|
<Columns>
|
||||||
<DxGridCommandColumn Width="150" MinWidth="150" Visible="CommandColumnVisible" NewButtonVisible="NewButtonVisible" EditButtonVisible="EditButtonVisible" DeleteButtonVisible="DeleteButtonVisible" FixedPosition="GridColumnFixedPosition.Left" />
|
<DxGridCommandColumn Width="150" MinWidth="150" 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" />
|
||||||
|
|
@ -80,25 +82,6 @@
|
||||||
</DxTabs>
|
</DxTabs>
|
||||||
}
|
}
|
||||||
</DetailRowTemplate>
|
</DetailRowTemplate>
|
||||||
|
|
||||||
@* <EditFormTemplate Context="userEditFormContext">
|
|
||||||
@{
|
|
||||||
var userProduct = (UserProductMapping)userEditFormContext.EditModel;
|
|
||||||
}
|
|
||||||
<DxFormLayout CssClass="w-100">
|
|
||||||
<DxFormLayoutItem Caption="User" ColSpanMd="4">
|
|
||||||
@userEditFormContext.GetEditor("UserId")
|
|
||||||
</DxFormLayoutItem>
|
|
||||||
<DxFormLayoutItem Caption="Product:" ColSpanMd="4">
|
|
||||||
<DxComboBox Data="@_availableProducts" TextFieldName="Name" @bind-Value="((UserProductMapping)userEditFormContext.EditModel).ProductId" />
|
|
||||||
</DxFormLayoutItem>
|
|
||||||
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
|
|
||||||
@userEditFormContext.GetEditor("Permissions")
|
|
||||||
</DxFormLayoutItem>
|
|
||||||
|
|
||||||
</DxFormLayout>
|
|
||||||
</EditFormTemplate>
|
|
||||||
*@
|
|
||||||
</UserProductMappingGrid>
|
</UserProductMappingGrid>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
@ -117,42 +100,16 @@
|
||||||
private bool? _isNewState = null;
|
private bool? _isNewState = null;
|
||||||
private LoggerClient<UserProductMappingGridComponent> _logger;
|
private LoggerClient<UserProductMappingGridComponent> _logger;
|
||||||
|
|
||||||
private List<User> _users = [];
|
private static List<User> _users = [];
|
||||||
private List<Product> _products = [];
|
private static List<Product> _products = [];
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
|
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
|
||||||
|
|
||||||
//_products = (await AdminSignalRClient.GetAllAsync<List<Product>>(SignalRTags.GetAllProducts)) ?? [];
|
|
||||||
|
|
||||||
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
|
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
|
||||||
AdminSignalRClient.GetAllIntoAsync(_users, SignalRTags.GetAllUsers).Forget();
|
AdminSignalRClient.GetAllIntoAsync(_users, SignalRTags.GetAllUsers).Forget();
|
||||||
|
|
||||||
// AdminSignalRClient.GetAllAsync<List<Product>>(SignalRTags.GetAllProducts, response =>
|
|
||||||
// {
|
|
||||||
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
|
||||||
// {
|
|
||||||
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
|
|
||||||
// return Task.CompletedTask;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _products.AddRange(response.ResponseData);
|
|
||||||
// return Task.CompletedTask;
|
|
||||||
// }).Forget();
|
|
||||||
|
|
||||||
// AdminSignalRClient.GetAllAsync<List<User>>(SignalRTags.getal, response =>
|
|
||||||
// {
|
|
||||||
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
|
||||||
// {
|
|
||||||
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
|
|
||||||
// return Task.CompletedTask;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _products.AddRange(response.ResponseData);
|
|
||||||
// return Task.CompletedTask;
|
|
||||||
// }).Forget();
|
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +130,15 @@
|
||||||
|
|
||||||
private void OnGridEditModelSaving(GridEditModelSavingEventArgs e)
|
private void OnGridEditModelSaving(GridEditModelSavingEventArgs e)
|
||||||
{
|
{
|
||||||
_isNewState = false;
|
_isNewState = e.IsNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGridItemChanged(GridDataItemChangedEventArgs<UserProductMapping> args)
|
||||||
|
{
|
||||||
|
// if (args.TrackingState != TrackingState.Add) return;
|
||||||
|
|
||||||
|
// args.CancelStateChangeInvoke = true;
|
||||||
|
// StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EditCanceling(GridEditCancelingEventArgs e)
|
private void EditCanceling(GridEditCancelingEventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -177,20 +177,20 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[Tags("Finished", "ServiceProvider")]
|
[Tags("Finished", "ServiceProvider")]
|
||||||
[EndpointSummary("Create assigned user to product")]
|
[EndpointSummary("Create assigned user to product")]
|
||||||
[SignalR(SignalRTags.CreateUserProductMapping)]
|
[SignalR(SignalRTags.CreateUserProductMapping)]
|
||||||
public async Task<IActionResult> CreateUserProductMapping(UserProductMapping userProductMapping)
|
public async Task<UserProductMapping?> CreateUserProductMapping(UserProductMapping userProductMapping)
|
||||||
{
|
{
|
||||||
if (userProductMapping.ProductId == Guid.Empty || userProductMapping.UserId == Guid.Empty)
|
_logger.Info($@"CreateUserProductMappings called with ownerId: {userProductMapping.ProductId}, {userProductMapping.UserId}");
|
||||||
{
|
|
||||||
return BadRequest("Invalid request");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Info($@"CreateUserProductMappings called with ownerId: {userProductMapping.ProductId}, {userProductMapping.UserId}");
|
|
||||||
|
|
||||||
var result = await adminDal.AddUserProductMappingAsync(userProductMapping);
|
if (userProductMapping.ProductId.IsNullOrEmpty() || userProductMapping.UserId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
return Ok(result);
|
_logger.Error(@"CreateUserProductMappings; (userProductMapping.ProductId.IsNullOrEmpty() || userProductMapping.UserId.IsNullOrEmpty())");
|
||||||
|
return null;//BadRequest("Invalid request");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var result = await adminDal.AddUserProductMappingAsync(userProductMapping);
|
||||||
|
|
||||||
|
//TODO: A userProductMapping-nem include-olja be a User-t és a Product-ot automatikusan, ezért kell újra lekérni! TransactionAsync T-t adjon vissza, ne csak bool-t... - J.
|
||||||
|
return result ? adminDal.GetUserProductMappingById(userProductMapping.Id) : null; //Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
|
@ -203,7 +203,8 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
|
|
||||||
var result = await adminDal.UpdateUserProductMappingAsync(userProductMapping);
|
var result = await adminDal.UpdateUserProductMappingAsync(userProductMapping);
|
||||||
|
|
||||||
return result == null ? string.Empty : userProductMapping.ToJson();
|
//TODO: A userProductMapping-nem include-olja be a User-t és a Product-ot automatikusan, ezért kell újra lekérni! TransactionAsync T-t adjon vissza, ne csak bool-t... - J.
|
||||||
|
return result == null ? string.Empty : adminDal.GetUserProductMappingById(userProductMapping.Id).ToJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue