Implement TransferDestination SignalR crud test;
This commit is contained in:
parent
1e3690f7e8
commit
7779379bd4
|
|
@ -4,7 +4,6 @@ using Newtonsoft.Json;
|
|||
using TIAM.Core.Enums;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAM.Database.DbContexts.Admins;
|
||||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Drivers;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Products;
|
||||
|
|
@ -13,6 +12,7 @@ using TIAM.Models.Dtos.Users;
|
|||
using TIAM.Entities.Transfers;
|
||||
using AyCode.Core.Extensions;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Addresses;
|
||||
|
||||
namespace TIAM.Database.Test
|
||||
{
|
||||
|
|
@ -536,32 +536,9 @@ namespace TIAM.Database.Test
|
|||
var transferDestId = Guid.Parse(transferDestIdaddressIdStrings[0]);
|
||||
var addressId = Guid.Parse(transferDestIdaddressIdStrings[1]);
|
||||
|
||||
var name = "Liszt Ferenc repülőtér";
|
||||
var address = "Budapest, Liszt Ferenc tér";
|
||||
var modifiedAddress = "modified; " + address;
|
||||
|
||||
await Dal.RemoveTransferDestinationAsync(transferDestId, true); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
|
||||
|
||||
var transferDest = new TransferDestination
|
||||
{
|
||||
Id = transferDestId,
|
||||
AddressId = addressId,
|
||||
Name = name,
|
||||
Description = name + "description",
|
||||
Price = 15000,
|
||||
//Price2 = 21000,
|
||||
//Price3 = 23000,
|
||||
//PriceType = PriceType.Fix,
|
||||
Address = new Address
|
||||
{
|
||||
Id = addressId,
|
||||
AddressText = address,
|
||||
IsValid = false,
|
||||
IsHelper = false,
|
||||
Latitude = new Random().NextDouble() + 42d,
|
||||
Longitude = new Random().NextDouble() + 19d
|
||||
}
|
||||
};
|
||||
var transferDest = TestHelper.CreateTransferDestination(transferDestId, addressId);
|
||||
|
||||
Assert.IsTrue(await Dal.AddTransferDestinationAsync(transferDest));
|
||||
Assert.IsNotNull(transferDest);
|
||||
|
|
@ -571,6 +548,8 @@ namespace TIAM.Database.Test
|
|||
Assert.IsNotNull(transferDest);
|
||||
Assert.IsNotNull(transferDest.Address);
|
||||
|
||||
var modifiedAddress = "modified; " + transferDest.Address.AddressText;
|
||||
|
||||
transferDest.Price = 20000;
|
||||
transferDest.Address.AddressText = modifiedAddress;
|
||||
|
||||
|
|
@ -590,6 +569,8 @@ namespace TIAM.Database.Test
|
|||
transferDest = Dal.GetTransferDestinationById(transferDestId);
|
||||
Assert.IsNull(transferDest); //a korábbi törlés miatt NULL kell legyen - J.
|
||||
}
|
||||
|
||||
|
||||
#endregion Transfer
|
||||
|
||||
#region EmailMessage
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Transfers;
|
||||
|
||||
namespace TIAM.Database.Test;
|
||||
|
||||
public static class TestHelper
|
||||
{
|
||||
public static TransferDestination CreateTransferDestination(Guid transferDestId, Guid addressId)
|
||||
{
|
||||
var name = "Liszt Ferenc repülőtér";
|
||||
var address = "Budapest, Liszt Ferenc tér";
|
||||
|
||||
var transferDest = new TransferDestination
|
||||
{
|
||||
Id = transferDestId,
|
||||
AddressId = addressId,
|
||||
Name = name,
|
||||
Description = name + "description",
|
||||
Price = 15000,
|
||||
//Price2 = 21000,
|
||||
//Price3 = 23000,
|
||||
//PriceType = PriceType.Fix,
|
||||
AddressString = address,
|
||||
Address = new Address
|
||||
{
|
||||
Id = addressId,
|
||||
AddressText = address,
|
||||
IsValid = false,
|
||||
IsHelper = false,
|
||||
Latitude = null,
|
||||
Longitude = null
|
||||
}
|
||||
};
|
||||
|
||||
return transferDest;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,8 +75,8 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
|
||||
public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination));
|
||||
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination));
|
||||
public Task<bool> RemoveTransferDestinationAsync(TransferDestination transferDestination, bool removeAddress = false) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestination, removeAddress));
|
||||
public Task<bool> RemoveTransferDestinationAsync(Guid transferDestinationId, bool removeAddress = false) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestinationId, removeAddress));
|
||||
public Task<bool> RemoveTransferDestinationAsync(TransferDestination transferDestination, bool removeAddress) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestination.Id, removeAddress));
|
||||
public Task<bool> RemoveTransferDestinationAsync(Guid transferDestinationId, bool removeAddress) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestinationId, removeAddress));
|
||||
#endregion TransferDestination
|
||||
|
||||
#region TransferToDriver
|
||||
|
|
|
|||
|
|
@ -30,20 +30,20 @@ public static class TransferDbSetExtensions
|
|||
public static IQueryable<Transfer> GetTransfers(this ITransferDbSet ctx)
|
||||
=> ctx.Transfers;
|
||||
|
||||
#region TransferDestination
|
||||
public static TransferDestination? GetTransferDestinationById(this ITransferDestinationDbSet ctx, Guid transferDestinationId)
|
||||
=> ctx.TransferDestinations.FirstOrDefault(x => x.Id == transferDestinationId);
|
||||
|
||||
public static IQueryable<TransferDestination> GetTransferDestinations(this ITransferDestinationDbSet ctx)
|
||||
=> ctx.TransferDestinations;
|
||||
|
||||
#region TransferDestination
|
||||
public static bool AddTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination)
|
||||
=> ctx.TransferDestinations.Add(transferDestination).State == EntityState.Added;
|
||||
|
||||
public static bool UpdateTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination)
|
||||
=> ctx.TransferDestinations.Update(transferDestination).State == EntityState.Modified;
|
||||
|
||||
public static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination, bool removeAddress)
|
||||
private static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination, bool removeAddress)
|
||||
{
|
||||
if (removeAddress) ctx.Addresses.Remove(transferDestination.Address);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,14 +77,15 @@ public class SignalRTags : AcSignalRTags
|
|||
public const int GetProductsById = 76;
|
||||
public const int GetAllProducts = 77;
|
||||
|
||||
public const int CreateTransferDestination = 80;
|
||||
public const int UpdateTransferDestination = 81;
|
||||
public const int DeleteTransferDestination = 82; //set permissions to 0
|
||||
public const int GetAllTransferDestinations = 83;
|
||||
|
||||
public const int GetTransferDestinationById = 80;
|
||||
public const int GetAllTransferDestinations = 81;
|
||||
public const int CreateTransferDestination = 82;
|
||||
public const int UpdateTransferDestination = 83;
|
||||
public const int RemoveTransferDestination = 84; //set permissions to 0
|
||||
|
||||
public const int CreateTransferDestinationToProduct = 90;
|
||||
public const int UpdateTransferDestinationToProduct = 91;
|
||||
public const int DeleteTransferDestinationToProduct = 92; //set permissions to 0
|
||||
public const int RemoveTransferDestinationToProduct = 92; //set permissions to 0
|
||||
public const int GetAllTransferDestinationToProducts = 93;
|
||||
public const int GetTransferDestinationToProductByProductId = 94;
|
||||
public const int GetTransferDestinationToProductByTransferDestinationId = 95;
|
||||
|
|
|
|||
|
|
@ -395,10 +395,8 @@
|
|||
if (SelectedCategories.Count > 0)
|
||||
TagBox_ValuesChanged(SelectedCategories);
|
||||
|
||||
if(!SelectedCategories.Any())
|
||||
SelectedCategories = [Statuses.FirstOrDefault(x => x.StatusValue == (byte)TransferStatusType.Finished)!];
|
||||
|
||||
|
||||
// if(!SelectedCategories.Any())
|
||||
// SelectedCategories = [Statuses.FirstOrDefault(x => x.StatusValue == (byte)TransferStatusType.Finished)!];
|
||||
|
||||
// var filterTransferStatusType = Statuses.FirstOrDefault(x => x.StatusValue == (byte)TransferStatusType.Finished)!;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,19 +27,6 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[Route("api/v1/[controller]")]
|
||||
public class TransferDataAPIController : ControllerBase
|
||||
{
|
||||
//private static readonly TransferDestination[] Names = new TransferDestination[]
|
||||
//{
|
||||
// /*"Castle of Buda", "Hungarian National Museum", "Parliament of Hungary", "Heroes square", "Gellert Hill", "Margaret Island"*/
|
||||
// new() { DestinationId = 1, DestinationName = "Airport", DestinationDescription = "International airport of Budapest", DestinationLatitude = 42.234444f, DestinationLongitude = 39.100010f },
|
||||
// new() { DestinationId = 2, DestinationName = "Castle of Buda", DestinationDescription = "International airport of Budapest", DestinationLatitude = 42.234444f, DestinationLongitude = 39.100010f },
|
||||
// new() { DestinationId = 3, DestinationName = "Hungarian National Museum", DestinationDescription = "International airport of Budapest", DestinationLatitude = 42.234444f, DestinationLongitude = 39.100010f },
|
||||
// new() { DestinationId = 4, DestinationName = "Parliament of Hungary", DestinationDescription = "International airport of Budapest", DestinationLatitude = 42.234444f, DestinationLongitude = 39.100010f },
|
||||
// new() { DestinationId = 5, DestinationName = "Heroes square", DestinationDescription = "International airport of Budapest", DestinationLatitude = 42.234444f, DestinationLongitude = 39.100010f },
|
||||
// new() { DestinationId = 6, DestinationName = "Gellert Hill", DestinationDescription = "International airport of Budapest", DestinationLatitude = 42.234444f, DestinationLongitude = 39.100010f },
|
||||
// new() { DestinationId = 6, DestinationName = "Margaret Island", DestinationDescription = "International airport of Budapest", DestinationLatitude = 42.234444f, DestinationLongitude = 39.100010f }
|
||||
|
||||
//};
|
||||
|
||||
private readonly AdminDal _adminDal;
|
||||
private readonly TIAM.Core.Loggers.ILogger _logger;
|
||||
private readonly TransferBackendService _transferBackendService;
|
||||
|
|
@ -66,6 +53,16 @@ namespace TIAMWebApp.Server.Controllers
|
|||
return await _adminDal.Context.TransferDestinations.ToListAsync();
|
||||
}
|
||||
|
||||
//[Authorize]
|
||||
//[HttpGet]
|
||||
//[Route(APIUrls.GetTransferDriversByTransferIdRouteName)]
|
||||
[SignalR(SignalRTags.GetTransferDestinationById)]
|
||||
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId)
|
||||
{
|
||||
var transferDestination = _adminDal.GetTransferDestinationById(transferDestinationId);
|
||||
return transferDestination;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetTransferDestinationByCoordinates")]
|
||||
|
|
@ -85,124 +82,180 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.CreateTransferDestinationRouteName)]
|
||||
public async Task<IActionResult> CreateTransferDestination([FromBody] JsonElement serializedTransferDestinationModel)
|
||||
[SignalR(SignalRTags.CreateTransferDestination)]
|
||||
public async Task<TransferDestination?> CreateTransferDestination([FromBody] TransferDestination transferDestination)
|
||||
{
|
||||
_logger.Info(@"CreateTransferDestination called!");
|
||||
if (string.IsNullOrEmpty(serializedTransferDestinationModel.GetRawText()))
|
||||
|
||||
var isSuccess = false;
|
||||
if (string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||
{
|
||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||
var logText = $"string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString); Name: {transferDestination.Name}; AddressString: {transferDestination.AddressString}";
|
||||
|
||||
_logger.Error(logText);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransferDestination? transferDestination = JObject.Parse(serializedTransferDestinationModel.GetRawText()).ToObject<TransferDestination>();
|
||||
|
||||
if (transferDestination != null)
|
||||
{
|
||||
|
||||
var id = Guid.NewGuid();
|
||||
//TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug(transferDestination.ToString());
|
||||
|
||||
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||
await _adminDal.AddTransferDestinationAsync(transferDestination);
|
||||
return Ok(transferDestination);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
|
||||
|
||||
if (transferDestination.Id.IsNullOrEmpty()) transferDestination.Id = Guid.NewGuid();
|
||||
isSuccess = await _adminDal.AddTransferDestinationAsync(transferDestination);
|
||||
}
|
||||
|
||||
|
||||
return isSuccess ? transferDestination : null;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.UpdateTransferDestinationRouteName)]
|
||||
public async Task<IActionResult> UpdateTransferDestination([FromBody] JsonElement serializedTransferDestination)
|
||||
[SignalR(SignalRTags.UpdateTransferDestination)]
|
||||
public async Task<TransferDestination?> UpdateTransferDestination([FromBody] TransferDestination transferDestination)
|
||||
{
|
||||
_logger.Info(@"UpdateTransferDestination called!");
|
||||
if (string.IsNullOrEmpty(serializedTransferDestination.GetRawText()))
|
||||
|
||||
var isSuccess = false;
|
||||
if (transferDestination.Id.IsNullOrEmpty() || string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||
{
|
||||
_logger.Error(@"Bad request!");
|
||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Info(@"Serialized model not empty!");
|
||||
TransferDestination? transferDestination = JObject.Parse(serializedTransferDestination.GetRawText()).ToObject<TransferDestination>();
|
||||
_logger.Info($@"TransferDestination to be updated: {serializedTransferDestination.GetRawText()}");
|
||||
_logger.Info($@"TransferDestination to be updated: {transferDestination.AddressString}");
|
||||
|
||||
|
||||
if (transferDestination != null)
|
||||
{
|
||||
|
||||
|
||||
//TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
||||
|
||||
if (transferDestination.Id == Guid.Empty || string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||
{
|
||||
_logger.Error(@"Serialized model not empty, but bad request!");
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_logger.Info($@"TransferDestination to be updated: {transferDestination.Id}");
|
||||
_logger.Info($@"TransferDestination to be updated new name: {transferDestination.Name}");
|
||||
_logger.Info($@"TransferDestination to be updated new price: {transferDestination.Price}");
|
||||
//Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price2}");
|
||||
//Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price3}");
|
||||
//Console.WriteLine($"TransferDestination to be updated new priceType: {transferDestination.PriceType}");
|
||||
_logger.Info($@"TransferDestination to be updated new address: {transferDestination.AddressString}");
|
||||
_logger.Info($@"TransferDestination to be updated new description: {transferDestination.Description}");
|
||||
|
||||
//var dbTransferDestinationJson = _adminDal.GetTransferDestinationJsonById(transferDestination.Id);
|
||||
//_logger.Info($"TransferDestination JSON to be updated: {dbTransferDestinationJson}");
|
||||
|
||||
//var dbTransferDestination = JObject.Parse(dbTransferDestinationJson).ToObject<TransferDestination>();
|
||||
|
||||
//var dbTransferDestination = _adminDal.GetTransferDestinationById(transferDestination.Id, true);
|
||||
//if (dbTransferDestination.Id != Guid.Empty)
|
||||
//{
|
||||
// dbTransferDestination.AddressId = transferDestination.AddressId;
|
||||
// dbTransferDestination.Price = transferDestination.Price;
|
||||
// dbTransferDestination.PriceType = transferDestination.PriceType;
|
||||
// dbTransferDestination.Name = transferDestination.Name;
|
||||
// dbTransferDestination.Description = transferDestination.Description;
|
||||
// dbTransferDestination.AddressString = transferDestination.AddressString;
|
||||
// dbTransferDestination.Address = transferDestination.Address;
|
||||
|
||||
//}
|
||||
|
||||
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||
await _adminDal.UpdateTransferDestinationAsync(transferDestination);
|
||||
return Ok(transferDestination);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
|
||||
|
||||
var logText = $"transferDestination.Id.IsNullOrEmpty() || string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString); Id: {transferDestination.Id}; Name: {transferDestination.Name}; AddressString: {transferDestination.AddressString}";
|
||||
|
||||
_logger.Error(logText);
|
||||
}
|
||||
else isSuccess = await _adminDal.UpdateTransferDestinationAsync(transferDestination);
|
||||
|
||||
return isSuccess ? transferDestination : null;
|
||||
|
||||
}
|
||||
|
||||
//[Authorize]
|
||||
//[HttpGet]
|
||||
//[Route(APIUrls.GetTransferDriversByTransferIdRouteName)]
|
||||
[SignalR(SignalRTags.RemoveTransferDestination)]
|
||||
public async Task<TransferDestination?> RemoveTransferDestination([FromBody] TransferDestination transferDestination)
|
||||
{
|
||||
var result = await _adminDal.RemoveTransferDestinationAsync(transferDestination, true);
|
||||
return result ? transferDestination : null;
|
||||
}
|
||||
|
||||
|
||||
//[AllowAnonymous]
|
||||
//[HttpPost]
|
||||
//[Route(APIUrls.CreateTransferDestinationRouteName)]
|
||||
//public async Task<IActionResult> CreateTransferDestination([FromBody] JsonElement serializedTransferDestinationModel)
|
||||
//{
|
||||
// _logger.Info(@"CreateTransferDestination called!");
|
||||
// if (string.IsNullOrEmpty(serializedTransferDestinationModel.GetRawText()))
|
||||
// {
|
||||
// return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TransferDestination? transferDestination = JObject.Parse(serializedTransferDestinationModel.GetRawText()).ToObject<TransferDestination>();
|
||||
|
||||
// if (transferDestination != null)
|
||||
// {
|
||||
|
||||
// var id = Guid.NewGuid();
|
||||
// //TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
||||
|
||||
|
||||
// if (string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||
// {
|
||||
// return BadRequest("Invalid request");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _logger.Debug(transferDestination.ToString());
|
||||
|
||||
// //await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||
// await _adminDal.AddTransferDestinationAsync(transferDestination);
|
||||
// return Ok(transferDestination);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return BadRequest("Invalid request");
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
|
||||
//[AllowAnonymous]
|
||||
//[HttpPost]
|
||||
//[Route(APIUrls.UpdateTransferDestinationRouteName)]
|
||||
//public async Task<IActionResult> UpdateTransferDestination([FromBody] JsonElement serializedTransferDestination)
|
||||
//{
|
||||
// _logger.Info(@"UpdateTransferDestination called!");
|
||||
// if (string.IsNullOrEmpty(serializedTransferDestination.GetRawText()))
|
||||
// {
|
||||
// _logger.Error(@"Bad request!");
|
||||
// return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _logger.Info(@"Serialized model not empty!");
|
||||
// TransferDestination? transferDestination = JObject.Parse(serializedTransferDestination.GetRawText()).ToObject<TransferDestination>();
|
||||
// _logger.Info($@"TransferDestination to be updated: {serializedTransferDestination.GetRawText()}");
|
||||
// _logger.Info($@"TransferDestination to be updated: {transferDestination.AddressString}");
|
||||
|
||||
|
||||
// if (transferDestination != null)
|
||||
// {
|
||||
|
||||
|
||||
// //TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
||||
|
||||
// if (transferDestination.Id == Guid.Empty || string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||
// {
|
||||
// _logger.Error(@"Serialized model not empty, but bad request!");
|
||||
// return BadRequest("Invalid request");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// _logger.Info($@"TransferDestination to be updated: {transferDestination.Id}");
|
||||
// _logger.Info($@"TransferDestination to be updated new name: {transferDestination.Name}");
|
||||
// _logger.Info($@"TransferDestination to be updated new price: {transferDestination.Price}");
|
||||
// //Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price2}");
|
||||
// //Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price3}");
|
||||
// //Console.WriteLine($"TransferDestination to be updated new priceType: {transferDestination.PriceType}");
|
||||
// _logger.Info($@"TransferDestination to be updated new address: {transferDestination.AddressString}");
|
||||
// _logger.Info($@"TransferDestination to be updated new description: {transferDestination.Description}");
|
||||
|
||||
// //var dbTransferDestinationJson = _adminDal.GetTransferDestinationJsonById(transferDestination.Id);
|
||||
// //_logger.Info($"TransferDestination JSON to be updated: {dbTransferDestinationJson}");
|
||||
|
||||
// //var dbTransferDestination = JObject.Parse(dbTransferDestinationJson).ToObject<TransferDestination>();
|
||||
|
||||
// //var dbTransferDestination = _adminDal.GetTransferDestinationById(transferDestination.Id, true);
|
||||
// //if (dbTransferDestination.Id != Guid.Empty)
|
||||
// //{
|
||||
// // dbTransferDestination.AddressId = transferDestination.AddressId;
|
||||
// // dbTransferDestination.Price = transferDestination.Price;
|
||||
// // dbTransferDestination.PriceType = transferDestination.PriceType;
|
||||
// // dbTransferDestination.Name = transferDestination.Name;
|
||||
// // dbTransferDestination.Description = transferDestination.Description;
|
||||
// // dbTransferDestination.AddressString = transferDestination.AddressString;
|
||||
// // dbTransferDestination.Address = transferDestination.Address;
|
||||
|
||||
// //}
|
||||
|
||||
// //await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||
// await _adminDal.UpdateTransferDestinationAsync(transferDestination);
|
||||
// return Ok(transferDestination);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return BadRequest("Invalid request");
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.CreateTransferRouteName)]
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ using AyCode.Services.Loggers;
|
|||
using AyCode.Services.SignalRs;
|
||||
using Azure;
|
||||
using TIAM.Core.Loggers;
|
||||
using TIAM.Database.Test;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAM.Services;
|
||||
using TIAMWebApp.Shared.Application.Services;
|
||||
using TIAMWebApp.Shared.Application.Utility;
|
||||
|
|
@ -88,5 +90,44 @@ namespace Tiam.Services.Client.Tests
|
|||
Assert.IsNotNull(companies);
|
||||
Assert.IsTrue(companies.Count > 0);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(["cfb27fc2-54c2-4f07-8471-587d6b79b019", "7385c4e3-3c1e-4c5e-9926-8c0ea60dcb38"])]
|
||||
public async Task TransferDestinationCrudTest(string[] transferDestIdaddressIdStrings)
|
||||
{
|
||||
var transferDestId = Guid.Parse(transferDestIdaddressIdStrings[0]);
|
||||
var addressId = Guid.Parse(transferDestIdaddressIdStrings[1]);
|
||||
|
||||
var transferDest = TestHelper.CreateTransferDestination(transferDestId, addressId);
|
||||
|
||||
await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestination, transferDest);
|
||||
|
||||
transferDest = await _signalRClient.PostDataAsync(SignalRTags.CreateTransferDestination, transferDest);
|
||||
Assert.IsNotNull(transferDest);
|
||||
|
||||
transferDest = await _signalRClient.GetByIdAsync<TransferDestination>(SignalRTags.GetTransferDestinationById, transferDestId);
|
||||
|
||||
Assert.IsNotNull(transferDest);
|
||||
Assert.IsNotNull(transferDest.Address);
|
||||
|
||||
var modifiedAddress = "modified; " + transferDest.Address.AddressText;
|
||||
|
||||
transferDest.Price = 20000;
|
||||
transferDest.Address.AddressText = modifiedAddress;
|
||||
|
||||
transferDest = await _signalRClient.PostDataAsync(SignalRTags.UpdateTransferDestination, transferDest);
|
||||
|
||||
Assert.IsNotNull(transferDest);
|
||||
Assert.IsNotNull(transferDest.Address);
|
||||
|
||||
Assert.IsTrue((int)transferDest.Price == 20000);
|
||||
Assert.IsTrue(transferDest.Address.AddressText == modifiedAddress);
|
||||
Assert.IsTrue(transferDest.Id == transferDestId, "transferDest.Id != transferDestId");
|
||||
|
||||
await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestination, transferDest); //mielõbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||
|
||||
transferDest = await _signalRClient.GetByIdAsync<TransferDestination>(SignalRTags.GetTransferDestinationById, transferDestId);
|
||||
Assert.IsNull(transferDest); //a korábbi törlés miatt NULL kell legyen - J.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ using Newtonsoft.Json;
|
|||
using Newtonsoft.Json.Linq;
|
||||
using TIAM.Core.Loggers;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAM.Database.Test;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAM.Services;
|
||||
|
|
@ -80,6 +81,7 @@ namespace Tiam.Services.Client.Tests
|
|||
Assert.IsTrue(dbTransfer.LuggageCount == luggageCount);
|
||||
}
|
||||
|
||||
|
||||
[DataTestMethod]
|
||||
public void FilterExpressionTest_WhenTransfersFiletered()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<ProjectReference Include="..\..\Aycode.Blazor\AyCode.Blazor.Models\AyCode.Blazor.Models.csproj" />
|
||||
<ProjectReference Include="..\..\Aycode.Blazor\AyCode.Maui.Core\AyCode.Maui.Core.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Database.Test\TIAM.Database.Test.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Models\TIAM.Models.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Services\TIAM.Services.csproj" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue