Merge branch 'v0.0.5.1' of https://git.aycode.com/Adam/TourIAm into v0.0.5.1
This commit is contained in:
commit
eda1da7cca
|
|
@ -168,6 +168,8 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
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>> GetTransferToDriversByProductIdAsync(Guid productId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByProductId(productId, autoInclude).ToList());
|
||||
|
||||
public Task<bool> AddTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.AddTransferToDriver(transferToDriver));
|
||||
|
||||
public Task<TransferToDriver?> UpdateTransferToDriverAsync(TransferToDriver transferToDriver)
|
||||
|
|
|
|||
|
|
@ -21,21 +21,41 @@ public static class TransferToDriverDbSetExtensions
|
|||
.FirstOrDefault(x => x.Id == transferToDriverId);
|
||||
|
||||
public static IQueryable<TransferToDriver> GetTransferToDriversByTransferId(this ITransferToDriverDbSet ctx, Guid transferId, bool autoInclude = true)
|
||||
=> ctx.TransferToDrivers
|
||||
.Where(x => x.TransferId == transferId)
|
||||
.Include(x => x.Car.UserProductMapping.Product.ServiceProvider).ThenInclude(x => x.Products)
|
||||
.Include(x => x.UserProductMapping.User.Profile.Address)
|
||||
.Include(x => x.Transfer);
|
||||
{
|
||||
var query = ctx.TransferToDrivers.Where(x => x.TransferId == transferId);
|
||||
|
||||
//.Include(x => x.UserProductMapping.User.Products).ThenInclude(x => x.UserProductMappings)
|
||||
//.Include(x => x.Car.UserProductMapping.Product.ServiceProvider).ThenInclude(x => x.Products)
|
||||
//.Include(x => x.UserProductMapping.User.Profile.Address)
|
||||
//.Include(x => x.Transfer);
|
||||
if (autoInclude)
|
||||
{
|
||||
query = query.Include(x => x.Car.UserProductMapping.Product.ServiceProvider).ThenInclude(x => x.Products)
|
||||
.Include(x => x.UserProductMapping.User.Profile.Address)
|
||||
.Include(x => x.Transfer);
|
||||
}
|
||||
|
||||
//.Include(x => x.UserProductMapping.User.Products).ThenInclude(x => x.UserProductMappings).ThenInclude(x => x.User.Profile.Address)
|
||||
//.Include(x => x.Car.UserProductMapping.Product.ServiceProvider).ThenInclude(x => x.Products)
|
||||
//.Include(x => x.UserProductMapping.User.Profile.Address)
|
||||
//.Include(x => x.Transfer);
|
||||
return query;
|
||||
//.Include(x => x.UserProductMapping.User.Products).ThenInclude(x => x.UserProductMappings)
|
||||
//.Include(x => x.Car.UserProductMapping.Product.ServiceProvider).ThenInclude(x => x.Products)
|
||||
//.Include(x => x.UserProductMapping.User.Profile.Address)
|
||||
//.Include(x => x.Transfer);
|
||||
|
||||
//.Include(x => x.UserProductMapping.User.Products).ThenInclude(x => x.UserProductMappings).ThenInclude(x => x.User.Profile.Address)
|
||||
//.Include(x => x.Car.UserProductMapping.Product.ServiceProvider).ThenInclude(x => x.Products)
|
||||
//.Include(x => x.UserProductMapping.User.Profile.Address)
|
||||
//.Include(x => x.Transfer);
|
||||
}
|
||||
|
||||
public static IQueryable<TransferToDriver> GetTransferToDriversByProductId(this ITransferToDriverDbSet ctx, Guid productId, bool autoInclude = true)
|
||||
{
|
||||
var query = ctx.TransferToDrivers.Where(x => x.UserProductMapping.ProductId == productId);
|
||||
|
||||
if (autoInclude)
|
||||
{
|
||||
query = query.Include(x => x.Car.UserProductMapping.Product.ServiceProvider).ThenInclude(x => x.Products)
|
||||
.Include(x => x.UserProductMapping.User.Profile.Address)
|
||||
.Include(x => x.Transfer);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public static IQueryable<TransferToDriver> GetTransferToDriversByUpmId(this ITransferToDriverDbSet ctx, Guid upmId, bool autoInclude = true)
|
||||
=> ctx.TransferToDrivers.Where(x => x.UserProductMappingId == upmId);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using TIAM.Entities.Transfers;
|
||||
using AyCode.Services.SignalRs;
|
||||
using TIAM.Entities.Transfers;
|
||||
|
||||
namespace TIAM.Services.Interfaces;
|
||||
|
||||
|
|
@ -6,4 +7,6 @@ public interface ITransferApiControllerClient : ITransferApiControllerCommon
|
|||
{
|
||||
Task GetTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Action? callback = null);
|
||||
Task GetPublicTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Guid includeProductId, Action? callback = null);
|
||||
|
||||
Task GetTransferToDriversByProductIdAsync(Guid productId, Func<ISignalResponseMessage<List<TransferToDriver>?>, Task> responseCallback);
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ public interface ITransferApiControllerCommon
|
|||
public Task<List<UserProductMapping>> GetAllDriversByProductId(Guid productId);
|
||||
public Task<TransferToDriver?> GetTransferDriver(Guid transferDriverId);
|
||||
public Task<List<TransferToDriver>> GetTransferDrivers(Guid transferId);
|
||||
public Task<List<TransferToDriver>?> GetTransferToDriversByProductId(Guid productId);
|
||||
public Task<TransferToDriver?> AddTransferDriver(TransferToDriver transferToDriver);
|
||||
public Task<TransferToDriver?> UpdateTransferDriver(TransferToDriver transferToDriver);
|
||||
public Task<TransferToDriver?> RemoveTransferDriver(TransferToDriver transferToDriver);
|
||||
|
|
|
|||
|
|
@ -36,9 +36,11 @@ public class SignalRTags : AcSignalRTags
|
|||
public const int GetAllDrivers = 23;
|
||||
public const int GetAllDriversByProductId = 24;
|
||||
public const int GetTransferDriversByTransferId = 25;
|
||||
public const int AddTransferToDriver = 26;
|
||||
public const int UpdateTransferToDriver = 27;
|
||||
public const int RemoveTransferToDriver = 28;
|
||||
public const int GetTransferToDriversByProductId = 26;
|
||||
public const int AddTransferToDriver = 27;
|
||||
public const int UpdateTransferToDriver = 28;
|
||||
public const int RemoveTransferToDriver = 29;
|
||||
|
||||
public const int GetDriverManageTransfersPageModelByDriverId = 803;
|
||||
|
||||
public const int GetAddress = 29;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@
|
|||
<CellDisplayTemplate>
|
||||
@{
|
||||
var keyItem = (Transfer)context.DataItem;
|
||||
<text>@(string.Join(", ", keyItem.TransferToDrivers.Select(x => x.UserProductMapping?.User?.Profile?.GetFullName())))</text>
|
||||
<text>@(string.Join(", ", keyItem.TransferToDrivers.Select(x => x.UserProductMapping?.User?.Profile?.Name)))</text>
|
||||
}
|
||||
</CellDisplayTemplate>
|
||||
|
||||
|
|
@ -164,7 +164,9 @@
|
|||
<MessageDetailGridComponent ContextId="((Transfer)context.DataItem).Id" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Driver">
|
||||
<TransferToDriverGridComponent ContextId="((Transfer)context.DataItem).Id" ParentData="(Transfer)context.DataItem" />
|
||||
<TransferToDriverGridComponent ContextId="((Transfer)context.DataItem).Id" ParentData="(Transfer)context.DataItem"
|
||||
CommandColumnVisible="((Transfer)context.DataItem).TransferStatusType < TransferStatusType.Finished"
|
||||
OnTransferToDriverChanged="OnTransferToDriverChanged" />
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
</DetailRowTemplate>
|
||||
|
|
@ -274,7 +276,7 @@
|
|||
private DxTagBox<TransferStatusModel, TransferStatusModel> _filterTag;
|
||||
|
||||
public List<string> IgnoreList =
|
||||
[
|
||||
[
|
||||
"ReceiverEmailAddress",
|
||||
"ReceiverFullName",
|
||||
"ReceiverId",
|
||||
|
|
@ -438,10 +440,15 @@
|
|||
// _gridTransfer.SetFieldFilterCriteria(nameof(Transfer.TransferStatusType), filterCriteria);
|
||||
// }
|
||||
|
||||
private List<TransferToDriver>? _allTransfersDrivers = null;
|
||||
|
||||
private void DataSourceChanged(IList<Transfer> transfers)
|
||||
{
|
||||
_logger.Info("DataSourceChanged called");
|
||||
|
||||
if (_allTransfersDrivers == null && transfers.Count > 0) GetAllTransferToDriversFromDb(transfers);
|
||||
else RefreshDatasourceAllTransferToDrivers(transfers);
|
||||
|
||||
InitializeAppointments(transfers);
|
||||
|
||||
if (_selectedCategories.Count > 0)
|
||||
|
|
@ -482,6 +489,8 @@
|
|||
{
|
||||
_logger = new LoggerClient<ManageTransfers>(_logWriters.ToArray());
|
||||
|
||||
//GetAllTransferToDriversFromDb(null);
|
||||
|
||||
//await AdminSignalRClient.GetAllCarsByProductIdAsync(TiamConstClient.TransferProductId, _cars, StateHasChanged);
|
||||
|
||||
//await base.OnInitializedAsync();
|
||||
|
|
@ -506,23 +515,23 @@
|
|||
}
|
||||
|
||||
_dataStorage = new DxSchedulerDataStorage
|
||||
{
|
||||
AppointmentMappings = new DxSchedulerAppointmentMappings()
|
||||
{
|
||||
AppointmentMappings = new DxSchedulerAppointmentMappings()
|
||||
{
|
||||
Type = "AppointmentType",
|
||||
Start = "StartDate",
|
||||
End = "EndDate",
|
||||
Subject = "Caption",
|
||||
AllDay = "AllDay",
|
||||
Location = "Location",
|
||||
Description = "Description",
|
||||
LabelId = "Label",
|
||||
StatusId = "Status",
|
||||
RecurrenceInfo = "Recurrence"
|
||||
},
|
||||
Type = "AppointmentType",
|
||||
Start = "StartDate",
|
||||
End = "EndDate",
|
||||
Subject = "Caption",
|
||||
AllDay = "AllDay",
|
||||
Location = "Location",
|
||||
Description = "Description",
|
||||
LabelId = "Label",
|
||||
StatusId = "Status",
|
||||
RecurrenceInfo = "Recurrence"
|
||||
},
|
||||
|
||||
AppointmentsSource = AppointmentModels
|
||||
};
|
||||
AppointmentsSource = AppointmentModels
|
||||
};
|
||||
}
|
||||
|
||||
public AppointmentModel CreateAppointmentModel(Transfer transfer)
|
||||
|
|
@ -548,7 +557,7 @@
|
|||
{
|
||||
if (selectedRow is not Transfer selectedTransfer) return;
|
||||
|
||||
RefreshTransferToDriversData(selectedTransfer, () => { _gridTransfer.Reload(); });
|
||||
//RefreshTransferToDriversData(selectedTransfer, () => { _gridTransfer.Reload(); });
|
||||
}
|
||||
|
||||
private void RefreshTransferToDriversData(Transfer? transfer, Action? callback = null)
|
||||
|
|
@ -562,7 +571,7 @@
|
|||
{
|
||||
if (x?.ResponseData == null) return Task.CompletedTask;
|
||||
|
||||
transfer.TransferToDrivers.UpdateCollection<TransferToDriver>(x.ResponseData, false);
|
||||
transfer.TransferToDrivers.UpdateCollection(x.ResponseData, false);
|
||||
callback?.Invoke();
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
@ -574,4 +583,50 @@
|
|||
}
|
||||
}
|
||||
|
||||
private void GetAllTransferToDriversFromDb(IList<Transfer>? transfers)
|
||||
{
|
||||
_allTransfersDrivers = [];
|
||||
|
||||
// _allTransfersDrivers = await AdminSignalRClient.GetTransferToDriversByProductId(TiamConstClient.TransferProductId);
|
||||
// RefreshDatasourceAllTransferToDrivers(transfers);
|
||||
|
||||
//TODO: itt kell az animált Driver column töltő icon-t megjeleníteni! - J.
|
||||
AdminSignalRClient.GetTransferToDriversByProductIdAsync(TiamConstClient.TransferProductId, response =>
|
||||
{
|
||||
//TODO: itt kell a Driver column töltő icon-t eltüntetni! - J.
|
||||
if (response.ResponseData == null || response.ResponseData.Count == 0) return Task.CompletedTask;
|
||||
|
||||
_allTransfersDrivers.AddRange(response.ResponseData);
|
||||
|
||||
RefreshDatasourceAllTransferToDrivers(transfers);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}).Forget();
|
||||
}
|
||||
|
||||
private void RefreshDatasourceAllTransferToDrivers(IList<Transfer>? transfers)
|
||||
{
|
||||
if (_allTransfersDrivers == null || _allTransfersDrivers.Count == 0 || transfers == null || transfers.Count == 0) return;
|
||||
|
||||
//lock (transfers)
|
||||
{
|
||||
foreach (var transfer in transfers.Where(t => t is { TransferStatusType: >= TransferStatusType.AssignedToDriver, TransferToDrivers.Count: 0 }))
|
||||
{
|
||||
var currentTransferDrivers = _allTransfersDrivers.Where(x => x.TransferId == transfer.Id).ToList();
|
||||
|
||||
if (currentTransferDrivers.Count > 0)
|
||||
transfer.TransferToDrivers.UpdateCollection(currentTransferDrivers, false);
|
||||
}
|
||||
}
|
||||
|
||||
_gridTransfer.Reload();
|
||||
//StateHasChanged();
|
||||
}
|
||||
|
||||
private void OnTransferToDriverChanged(GridDataItemChangedEventArgs<TransferToDriver> args)
|
||||
{
|
||||
_allTransfersDrivers?.UpdateCollection(args.DataItem, args.TrackingState == TrackingState.Remove);
|
||||
_gridTransfer.Reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
var email = string.Empty;
|
||||
var transferToDriverDataItem = ((TransferToDriver)context.DataItem);
|
||||
|
||||
if (HasReadPermission(transferToDriverDataItem.UserProductMappingId))
|
||||
if (transferToDriverDataItem != null && HasReadPermission(transferToDriverDataItem.UserProductMappingId))
|
||||
email = transferToDriverDataItem.UserProductMapping?.User.EmailAddress;
|
||||
}
|
||||
<text>@email</text>
|
||||
|
|
@ -142,7 +142,7 @@
|
|||
var price = string.Empty;
|
||||
var transferToDriverDataItem = ((TransferToDriver)context.DataItem);
|
||||
|
||||
if (HasReadPermission(transferToDriverDataItem.UserProductMappingId))
|
||||
if (transferToDriverDataItem != null && HasReadPermission(transferToDriverDataItem.UserProductMappingId))
|
||||
price = transferToDriverDataItem.Price.ToString("N0");
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +163,7 @@
|
|||
[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 EventCallback<GridDataItemChangedEventArgs<TransferToDriver>> OnTransferToDriverChanged { get; set; }
|
||||
|
||||
[Parameter] public bool CommandColumnVisible { get; set; } = true;
|
||||
[Parameter] public bool NewButtonVisible { get; set; } = true;
|
||||
|
|
@ -227,7 +227,7 @@
|
|||
{
|
||||
//ParentData?.TransferToDrivers?.UpdateCollection(args.DataItem, args.TrackingState == TrackingState.Remove);
|
||||
|
||||
OnTransferToDriverChanged.InvokeAsync(args.DataItem);
|
||||
OnTransferToDriverChanged.InvokeAsync(args);
|
||||
}
|
||||
|
||||
private void DataItemSaving(GridEditModelSavingEventArgs args)
|
||||
|
|
|
|||
|
|
@ -801,6 +801,18 @@ namespace TIAMWebApp.Server.Controllers
|
|||
return result;
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
[Route(APIUrls.GetTransferDriversByTransferIdRouteName)]
|
||||
[SignalR(SignalRTags.GetTransferToDriversByProductId)]
|
||||
public async Task<List<TransferToDriver>> GetTransferToDriversByProductId(Guid productId)
|
||||
{
|
||||
_logger.Debug($"GetTransferToDriversByProductId called; productId: {productId}");
|
||||
|
||||
var result = await _adminDal.GetTransferToDriversByProductIdAsync(productId, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
//[Authorize]
|
||||
//[HttpGet]
|
||||
//[Route(APIUrls.GetTransferDriversByTransferIdRouteName)]
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ builder.Services.AddSingleton<ExchangeRateService>();
|
|||
builder.Services.AddScoped<SmartyStreetsService>();
|
||||
builder.Services.AddScoped<GooglePlacesService>();
|
||||
|
||||
//Eddig a 23kb volt a legnagyobb MaximumReceiveMessageSize! "The default value of MaximumReceiveMessageSize is 32 KB" - J.
|
||||
//Eddig a 32kb volt a legnagyobb MaximumReceiveMessageSize! "The default value of MaximumReceiveMessageSize is 32 KB" - J.
|
||||
builder.Services.AddSignalR(options => options.MaximumReceiveMessageSize = 256 * 1024);//.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData));
|
||||
|
||||
builder.Services.Configure<JsonOptions>(options =>
|
||||
|
|
|
|||
|
|
@ -159,6 +159,10 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string GetTransferDriversByTransferIdRouteName = "GetTransferDriversByTransferId";
|
||||
public const string GetTransferDriversByTransferId = TransferDataAPI + GetTransferDriversByTransferIdRouteName;
|
||||
|
||||
public const string GetTransferToDriversByProductIdRouteName = "GetTransferToDriversByProductId";
|
||||
public const string GetTransferToDriversByProductId = TransferDataAPI + GetTransferToDriversByProductIdRouteName;
|
||||
|
||||
|
||||
//serviceprovider
|
||||
public const string CreateServiceProviderRouteName = "CreateServiceProvider/";
|
||||
public const string CreateServiceProvider = ServiceProviderAPI + CreateServiceProviderRouteName;
|
||||
|
|
|
|||
|
|
@ -102,6 +102,12 @@ namespace TIAMWebApp.Shared.Application.Services
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task GetTransferToDriversByProductIdAsync(Guid productId, Func<ISignalResponseMessage<List<TransferToDriver>?>, Task> responseCallback)
|
||||
=> GetByIdAsync<List<TransferToDriver>?>(SignalRTags.GetTransferToDriversByProductId, responseCallback, [productId]);
|
||||
|
||||
public Task<List<TransferToDriver>?> GetTransferToDriversByProductId(Guid productId)
|
||||
=> GetByIdAsync<List<TransferToDriver>>(SignalRTags.GetTransferToDriversByProductId, productId);
|
||||
|
||||
public async Task<TransferToDriver?> GetTransferDriver(Guid transferDriverId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
|||
|
|
@ -317,10 +317,34 @@ namespace Tiam.Services.Client.Tests
|
|||
//var drivers = await _signalRClient.GetByIdAsync<List<TransferToDriver>>(SignalRTags.GetTransferDriversByTransferId, transferId);
|
||||
var drivers = await _signalRClient.GetTransferDrivers(transferId);
|
||||
|
||||
await TaskHelper.WaitToAsync(() => drivers.Count > 0, 5000, 50);
|
||||
|
||||
//await TaskHelper.WaitToAsync(() => drivers.Count > 0, 5000, 50);
|
||||
|
||||
Assert.IsNotNull(drivers);
|
||||
Assert.IsTrue(drivers.Count > 0);
|
||||
Assert.IsTrue(drivers.All(driver => driver.TransferId == transferId));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task GetTransferDiversByProductIdAsyncTest_ReturnDrivers_WhenHasDrivers()
|
||||
{
|
||||
var transferToDrivers = new List<TransferToDriver>();
|
||||
|
||||
_signalRClient.GetTransferToDriversByProductIdAsync(TiamConstClient.TransferProductId, response =>
|
||||
{
|
||||
if (response.ResponseData == null || response.ResponseData.Count == 0) return Task.CompletedTask;
|
||||
|
||||
transferToDrivers.AddRange(response.ResponseData);
|
||||
return Task.CompletedTask;
|
||||
}).Forget();
|
||||
|
||||
await TaskHelper.WaitToAsync(() => transferToDrivers.Count > 0, 10000, 50);
|
||||
|
||||
//var transferToDrivers = await _signalRClient.GetTransferToDriversByProductId(TiamConstClient.TransferProductId);
|
||||
|
||||
Assert.IsNotNull(transferToDrivers);
|
||||
Assert.IsTrue(transferToDrivers.Count > 0);
|
||||
Assert.IsTrue(transferToDrivers.All(driver => driver.UserProductMapping.ProductId == TiamConstClient.TransferProductId));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue