This commit is contained in:
Loretta 2024-06-21 15:19:42 +02:00
commit 572473d471
4 changed files with 11 additions and 8 deletions

View File

@ -4,6 +4,6 @@ namespace TIAM.Entities.Products;
public interface IProductsRelation
{
public List<UserProductMapping> UserProductMappings { get; set; }
//public List<UserProductMapping> UserProductMappings { get; set; }
public List<Product> Products { get; set; }
}

View File

@ -8,9 +8,9 @@ using TIAM.Entities.Users;
namespace TIAM.Entities.ServiceProviders;
[Table("ServiceProviders")]
public class Company : AcCompany<User, UserToCompany, Profile, Address>, ICompany
public class Company : AcCompany<User, UserToCompany, Profile, Address>, ICompany, IProductsRelation
{
public virtual List<Product> Products { get; } = new();
public virtual List<Product> Products { get; set; } = new();
public Company()
{

View File

@ -130,7 +130,7 @@
<ProfileGridComponent ProfileId="((Company)context.DataItem).ProfileId" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Products">
<ProductDetailGridComponent ContextId="((Company)context.DataItem).Id" KeyboardNavigationEnabled="true" />
<ProductDetailGridComponent ProductGrid="" ParentData="(Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />

View File

@ -23,8 +23,8 @@
@inject AdminSignalRClient AdminSignalRClient;
<ProductDetailGrid @ref="_productGrid"
ContextId="ContextId"
<ProductDetailGrid @ref="ProductGrid"
DataSource="ParentData.Products"
Logger="_logger"
SignalRClient="AdminSignalRClient"
OnGridEditModelSaving="DataItemSaving"
@ -81,8 +81,9 @@
@code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public Guid? ContextId { get; set; }
[Parameter] public IProductsRelation ParentData { get; set; } = null!;
private ProductDetailGrid _productGrid = null!;
public ProductDetailGrid ProductGrid = null!;
private LoggerClient<ProductDetailGridComponent> _logger = null!;
protected override void OnInitialized()
{
@ -96,7 +97,7 @@
{
_logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}");
_productGrid.SaveChangesAsync();
ProductGrid.SaveChangesAsync();
}
private void DataItemSaving(GridEditModelSavingEventArgs e)
@ -112,6 +113,8 @@
((Product)e.EditModel).Profile.Address = new Address();
((Product)e.EditModel).Profile.AddressId = _addressId;
((Product)e.EditModel).Profile.Address.Id = _addressId;
((Product)e.EditModel).UserProductMappings.Add(new UserProductMapping(Guid.NewGuid, ParentData.));