improvements, fixes, etc...

This commit is contained in:
Loretta 2024-06-24 07:07:57 +02:00
parent 2ee5967d67
commit 0c504f2ca5
23 changed files with 229 additions and 104 deletions

View File

@ -12,6 +12,7 @@ using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using AyCode.Core.Extensions; using AyCode.Core.Extensions;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
@ -222,6 +223,48 @@ namespace TIAM.Database.Test
#endregion UserProductMapping #endregion UserProductMapping
#region Product
//[DataTestMethod]
//[DataRow(["e24f6942-2210-47d7-8660-ace0ef302bae", "8e6a4170-0e15-4f8a-bdd2-46f9dbc63b93", "540271F6-C604-4C16-8160-D5A7CAFEDF00", "49c7805b-d8cd-4308-b1c5-7a54e5ee6287"])]
public async Task ProductCrudTest(string[] productIdCompanyIdUserIdUserToCompanyIdStrings)
{
var productId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[0]);
var companyId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[1]);
var userId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[2]); //test@tiam.hu
var userToCompanyId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[3]);
await Dal.RemoveProductAsync(productId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var company = new Company(companyId, "Test unit company...", null);
Assert.IsTrue(await Dal.AddCompanyAsync(company));
Assert.IsNotNull(company);
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsTrue(company.UserToServiceProviders.Count == 0);
Assert.IsTrue(company.Id == companyId);
company.OwnerId = userId;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsNotNull(company.UserToServiceProviders);
Assert.IsTrue(company.UserToServiceProviders.Any(x=>x.UserId == userId && x.ServiceProviderId == companyId));
company.CommissionPercent = 5;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
Assert.IsTrue(await Dal.RemoveCompanyAsync(company)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNull(company); //a korábbi törlés miatt NULL kell legyen - J.
}
#endregion Product
[DataTestMethod] [DataTestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
[DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")] [DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")]
@ -297,6 +340,47 @@ namespace TIAM.Database.Test
Assert.IsTrue(users.Count > 0); Assert.IsTrue(users.Count > 0);
} }
#region Company
[DataTestMethod]
[DataRow(["8e6a4170-0e15-4f8a-bdd2-46f9dbc63b93", "540271F6-C604-4C16-8160-D5A7CAFEDF00", "49c7805b-d8cd-4308-b1c5-7a54e5ee6287"])]
public async Task CompanyCrudTest(string[] companyIdUserIdUserToCompanyIdStrings)
{
var companyId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[0]);
var userId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[1]); //test@tiam.hu
var userToCompanyId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[2]);
await Dal.RemoveCompanyAsync(companyId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var company = new Company(companyId, "Test unit company...", null);
Assert.IsTrue(await Dal.AddCompanyAsync(company));
Assert.IsNotNull(company);
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsTrue(company.UserToServiceProviders.Count == 0);
Assert.IsTrue(company.Id == companyId);
company.OwnerId = userId;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsNotNull(company.UserToServiceProviders);
Assert.IsTrue(company.UserToServiceProviders.Any(x=>x.UserId == userId && x.ServiceProviderId == companyId));
company.CommissionPercent = 5;
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
Assert.IsTrue(await Dal.RemoveCompanyAsync(company)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNull(company); //a korábbi törlés miatt NULL kell legyen - J.
}
#endregion Company
#region Transfer #region Transfer
[DataTestMethod] [DataTestMethod]
[DataRow("6216f9fb-1dda-44bd-9d85-431f3cb09fde")] [DataRow("6216f9fb-1dda-44bd-9d85-431f3cb09fde")]

View File

@ -119,12 +119,13 @@ namespace TIAM.Database.DataLayers.Admins
public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers)); public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson()); public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToList()); public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToList());
public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson()); public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToJson());
public Task<bool> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product)); public Task<bool> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
public Task<bool> UpdateProductAsync(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product)); public Task<bool> UpdateProductAsync(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product));
public Task<bool> RemoveProductAsync(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product)); public Task<bool> RemoveProductAsync(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product));
public Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId));
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude)); public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude)); public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
@ -215,26 +216,17 @@ namespace TIAM.Database.DataLayers.Admins
#endregion EmailMessage #endregion EmailMessage
#region ServiceProviders
//15. (IServiceProviderDataService) Create service provider //15. (IServiceProviderDataService) Create service provider
public Task<bool> CreateServiceProviderAsync(Company serviceProvider) => TransactionAsync(ctx => ctx.AddServiceProvider<Company, Profile, Address>(serviceProvider)); public Task<bool> AddCompanyAsync(Company serviceProvider) => TransactionAsync(ctx => ctx.AddCompany<Company, Profile, Address>(serviceProvider));
//public bool CreateProductAsync(Product product) public Task<List<Company>> GetCompaniesAsync() => SessionAsync(ctx => ctx.GetCompanies().ToList());
//{
// Context.CreateProduct(product);
// GlobalLogger.Info($@"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
// var result = Context.SaveChangesAsync();
// return result.Result > 0;
//}
public Task<List<Company>> GetServiceProvidersAsync() => SessionAsync(ctx => ctx.GetServiceProviders().ToList()); public Task<string> GetCompaniesJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson());
public string GetCompaniesJson() => Session(ctx => ctx.Companies.ToJson());
public Task<string> GetServiceProvidersJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson());
public string GetServiceProvidersJson() => Session(ctx => ctx.Companies.ToJson());
public virtual Task<Company?> GetCompanyByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompanyById(id));
public virtual Task<List<Company>> GetCompaniesByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompaniesByOwnerId(id));
public virtual Task<Company?> GetServiceProviderByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProviderById(id));
public virtual Task<List<Company>> GetServiceProvidersByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProvidersByOwnerId(id));
//public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping) //public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping)
//{ //{
@ -243,17 +235,12 @@ namespace TIAM.Database.DataLayers.Admins
// return Context.SaveChangesAsync().ContinueWith(x => userProductMapping); // return Context.SaveChangesAsync().ContinueWith(x => userProductMapping);
//} //}
#region ServiceProviders
//14. (IserviceProviderDataService) Update service provider //14. (IserviceProviderDataService) Update service provider
public Task<bool> UpdateCompanyAsync(Company company) => TransactionAsync(ctx => ctx.UpdateServiceProvider<Company, Profile, Address>(company)); public Task<bool> UpdateCompanyAsync(Company company) => TransactionAsync(ctx => ctx.UpdateCompany(company));
//13. (IserviceProviderDataService) delete service provider //13. (IserviceProviderDataService) delete service provider
public Task<bool> RemoveCompanyAsync(Guid id) => TransactionAsync(ctx => ctx.RemoveServiceProvider(id)); public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
public Task<bool> RemoveCompanyAsync(Company company) => TransactionAsync(ctx => ctx.RemoveServiceProvider(company));
public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id);
#endregion #endregion
#region PermissionTypes #region PermissionTypes
@ -488,17 +475,6 @@ namespace TIAM.Database.DataLayers.Admins
#region Products #region Products
//* 21. (IServiceProviderDataService) delete product
public Task<bool> DeleteProductByIdAsync(Guid productId)
{
return TransactionAsync(ctx =>
{
ctx.DeleteProductById(productId);
return true;
});
}
//4. (IPermissionService) AssignPermissionToUserForContextAsync //4. (IPermissionService) AssignPermissionToUserForContextAsync
public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission) public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission)
{ {

View File

@ -21,8 +21,9 @@ namespace TIAM.Database.DbContexts.Admins
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
public DbSet<Profile> Profiles { get; set; } public DbSet<Profile> Profiles { get; set; }
public DbSet<Company> Companies { get; set; } public DbSet<Company> Companies { get; set; }
public DbSet<UserToCompany> UserToCompanies { get; set; }
public DbSet<UserToken> UserTokens { get; set; } public DbSet<UserToken> UserTokens { get; set; }
public DbSet<TransferDestination> TransferDestinations { get; set; } public DbSet<TransferDestination> TransferDestinations { get; set; }
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; } public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<Transfer> Transfers { get; set; } public DbSet<Transfer> Transfers { get; set; }

View File

@ -93,39 +93,39 @@ namespace TIAM.Database.DbContexts.Admins
return true; return true;
} }
public static bool CreateProduct(this IAdminDbContext ctx, Product myproduct) //public static bool CreateProduct(this IAdminDbContext ctx, Product myproduct)
{ //{
if (myproduct == null) return false; // if (myproduct == null) return false;
//Automatically add assigneduser for owner // //Automatically add assigneduser for owner
Company? company = ctx.Companies.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId); // Company? company = ctx.Companies.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId);
if (company == null || company.OwnerId.IsNullOrEmpty()) return false; // if (company == null || company.OwnerId.IsNullOrEmpty()) return false;
var userProductMapping = new UserProductMapping(myproduct.Id, company.OwnerId.Value); // var userProductMapping = new UserProductMapping(myproduct.Id, company.OwnerId.Value);
ctx.CreateAssignedUser(userProductMapping); // ctx.CreateAssignedUser(userProductMapping);
ctx.AddProduct(myproduct); // ctx.AddProduct(myproduct);
return true; // return true;
} //}
public static bool CreateAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping) //public static bool CreateAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping)
{ //{
if (userProductMapping == null) return false; // if (userProductMapping == null) return false;
ctx.UserProductMappings.Add(userProductMapping); // ctx.UserProductMappings.Add(userProductMapping);
return true; // return true;
} //}
public static Company CreateServiceProvider(this IAdminDbContext ctx, Company serviceProvider) //public static Company CreateServiceProvider(this IAdminDbContext ctx, Company serviceProvider)
{ //{
if (serviceProvider == null || serviceProvider.OwnerId.IsNullOrEmpty()) return null; // if (serviceProvider == null || serviceProvider.OwnerId.IsNullOrEmpty()) return null;
ctx.Companies.Add(serviceProvider); // ctx.Companies.Add(serviceProvider);
var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId.Value); // var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId.Value);
ctx.CreateAssignedUser(userProductMapping); // ctx.CreateAssignedUser(userProductMapping);
return serviceProvider; // return serviceProvider;
} //}
} }
} }

