improvements, fixes, etc...
This commit is contained in:
parent
7779379bd4
commit
d76cdb68b1
|
|
@ -531,10 +531,10 @@ namespace TIAM.Database.Test
|
|||
|
||||
[DataTestMethod]
|
||||
[DataRow(["069089cd-66d4-4f0d-851b-2eea14fa62a4", "be709d9b-87dc-4c94-bf9e-d6254db3fa3e"])]
|
||||
public async Task TransferDestinationCrudTest(string[] transferDestIdaddressIdStrings)
|
||||
public async Task TransferDestinationCrudTest(string[] transferDestIdAddressIdStrings)
|
||||
{
|
||||
var transferDestId = Guid.Parse(transferDestIdaddressIdStrings[0]);
|
||||
var addressId = Guid.Parse(transferDestIdaddressIdStrings[1]);
|
||||
var transferDestId = Guid.Parse(transferDestIdAddressIdStrings[0]);
|
||||
var addressId = Guid.Parse(transferDestIdAddressIdStrings[1]);
|
||||
|
||||
await Dal.RemoveTransferDestinationAsync(transferDestId, true); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
|
||||
#region TransferDestination
|
||||
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx=>ctx.GetTransferDestinationById(transferDestinationId));
|
||||
public Task<TransferDestination?> GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx=>ctx.GetTransferDestinationById(transferDestinationId));
|
||||
public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson());
|
||||
|
||||
public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination));
|
||||
|
|
@ -97,7 +98,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
|
||||
public Task<bool> AddTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.AddTransferDestinationToProduct(transferDestinationToProduct));
|
||||
public Task<bool> UpdateTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.UpdateTransferDestinationToProduct(transferDestinationToProduct));
|
||||
public Task<bool> RemoveTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.RemoveTransferDestinationToProduct(transferDestinationToProduct));
|
||||
public Task<bool> RemoveTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.RemoveTransferDestinationToProduct(transferDestinationToProduct.Id));
|
||||
public Task<bool> RemoveTransferDestinationToProductAsync(Guid transferDestinationToProductId) => TransactionAsync(ctx => ctx.RemoveTransferDestinationToProduct(transferDestinationToProductId));
|
||||
#endregion TransferDestinationToProduct
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Database.DbSets.Profiles;
|
||||
using TIAM.Database.DbSets.Transfers;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Products;
|
||||
|
||||
namespace TIAM.Database.DbSets.Products;
|
||||
|
||||
public interface IProductDbSet : IProfileDbSet, IUserProductMappingDbSet
|
||||
public interface IProductDbSet : IProfileDbSet, IUserProductMappingDbSet, ITransferDestinationDbSet
|
||||
{
|
||||
public DbSet<Product> Products { get; set; }
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ using AyCode.Interfaces.Entities;
|
|||
using AyCode.Interfaces.Profiles;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using TIAM.Database.DbSets.Transfers;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Products;
|
||||
|
|
@ -39,6 +40,7 @@ public static class ProductDbSetExtensions
|
|||
{
|
||||
ctx.RemoveProfile(product.ProfileId);
|
||||
ctx.RemoveUserProductMappingsByProductId(product.Id);
|
||||
ctx.RemoveTransferDestinationToProductByProductId(product.Id);
|
||||
|
||||
//TODO: Transfer, etc... - J.
|
||||
return ctx.Products.Remove(product).State == EntityState.Deleted;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public static class TransferDbSetExtensions
|
|||
{
|
||||
if (removeAddress) ctx.Addresses.Remove(transferDestination.Address);
|
||||
|
||||
ctx.RemoveTransferDestinationToProductByTransferDestinationId(transferDestination.Id);
|
||||
return ctx.TransferDestinations.Remove(transferDestination).State == EntityState.Deleted;
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ public static class TransferDbSetExtensions
|
|||
public static bool UpdateTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, TransferDestinationToProduct transferDestinationToProduct)
|
||||
=> ctx.TransferDestinationToProducts.Update(transferDestinationToProduct).State == EntityState.Modified;
|
||||
|
||||
public static bool RemoveTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, TransferDestinationToProduct transferDestinationToProduct)
|
||||
private static bool RemoveTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, TransferDestinationToProduct transferDestinationToProduct)
|
||||
{
|
||||
return ctx.TransferDestinationToProducts.Remove(transferDestinationToProduct).State == EntityState.Deleted;
|
||||
}
|
||||
|
|
@ -80,5 +81,18 @@ public static class TransferDbSetExtensions
|
|||
var transferDestinationToProduct = ctx.GetTransferDestinationToProductById(transferDestinationToProductId);
|
||||
return transferDestinationToProduct == null || ctx.RemoveTransferDestinationToProduct(transferDestinationToProduct);
|
||||
}
|
||||
|
||||
public static bool RemoveTransferDestinationToProductByProductId(this ITransferDestinationToProductDbSet ctx, Guid productId)
|
||||
{
|
||||
ctx.TransferDestinationToProducts.RemoveRange(ctx.TransferDestinationToProducts.Where(x => x.ProductId == productId));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool RemoveTransferDestinationToProductByTransferDestinationId(this ITransferDestinationToProductDbSet ctx, Guid transferDestinationId)
|
||||
{
|
||||
ctx.TransferDestinationToProducts.RemoveRange(ctx.TransferDestinationToProducts.Where(x => x.TransferDestinationId == transferDestinationId));
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion TransferDestinationToProduct
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
Click="ColumnChooserButton_Click" />
|
||||
</div>
|
||||
|
||||
<TransferDestinationToProductGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllTransferDestinationToProducts"></TransferDestinationToProductGridComponent>
|
||||
<TransferDestinationToProductGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto"></TransferDestinationToProductGridComponent>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@
|
|||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using AyCode.Interfaces.Addresses
|
||||
@using AyCode.Core
|
||||
@using AyCode.Core.Extensions
|
||||
@inject IStringLocalizer<TIAMResources> Localizer
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient AdminSignalRClient;
|
||||
|
||||
|
||||
<ProductDetailGrid @ref="_productGrid"
|
||||
ContextIds="new[] {ContextId}"
|
||||
ContextIds="@(ContextId.IsNullOrEmpty() ? throw new InvalidDataException($"ContextId.IsNullOrEmpty(); ContextId: {ContextId}") : [ContextId.Value])"
|
||||
DataSource="ParentData?.Products ?? []"
|
||||
GetAllMessageTag="GetAllTag"
|
||||
Logger="_logger"
|
||||
|
|
@ -85,7 +86,7 @@
|
|||
|
||||
@code {
|
||||
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
|
||||
[Parameter] public Guid ContextId { get; set; }
|
||||
[Parameter] public Guid? ContextId { get; set; }
|
||||
[Parameter] public IProductsRelation? ParentData { get; set; } = null!;
|
||||
[Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; }
|
||||
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByContextId;
|
||||
|
|
|
|||
|
|
@ -10,26 +10,25 @@
|
|||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Loggers
|
||||
@using AyCode.Core
|
||||
@using AyCode.Core.Extensions
|
||||
@using TIAMSharedUI.Shared.Components.Grids
|
||||
@inject IServiceProviderDataService ServiceProviderDataService
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient AdminSignalRClient;
|
||||
|
||||
<TransferDestinationToProductGrid
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
ContextIds="ContextIds"
|
||||
PageSize="5"
|
||||
AutoExpandAllGroupRows="true"
|
||||
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
||||
KeyFieldName="Id"
|
||||
ValidationEnabled="false"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||
ShowFilterRow="true">
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
ContextIds="@(ContextId.IsNullOrEmpty() ? throw new InvalidDataException($"ContextId.IsNullOrEmpty(); ContextId: {ContextId}") : [ContextId.Value])"
|
||||
PageSize="10"
|
||||
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
||||
KeyFieldName="Id"
|
||||
ValidationEnabled="false"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn">
|
||||
<Columns>
|
||||
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
||||
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
||||
<DxGridDataColumn FieldName="ProductId" />
|
||||
<DxGridDataColumn FieldName="TransferDestinationId"/>
|
||||
<DxGridDataColumn FieldName="Price" />
|
||||
|
|
@ -38,37 +37,30 @@
|
|||
<DxGridDataColumn FieldName="ProductCommis" />
|
||||
</Columns>
|
||||
<DetailRowTemplate>
|
||||
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Partner">
|
||||
|
||||
</DxTabPage>
|
||||
|
||||
</DxTabs>
|
||||
|
||||
|
||||
</DetailRowTemplate>
|
||||
<EditFormTemplate Context="EditFormContext">
|
||||
<EditFormTemplate Context="editFormContext">
|
||||
@{
|
||||
var serviceProvider = (Company)EditFormContext.EditModel;
|
||||
var transferDestinationToProduct = (TransferDestinationToProduct)editFormContext.EditModel;
|
||||
}
|
||||
<DxFormLayout CssClass="w-100">
|
||||
<DxFormLayoutItem Caption="Price" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Price")
|
||||
@editFormContext.GetEditor("Price")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Price2" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Price2")
|
||||
@editFormContext.GetEditor("Price2")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Price3" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Price3")
|
||||
@editFormContext.GetEditor("Price3")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Commission rate" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("ProductCommis")
|
||||
@editFormContext.GetEditor("ProductCommis")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
|
||||
|
||||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
|
||||
|
|
@ -79,65 +71,12 @@
|
|||
|
||||
[Parameter] public Guid? ContextId { get; set; }
|
||||
|
||||
[Parameter] public int GetAllTag { get; set; }
|
||||
|
||||
public Guid[]? ContextIds = new Guid[1];
|
||||
|
||||
private LoggerClient<TransferDestinationToProductGridComponent> _logger = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<TransferDestinationToProductGridComponent>(LogWriters.ToArray());
|
||||
|
||||
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
|
||||
//_detailGridData = UserModelDtoDetail.ServiceProviders ?? [];
|
||||
//_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync();
|
||||
|
||||
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
ContextIds[0] = (Guid)ContextId!;
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
// void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
// {
|
||||
// if (!e.IsNew) return;
|
||||
|
||||
// var newProductMapping = new UserProductMapping
|
||||
// {
|
||||
// ProductId = Guid.NewGuid(),
|
||||
// UserId = UserModelDtoDetail.Id,
|
||||
// Permissions = 1
|
||||
// };
|
||||
|
||||
// e.EditModel = newProductMapping;
|
||||
// }
|
||||
|
||||
// async Task EditModelSaving(GridEditModelSavingEventArgs e)
|
||||
// {
|
||||
// if (e.IsNew)
|
||||
// //add new orderData to orderData array
|
||||
// _logger.Info("New orderData added");
|
||||
// else
|
||||
// _logger.Info("orderData updated");
|
||||
|
||||
// await UpdateDataAsync();
|
||||
// }
|
||||
|
||||
// async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
||||
// {
|
||||
// //remove orderData from orderData array
|
||||
// _logger.Info("orderData deleted");
|
||||
// //await UpdateDataAsync();
|
||||
// }
|
||||
|
||||
// async Task UpdateDataAsync()
|
||||
// {
|
||||
// //refresh grid
|
||||
// _logger.Info("orderData grid refreshed");
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -9,10 +9,10 @@ public class TransferDestinationToProductGrid : TiamGrid<TransferDestinationToPr
|
|||
{
|
||||
public TransferDestinationToProductGrid() : base()
|
||||
{
|
||||
GetAllMessageTag = SignalRTags.GetProductsByContextId;
|
||||
AddMessageTag = SignalRTags.AddProduct;
|
||||
UpdateMessageTag = SignalRTags.UpdateProduct;
|
||||
RemoveMessageTag = SignalRTags.RemoveProduct;
|
||||
GetAllMessageTag = SignalRTags.GetAllTransferDestinationToProducts;
|
||||
AddMessageTag = SignalRTags.CreateTransferDestinationToProduct;
|
||||
UpdateMessageTag = SignalRTags.UpdateTransferDestinationToProduct;
|
||||
RemoveMessageTag = SignalRTags.RemoveTransferDestinationToProduct;
|
||||
}
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ namespace TIAMWebApp.Server.Controllers
|
|||
//[HttpGet]
|
||||
//[Route(APIUrls.GetTransferDriversByTransferIdRouteName)]
|
||||
[SignalR(SignalRTags.GetTransferDestinationById)]
|
||||
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId)
|
||||
public async Task<TransferDestination?> GetTransferDestinationById(Guid transferDestinationId)
|
||||
{
|
||||
var transferDestination = _adminDal.GetTransferDestinationById(transferDestinationId);
|
||||
var transferDestination = await _adminDal.GetTransferDestinationByIdAsync(transferDestinationId);
|
||||
return transferDestination;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,10 +93,10 @@ namespace Tiam.Services.Client.Tests
|
|||
|
||||
[DataTestMethod]
|
||||
[DataRow(["cfb27fc2-54c2-4f07-8471-587d6b79b019", "7385c4e3-3c1e-4c5e-9926-8c0ea60dcb38"])]
|
||||
public async Task TransferDestinationCrudTest(string[] transferDestIdaddressIdStrings)
|
||||
public async Task TransferDestinationCrudTest(string[] transferDestIdAddressIdStrings)
|
||||
{
|
||||
var transferDestId = Guid.Parse(transferDestIdaddressIdStrings[0]);
|
||||
var addressId = Guid.Parse(transferDestIdaddressIdStrings[1]);
|
||||
var transferDestId = Guid.Parse(transferDestIdAddressIdStrings[0]);
|
||||
var addressId = Guid.Parse(transferDestIdAddressIdStrings[1]);
|
||||
|
||||
var transferDest = TestHelper.CreateTransferDestination(transferDestId, addressId);
|
||||
|
||||
|
|
@ -129,5 +129,44 @@ namespace Tiam.Services.Client.Tests
|
|||
transferDest = await _signalRClient.GetByIdAsync<TransferDestination>(SignalRTags.GetTransferDestinationById, transferDestId);
|
||||
Assert.IsNull(transferDest); //a korábbi törlés miatt NULL kell legyen - J.
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(["cfb27fc2-54c2-4f07-8471-587d6b79b019", "7385c4e3-3c1e-4c5e-9926-8c0ea60dcb38"])]
|
||||
public async Task TransferDestinationToProductCrudTest(string[] transferDestIdAddressIdStrings)
|
||||
{
|
||||
var transferDestId = Guid.Parse(transferDestIdAddressIdStrings[0]);
|
||||
var addressId = Guid.Parse(transferDestIdAddressIdStrings[1]);
|
||||
|
||||
var transferDest = TestHelper.CreateTransferDestination(transferDestId, addressId);
|
||||
|
||||
await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestinationToProduct, 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.
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue