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.Entities.Transfers;
using AyCode.Core.Extensions;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Database.Test
{
@ -222,6 +223,48 @@ namespace TIAM.Database.Test
#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]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
[DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")]
@ -297,6 +340,47 @@ namespace TIAM.Database.Test
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
[DataTestMethod]
[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 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 string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson());
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.GetProductsByCompanyId(serviceProviderId, includeUsers).ToJson());
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> 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 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
#region ServiceProviders
//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)
//{
// 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>> GetCompaniesAsync() => SessionAsync(ctx => ctx.GetCompanies().ToList());
public Task<List<Company>> GetServiceProvidersAsync() => SessionAsync(ctx => ctx.GetServiceProviders().ToList());
public Task<string> GetServiceProvidersJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson());
public string GetServiceProvidersJson() => Session(ctx => ctx.Companies.ToJson());
public Task<string> GetCompaniesJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson());
public string GetCompaniesJson() => Session(ctx => ctx.Companies.ToJson());
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 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 Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping)
//{
@ -243,17 +235,12 @@ namespace TIAM.Database.DataLayers.Admins
// return Context.SaveChangesAsync().ContinueWith(x => userProductMapping);
//}
#region ServiceProviders
//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
public Task<bool> RemoveCompanyAsync(Guid id) => TransactionAsync(ctx => ctx.RemoveServiceProvider(id));
public Task<bool> RemoveCompanyAsync(Company company) => TransactionAsync(ctx => ctx.RemoveServiceProvider(company));
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id);
#endregion
#region PermissionTypes
@ -488,17 +475,6 @@ namespace TIAM.Database.DataLayers.Admins
#region Products
//* 21. (IServiceProviderDataService) delete product
public Task<bool> DeleteProductByIdAsync(Guid productId)
{
return TransactionAsync(ctx =>
{
ctx.DeleteProductById(productId);
return true;
});
}
//4. (IPermissionService) AssignPermissionToUserForContextAsync
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<Profile> Profiles { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<UserToCompany> UserToCompanies { get; set; }
public DbSet<UserToken> UserTokens { get; set; }
public DbSet<TransferDestination> TransferDestinations { get; set; }
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<Transfer> Transfers { get; set; }

View File

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

View File

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

View File

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

View File

@ -1,6 +1,11 @@
using AyCode.Core.Extensions;
using AyCode.Database.DbSets.Profiles;
using AyCode.Interfaces.Addresses;
using AyCode.Interfaces.Profiles;
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products;
using TIAM.Entities.Profiles;
namespace TIAM.Database.DbSets.Products;
@ -19,8 +24,29 @@ public static class ProductDbSetExtensions
=> ctx.Products.Update(product).State == EntityState.Modified;
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
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)
=> 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);
}

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.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
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>
<ItemGroup>
<PackageReference Include="MessagePack.Annotations" Version="2.5.168" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" 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="d-flex justify-content-between">
<DxButton Click="@((e) => UpdateTransferEventHandler(e, true))">Save Changes</DxButton>
</div>
</div>
</div>
@ -234,8 +233,6 @@ else
</div>
</div>
</section>
}
</DxTabPage>

View File