View File

@ -17,6 +17,7 @@ namespace TIAM.Database.DbContexts.ServiceProviders
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; } public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<Company> Companies { get; set; } public DbSet<Company> Companies { get; set; }
public DbSet<UserToCompany> UserToCompanies { get; set; }
public DbSet<Profile> Profiles { get; set; } public DbSet<Profile> Profiles { get; set; }
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }

View File

@ -1,9 +1,12 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbSets.Profiles;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products; using TIAM.Entities.Products;
namespace TIAM.Database.DbSets.Products; namespace TIAM.Database.DbSets.Products;
public interface IProductDbSet public interface IProductDbSet : IProfileDbSet, IUserProductMappingDbSet
{ {
public DbSet<Product> Products { get; set; } public DbSet<Product> Products { get; set; }
} }

View File

@ -1,6 +1,11 @@
using AyCode.Core.Extensions; using AyCode.Core.Extensions;
using AyCode.Database.DbSets.Profiles;
using AyCode.Interfaces.Addresses;
using AyCode.Interfaces.Profiles;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles;
namespace TIAM.Database.DbSets.Products; namespace TIAM.Database.DbSets.Products;
@ -19,8 +24,29 @@ public static class ProductDbSetExtensions
=> ctx.Products.Update(product).State == EntityState.Modified; => ctx.Products.Update(product).State == EntityState.Modified;
public static bool RemoveProduct(this IProductDbSet ctx, Product product) public static bool RemoveProduct(this IProductDbSet ctx, Product product)
=> ctx.Products.Remove(product).State == EntityState.Deleted; {
ctx.RemoveProfile(product.ProfileId);
ctx.UserProductMappings.RemoveRange(ctx.UserProductMappings.Where(x => x.ProductId == product.Id));
//TODO: Transfer, etc... - J.
return ctx.Products.Remove(product).State == EntityState.Deleted;
}
public static bool RemoveProduct(this IProductDbSet ctx, Guid productId)
{
var product = ctx.GetProductById(productId);
return product == null || ctx.RemoveProduct(product);
}
public static bool RemoveProductsByCompanyId(this IProductDbSet ctx, Guid companyId)
{
var products = ctx.GetProductsByCompanyId(companyId);
foreach (var product in products)
ctx.RemoveProduct(product);
return true;
}
#endregion Add, Update, Remove #endregion Add, Update, Remove
public static IQueryable<Product> ProductsWithUserRelations(this IProductDbSet ctx, bool autoInclude = true) public static IQueryable<Product> ProductsWithUserRelations(this IProductDbSet ctx, bool autoInclude = true)
@ -33,7 +59,7 @@ public static class ProductDbSetExtensions
public static Product? GetProductById(this IProductDbSet ctx, Guid productId, bool includeUsers = true) public static Product? GetProductById(this IProductDbSet ctx, Guid productId, bool includeUsers = true)
=> ctx.ProductsWithUserRelations(includeUsers).FirstOrDefault(x => x.Id == productId); => ctx.ProductsWithUserRelations(includeUsers).FirstOrDefault(x => x.Id == productId);
public static IQueryable<Product> GetProductsByServiceProviderId(this IProductDbSet ctx, Guid serviceProviderId, bool includeUsers = true) public static IQueryable<Product> GetProductsByCompanyId(this IProductDbSet ctx, Guid serviceProviderId, bool includeUsers = true)
=> ctx.ProductsWithUserRelations(includeUsers).Where(x => x.ServiceProviderId == serviceProviderId); => ctx.ProductsWithUserRelations(includeUsers).Where(x => x.ServiceProviderId == serviceProviderId);
} }

