From 5dd68044a1c5f56105530a0e338416f5beb591e0 Mon Sep 17 00:00:00 2001 From: Loretta Date: Wed, 30 Apr 2025 11:51:31 +0200 Subject: [PATCH] UpdateCollection --- .../TransferToDriverDbSetExtensions.cs | 25 +++++++++++++++++-- .../Controllers/TransferDataAPIController.cs | 9 +++---- .../SignalRClientTest.cs | 3 ++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/TIAM.Database/DbSets/Transfers/TransferToDriverDbSetExtensions.cs b/TIAM.Database/DbSets/Transfers/TransferToDriverDbSetExtensions.cs index b924a75c..1251a877 100644 --- a/TIAM.Database/DbSets/Transfers/TransferToDriverDbSetExtensions.cs +++ b/TIAM.Database/DbSets/Transfers/TransferToDriverDbSetExtensions.cs @@ -10,11 +10,32 @@ namespace TIAM.Database.DbSets.Transfers; public static class TransferToDriverDbSetExtensions { #region TransferToDriver + public static TransferToDriver? GetTransferToDriverById(this ITransferToDriverDbSet ctx, Guid transferToDriverId, bool autoInclude = true) - => ctx.TransferToDrivers.FirstOrDefault(x => x.Id == transferToDriverId); + => ctx.TransferToDrivers + .Where(x => x.Id == transferToDriverId) + .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) + .FirstOrDefault(x => x.Id == transferToDriverId); public static IQueryable GetTransferToDriversByTransferId(this ITransferToDriverDbSet ctx, Guid transferId, bool autoInclude = true) - => ctx.TransferToDrivers.Where(x => x.TransferId == transferId); + => 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); + + //.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 GetTransferToDriversByUpmId(this ITransferToDriverDbSet ctx, Guid upmId, bool autoInclude = true) => ctx.TransferToDrivers.Where(x => x.UserProductMappingId == upmId); diff --git a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs index 7b74507f..d79f9023 100644 --- a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs +++ b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs @@ -766,11 +766,10 @@ namespace TIAMWebApp.Server.Controllers _logger.Debug($"GetTransferDrivers called; transferId: {transferId}"); var result = await _adminDal.GetTransferToDriversByTransferIdAsync(transferId); - if(result == null) - { - _logger.Warning("Null result", "GetTransferDrivers"); - } - return result; + + //System.IO.File.WriteAllText($"h://TiamJsons//{transferId}.json", result.ToJson()); + + return result; } //[Authorize] diff --git a/Tiam.Services.Client.Tests/SignalRClientTest.cs b/Tiam.Services.Client.Tests/SignalRClientTest.cs index de8ec7f1..85455b19 100644 --- a/Tiam.Services.Client.Tests/SignalRClientTest.cs +++ b/Tiam.Services.Client.Tests/SignalRClientTest.cs @@ -308,7 +308,8 @@ namespace Tiam.Services.Client.Tests } [TestMethod] - [DataRow("ddf26c38-933e-45aa-ad1f-76f6affc9fd1")] + //[DataRow("ddf26c38-933e-45aa-ad1f-76f6affc9fd1")] + [DataRow("fe68bac6-b180-4311-8df0-41f3587f28c7")] public async Task GetTransferDiversByTransferIdAsyncTest_ReturnDrivers_WhenHasDrivers(string transferIdString) { var transferId = Guid.Parse(transferIdString);