@ -29,14 +29,14 @@
OnGridEditModelSaving="DataItemSaving"
OnGridItemDeleting="DataItemDeleting"
OnGridItemChanged="DataItemChanged"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
TextWrapEnabled="false"
AutoExpandAllGroupRows="true"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="false">
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode">
<Columns>
<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" />
@ -62,6 +62,7 @@
[Parameter] public IAcAddressRelation<Address> ParentData { get; set; } = null!;
[Parameter] public IList<Address>? DataSource { get; set; }
[Parameter] public EventCallback<Address> OnAddressChanged { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private Guid? _contextId = null!;
private AddressDetailGrid _addressGrid = null!;

View File

@ -15,6 +15,7 @@
@using AyCode.Core
@using TIAM.Entities.Products
@using TIAM.Entities.Users
@using TIAM.Services
@layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IStringLocalizer<TIAMResources> localizer
@ -132,7 +133,11 @@
<ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage>
<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 Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />

View File

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

View File

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

View File

@ -12,8 +12,6 @@
@using TIAM.Entities.Addresses
@using TIAM.Entities.Profiles
@using Profile = TIAM.Entities.Profiles.Profile
@inject IServiceProviderDataService serviceProviderDataService
@inject IUserDataService userDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient
@ -21,14 +19,14 @@
ContextIds="new[] {ParentData.ProfileId}"
Logger="_logger"
SignalRClient="AdminSignalRClient"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
TextWrapEnabled="false"
AutoExpandAllGroupRows="true"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="false">
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode">
<Columns>
<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" />
@ -48,9 +46,8 @@
</ProfileDetailGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public IProfileForeignKey ParentData { get; set; } = null!;
private ProfileDetailGrid _profileGrid = null!;
@ -64,6 +61,8 @@
protected override void OnParametersSet()
{
_logger.DebugConditional(ParentData.ProfileId.ToString());
base.OnParametersSet();
}
}
}

View File

@ -101,7 +101,12 @@ namespace TIAMSharedUI.Shared.Components.Grids
var changedEventArgs = new GridDataItemChangedEventArgs<TDataItem>(this, args.Item, args.TrackingState);
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()
@ -169,7 +174,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
{
Logger.Error($"{_gridLogName} SaveChangesToServerAsync->SaveChangesAsync error!", ex);
}
return Task.CompletedTask;
}
@ -311,5 +316,6 @@ namespace TIAMSharedUI.Shared.Components.Grids
public TiamGrid<TDataItem> Grid { get; }
public TDataItem DataItem { get; }
public TrackingState TrackingState { get; }
public bool CancelStateChangeInvoke { get; set; }
}
}

View File

@ -98,6 +98,8 @@ namespace TIAMWebApp.Server.Controllers
return messages.ToJson();
}
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.UpdateMessage)]
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.
company.SetProfile(new Profile(Guid.NewGuid(), company.Name));
company.Profile.SetAddress(new Address(Guid.NewGuid(), "Controller AddCompanyAsync; address text..."));
//company.SetProfile(new Profile(Guid.NewGuid(), company.Name));
//company.Profile.SetAddress(new Address(Guid.NewGuid(), "Controller AddCompanyAsync; address text..."));
return await adminDal.CreateServiceProviderAsync(company);
return await adminDal.AddCompanyAsync(company);
case TrackingState.Update:
return await adminDal.UpdateCompanyAsync(company);
@ -106,7 +106,7 @@ namespace TIAMWebApp.Server.Controllers
[SignalR(SignalRTags.GetCompanies)]
public async Task<string> GetServiceProviders()
{
return await adminDal.GetServiceProvidersJsonAsync();
return await adminDal.GetCompaniesJsonAsync();
}
//18.
@ -118,7 +118,7 @@ namespace TIAMWebApp.Server.Controllers
{
_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}");
var serviceProviders = await adminDal.GetServiceProvidersAsync();
var serviceProviders = await adminDal.GetCompaniesAsync();
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
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}");
var serviceProviders = await adminDal.GetServiceProvidersByOwnerIdAsync(ownerId);
var serviceProviders = await adminDal.GetCompaniesByOwnerIdAsync(ownerId);
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
//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 serviceProviders = await adminDal.GetServiceProvidersAsync();
var serviceProviders = await adminDal.GetCompaniesAsync();
var myServiceproviders = serviceProviders.Where(x => x.Id == serviceProviderId).ToDictionary(x => x.Id, x => x.Name);
//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.SignalR.Common" 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="SendGrid" Version="9.29.3" />
<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)}");
callback.Invoke(response.ResponseData);
return Task.CompletedTask;
}, id);
}

View File

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

View File

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