View File

@ -0,0 +1,10 @@
using AyCode.Database.DbSets.Profiles;
using TIAM.Database.DbSets.Addresses;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
namespace TIAM.Database.DbSets.Profiles;
public interface IProfileDbSet : IAcProfileDbSetBase<Profile, Address>, IAddressDbSet
{
}

View File

@ -2,9 +2,10 @@
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.ServiceProvider; namespace TIAM.Database.DbSets.ServiceProvider;
public interface ICompanyDbSet : IAcCompanyDbSetBase<Company, Profile, Address> public interface ICompanyDbSet : IAcCompanyDbSetBase<Company, Profile, Address, UserToCompany>
{ {
} }

View File

@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MessagePack.Annotations" Version="2.5.168" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />

View File

@ -225,7 +225,6 @@ else
<div class="card-footer p-4"> <div class="card-footer p-4">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<DxButton Click="@((e) => UpdateTransferEventHandler(e, true))">Save Changes</DxButton> <DxButton Click="@((e) => UpdateTransferEventHandler(e, true))">Save Changes</DxButton>
</div> </div>
</div> </div>
</div> </div>
@ -234,8 +233,6 @@ else
</div> </div>
</div> </div>
</section> </section>
} }
</DxTabPage> </DxTabPage>

View File

@ -29,14 +29,14 @@
OnGridEditModelSaving="DataItemSaving" OnGridEditModelSaving="DataItemSaving"
OnGridItemDeleting="DataItemDeleting" OnGridItemDeleting="DataItemDeleting"
OnGridItemChanged="DataItemChanged" OnGridItemChanged="DataItemChanged"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled" KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id" KeyFieldName="Id"
ValidationEnabled="false" ValidationEnabled="false"
TextWrapEnabled="false"
AutoExpandAllGroupRows="true"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="false"> DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode">
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@ -62,6 +62,7 @@
[Parameter] public IAcAddressRelation<Address> ParentData { get; set; } = null!; [Parameter] public IAcAddressRelation<Address> ParentData { get; set; } = null!;
[Parameter] public IList<Address>? DataSource { get; set; } [Parameter] public IList<Address>? DataSource { get; set; }
[Parameter] public EventCallback<Address> OnAddressChanged { get; set; } [Parameter] public EventCallback<Address> OnAddressChanged { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private Guid? _contextId = null!; private Guid? _contextId = null!;
private AddressDetailGrid _addressGrid = null!; private AddressDetailGrid _addressGrid = null!;

View File

@ -15,6 +15,7 @@
@using AyCode.Core @using AyCode.Core
@using TIAM.Entities.Products @using TIAM.Entities.Products
@using TIAM.Entities.Users @using TIAM.Entities.Users
@using TIAM.Services
@layout AdminLayout @layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> localizer @inject IStringLocalizer<TIAMResources> localizer
@ -132,7 +133,11 @@
<ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" /> <ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage> </DxTabPage>
<DxTabPage Text="Products"> <DxTabPage Text="Products">
<ProductDetailGridComponent @ref="_productDetailGridComponent" OnGridEditModelSaving="OnProductGridItemSaving" ParentData="(Company)context.DataItem" KeyboardNavigationEnabled="true" /> <ProductDetailGridComponent @ref="_productDetailGridComponent"
OnGridEditModelSaving="OnProductGridItemSaving"
ParentData="(Company)context.DataItem"
DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto"
KeyboardNavigationEnabled="true" />
</DxTabPage> </DxTabPage>
<DxTabPage Text="Address"> <DxTabPage Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" /> <AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />

View File

@ -16,6 +16,7 @@
@using TIAMWebApp.Shared.Application.Services @using TIAMWebApp.Shared.Application.Services
@using AyCode.Interfaces.Addresses @using AyCode.Interfaces.Addresses
@using TIAM.Entities.Emails @using TIAM.Entities.Emails
@using AyCode.Blazor.Components.Services
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient; @inject AdminSignalRClient AdminSignalRClient;
@ -24,6 +25,7 @@
Logger="_logger" Logger="_logger"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
ContextIds="new[] {ContextId}" ContextIds="new[] {ContextId}"
KeyFieldName="Id"
CustomizeElement="CustomizeElement" CustomizeElement="CustomizeElement"
TextWrapEnabled="false"> TextWrapEnabled="false">
@ -49,9 +51,9 @@
if (!emailMessage.IsReaded) if (!emailMessage.IsReaded)
{ {
emailMessage.IsReaded = true; emailMessage.IsReaded = true;
_messageGrid.UpdateDataItemAsync(emailMessage).Forget();
InvokeAsync(StateHasChanged).Forget(); _messageGrid.UpdateDataItemAsync(emailMessage).Forget();
//InvokeAsync(StateHasChanged).ContinueWith(x => _messageGrid.UpdateDataItemAsync(emailMessage).Forget());
} }
} }
</DetailRowTemplate> </DetailRowTemplate>

