UpdateCollection

This commit is contained in:
Loretta 2025-04-30 11:51:31 +02:00
parent 1378e0199e
commit 5dd68044a1
3 changed files with 29 additions and 8 deletions

View File

@ -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<TransferToDriver> 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<TransferToDriver> GetTransferToDriversByUpmId(this ITransferToDriverDbSet ctx, Guid upmId, bool autoInclude = true)
=> ctx.TransferToDrivers.Where(x => x.UserProductMappingId == upmId);

View File

@ -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]

View File

@ -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);