View File

@ -25,20 +25,20 @@
<ProductDetailGrid @ref="_productGrid" <ProductDetailGrid @ref="_productGrid"
ContextIds="new[] {ContextId}"
DataSource="ParentData.Products" DataSource="ParentData.Products"
Logger="_logger" Logger="_logger"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
OnGridEditModelSaving="DataItemSaving" OnGridEditModelSaving="DataItemSaving"
OnGridItemDeleting="DataItemDeleting" OnGridItemDeleting="DataItemDeleting"
OnGridItemChanged="DataItemChanged" OnGridItemChanged="DataItemChanged"
PageSize="5" TextWrapEnabled="false"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled" KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id" KeyFieldName="Id"
ValidationEnabled="false" ValidationEnabled="false"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true"> DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode">
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="true" Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N"/> <DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N"/>
@ -82,9 +82,10 @@
@code { @code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; } [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 IProductsRelation ParentData { get; set; } = null!;
[Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; } [Parameter] public EventCallback<GridEditModelSavingEventArgs> OnGridEditModelSaving { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private ProductDetailGrid _productGrid = null!; private ProductDetailGrid _productGrid = null!;
private LoggerClient<ProductDetailGridComponent> _logger = null!; private LoggerClient<ProductDetailGridComponent> _logger = null!;

View File

@ -12,8 +12,6 @@
@using TIAM.Entities.Addresses @using TIAM.Entities.Addresses
@using TIAM.Entities.Profiles @using TIAM.Entities.Profiles
@using Profile = TIAM.Entities.Profiles.Profile @using Profile = TIAM.Entities.Profiles.Profile
@inject IServiceProviderDataService serviceProviderDataService
@inject IUserDataService userDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient @inject AdminSignalRClient AdminSignalRClient
@ -21,14 +19,14 @@
ContextIds="new[] {ParentData.ProfileId}" ContextIds="new[] {ParentData.ProfileId}"
Logger="_logger" Logger="_logger"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled" KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id" KeyFieldName="Id"
ValidationEnabled="false" ValidationEnabled="false"
TextWrapEnabled="false"
AutoExpandAllGroupRows="true"
EditMode="GridEditMode.EditForm" EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn" ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="false"> DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode">
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" /> <DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@ -48,9 +46,8 @@
</ProfileDetailGrid> </ProfileDetailGrid>
@code { @code {
[Parameter] [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
public bool KeyboardNavigationEnabled { get; set; } [Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public IProfileForeignKey ParentData { get; set; } = null!; [Parameter] public IProfileForeignKey ParentData { get; set; } = null!;
private ProfileDetailGrid _profileGrid = null!; private ProfileDetailGrid _profileGrid = null!;
@ -64,6 +61,8 @@
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
_logger.DebugConditional(ParentData.ProfileId.ToString()); _logger.DebugConditional(ParentData.ProfileId.ToString());
base.OnParametersSet(); base.OnParametersSet();
} }
} }

View File

@ -101,7 +101,12 @@ namespace TIAMSharedUI.Shared.Components.Grids
var changedEventArgs = new GridDataItemChangedEventArgs<TDataItem>(this, args.Item, args.TrackingState); var changedEventArgs = new GridDataItemChangedEventArgs<TDataItem>(this, args.Item, args.TrackingState);
await OnGridItemChanged.InvokeAsync(changedEventArgs); await OnGridItemChanged.InvokeAsync(changedEventArgs);
await InvokeAsync(StateHasChanged); if (!changedEventArgs.CancelStateChangeInvoke)
{
//BeginUpdate();
await InvokeAsync(StateHasChanged); //TODO: bezárja a DetailRow-t! pl: az email-nél IsReaded=true update... - J.
//EndUpdate();
}
} }
private Task OnDataSourceLoaded() private Task OnDataSourceLoaded()
@ -169,7 +174,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
{ {
Logger.Error($"{_gridLogName} SaveChangesToServerAsync->SaveChangesAsync error!", ex); Logger.Error($"{_gridLogName} SaveChangesToServerAsync->SaveChangesAsync error!", ex);
} }
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -311,5 +316,6 @@ namespace TIAMSharedUI.Shared.Components.Grids
public TiamGrid<TDataItem> Grid { get; } public TiamGrid<TDataItem> Grid { get; }
public TDataItem DataItem { get; } public TDataItem DataItem { get; }
public TrackingState TrackingState { get; } public TrackingState TrackingState { get; }
public bool CancelStateChangeInvoke { get; set; }
} }
} }

View File

@ -98,6 +98,8 @@ namespace TIAMWebApp.Server.Controllers
return messages.ToJson(); return messages.ToJson();
} }
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.UpdateMessage)] [SignalR(SignalRTags.UpdateMessage)]
public async Task<EmailMessage?> UpdateMessages([FromBody] EmailMessage message) public async Task<EmailMessage?> UpdateMessages([FromBody] EmailMessage message)
{ {

View File

@ -49,10 +49,10 @@ namespace TIAMWebApp.Server.Controllers
//if (company.OwnerId.IsNullOrEmpty()) company.OwnerId = Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00"); //TESZT - J. //if (company.OwnerId.IsNullOrEmpty()) company.OwnerId = Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00"); //TESZT - J.
company.SetProfile(new Profile(Guid.NewGuid(), company.Name)); //company.SetProfile(new Profile(Guid.NewGuid(), company.Name));
company.Profile.SetAddress(new Address(Guid.NewGuid(), "Controller AddCompanyAsync; address text...")); //company.Profile.SetAddress(new Address(Guid.NewGuid(), "Controller AddCompanyAsync; address text..."));
return await adminDal.CreateServiceProviderAsync(company); return await adminDal.AddCompanyAsync(company);
case TrackingState.Update: case TrackingState.Update:
return await adminDal.UpdateCompanyAsync(company); return await adminDal.UpdateCompanyAsync(company);
@ -106,7 +106,7 @@ namespace TIAMWebApp.Server.Controllers
[SignalR(SignalRTags.GetCompanies)] [SignalR(SignalRTags.GetCompanies)]
public async Task<string> GetServiceProviders() public async Task<string> GetServiceProviders()
{ {
return await adminDal.GetServiceProvidersJsonAsync(); return await adminDal.GetCompaniesJsonAsync();
} }
//18. //18.
@ -118,7 +118,7 @@ namespace TIAMWebApp.Server.Controllers
{ {
_logger.Info($@"GetServiceProviderById called with id: {id}"); _logger.Info($@"GetServiceProviderById called with id: {id}");
return await adminDal.GetServiceProviderByIdAsync(id); return await adminDal.GetCompanyByIdAsync(id);
} }
@ -132,7 +132,7 @@ namespace TIAMWebApp.Server.Controllers
{ {
_logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}"); _logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}");
var serviceProviders = await adminDal.GetServiceProvidersAsync(); var serviceProviders = await adminDal.GetCompaniesAsync();
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList(); //return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name); var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name);
@ -150,7 +150,7 @@ namespace TIAMWebApp.Server.Controllers
{ {
_logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}"); _logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}");
var serviceProviders = await adminDal.GetServiceProvidersByOwnerIdAsync(ownerId); var serviceProviders = await adminDal.GetCompaniesByOwnerIdAsync(ownerId);
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList(); //return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
//var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name); //var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name);
@ -218,7 +218,7 @@ namespace TIAMWebApp.Server.Controllers
var userProductMappingDictionary = new Dictionary<Guid, string>(); var userProductMappingDictionary = new Dictionary<Guid, string>();
var serviceProviders = await adminDal.GetServiceProvidersAsync(); var serviceProviders = await adminDal.GetCompaniesAsync();
var myServiceproviders = serviceProviders.Where(x => x.Id == serviceProviderId).ToDictionary(x => x.Id, x => x.Name); var myServiceproviders = serviceProviders.Where(x => x.Id == serviceProviderId).ToDictionary(x => x.Id, x => x.Name);
//put serviceprovider id and name into a dictionary //put serviceprovider id and name into a dictionary

View File

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="8.0.6" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.14" /> <PackageReference Include="Microsoft.OpenApi" Version="1.6.15" />
<PackageReference Include="QRCoderNetCore" Version="1.0.0" /> <PackageReference Include="QRCoderNetCore" Version="1.0.0" />
<PackageReference Include="SendGrid" Version="9.29.3" /> <PackageReference Include="SendGrid" Version="9.29.3" />
<PackageReference Include="SkiaSharp" Version="2.88.8" /> <PackageReference Include="SkiaSharp" Version="2.88.8" />

View File

@ -121,6 +121,8 @@ namespace TIAMWebApp.Shared.Application.Services
_logger.DetailConditional($"companyPropertiesByOwner async: {string.Join("; ", response.ResponseData!.Values)}"); _logger.DetailConditional($"companyPropertiesByOwner async: {string.Join("; ", response.ResponseData!.Values)}");
callback.Invoke(response.ResponseData); callback.Invoke(response.ResponseData);
return Task.CompletedTask;
}, id); }, id);
} }

View File

@ -50,6 +50,8 @@ namespace Tiam.Services.Client.Tests
Assert.IsTrue(response.Status == SignalResponseStatus.Success); Assert.IsTrue(response.Status == SignalResponseStatus.Success);
company = response.ResponseData; company = response.ResponseData;
return Task.CompletedTask;
}, companyId); }, companyId);
await TaskHelper.WaitToAsync(() => company != null, 5000, 50); await TaskHelper.WaitToAsync(() => company != null, 5000, 50);
@ -77,6 +79,8 @@ namespace Tiam.Services.Client.Tests
Assert.IsTrue(response.Status == SignalResponseStatus.Success); Assert.IsTrue(response.Status == SignalResponseStatus.Success);
companies = response.ResponseData; companies = response.ResponseData;
return Task.CompletedTask;
}); });
await TaskHelper.WaitToAsync(() => companies != null, 5000, 50); await TaskHelper.WaitToAsync(() => companies != null, 5000, 50);

View File

@ -10,10 +10,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" /> <PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> <PrivateAssets>all</PrivateAssets>
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" /> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" /> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>