This commit is contained in:
Adam 2024-06-24 19:12:30 +02:00
commit 35b26bd5be
31 changed files with 430 additions and 542 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

@ -36,6 +36,7 @@ namespace TIAM.Database.DataLayers.Admins
public Task<List<Car>> GetAllCarsAsync() => SessionAsync(ctx => ctx.Cars.OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList());
public Car? GetCarById(Guid carId) => Session(ctx => ctx.Cars.FirstOrDefault(x => x.Id == carId));
public List<Car> GetCarByUserProductMappingId(Guid userProductMappingId) => Session(ctx => ctx.Cars.Where(x => x.UserProductMappingId == userProductMappingId).ToList());
public Task<List<Car>> GetCarByUserProductMappingIdAsync(Guid userProductMappingId) => SessionAsync(ctx => ctx.Cars.Where(x => x.UserProductMappingId == userProductMappingId).ToList());
public Task<bool> AddCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Add(car).State == EntityState.Added);
public Task<bool> UpdateCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Update(car).State == EntityState.Modified);
public Task<bool> RemoveCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Remove(car).State == EntityState.Deleted);
@ -118,18 +119,25 @@ namespace TIAM.Database.DataLayers.Admins
public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId));
public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
public Task<Product?> GetProductByIdAsync(Guid contextId, bool includeUsers = true) => SessionAsync(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 List<UserProductMapping>? GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList();
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public List<UserProductMapping> GetUserProductMappingsByUserId(Guid userId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingsByUserId(userId, autoInclude).ToList());
public Task<List<UserProductMapping>> GetUserProductMappingsByUserIdAsync(Guid userId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingsByUserId(userId, autoInclude).ToList());
public Task<List<UserProductMapping>> GetUserProductMappingsByProductIdAsync(Guid productId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingsByProductId(productId, autoInclude).ToList());
public List<UserProductMapping> GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList();
public Task<List<UserProductMapping>> GetAllUserProductMappingsAsync(bool autoInclude = true) => SessionAsync(ctx => ctx.UserProductMappings.ToList());
public List<PermissionContextMapping> GetPermissionContextsView(Guid subjectId, Guid contextId)
=> Session(x => x.GetPermissionContextsView(subjectId, contextId).ToList());
@ -217,26 +225,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)
//{
@ -245,17 +244,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
@ -490,17 +484,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)
{
@ -529,13 +512,6 @@ namespace TIAM.Database.DataLayers.Admins
#region UserProductMappings
//23. (IServiceProviderDataService) Get Assigned Users By ProductId
public Task<List<UserProductMapping>> GetUserProductMappingsByProductIdAsync(Guid productId)
{
return Context.UserProductMappings.Where(x => x.ProductId == productId).ToListAsync();
}
//24 . (IServiceProviderDataService) Remove Assigned Users By Product Id
public Task RemoveUserProductMappingsByContextId(Guid productId)
{

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

@ -19,10 +19,11 @@ public class SignalRTags : AcSignalRTags
public const int GetCompany = 12;
public const int GetCompanies = 13;
public const int GetCompaniesByContextId = 14;
public const int UpdateCompany = 15;
public const int AddCompany = 16;
public const int RemoveCompany = 17;
public const int GetCompaniesById = 14;
public const int GetCompaniesByContextId = 15;
public const int UpdateCompany = 16;
public const int AddCompany = 17;
public const int RemoveCompany = 18;
public const int GetTransferToDriver = 22;
//public const int GetTransferToDrivers = 23;
@ -53,6 +54,7 @@ public class SignalRTags : AcSignalRTags
public const int GetUserProductMappingsByProductId = 44;
public const int GetUserProductMappingsByUserId = 45;
public const int GetUserProductMappingById = 46;
public const int GetUserProductMappingsById = 47;
public const int GetCarsForUserProductMapping = 50;
public const int CreateCar = 51;

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

@ -18,7 +18,7 @@
<CarDetailGrid Logger="_logger"
ContextIds="ContextIds"
ContextIds="new [] {ContextId}"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
@ -29,10 +29,11 @@
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="UserProductMappingId" />
<DxGridDataColumn FieldName="CountryCode"/>
<DxGridDataColumn FieldName="LicencePlate"/>
@ -45,88 +46,65 @@
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabs>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingById" ContextId="((Car)context.DataItem).UserProductMappingId" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingsById" ContextIds="new[] { ((Car)context.DataItem).UserProductMappingId }" KeyboardNavigationEnabled="true"/>
</DxTabPage>
</DxTabs>
}
</DxTabs>
}
</DetailRowTemplate>
<EditFormTemplate Context="UserEditFormContext">
<EditFormTemplate Context="userEditFormContext">
@{
var car = (Car)UserEditFormContext.EditModel;
var car = (Car)userEditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Country code" ColSpanMd="4">
@UserEditFormContext.GetEditor("CountryCode")
@userEditFormContext.GetEditor("CountryCode")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("LicencePlate")
@userEditFormContext.GetEditor("LicencePlate")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Color" ColSpanMd="4">
@UserEditFormContext.GetEditor("Color")
@userEditFormContext.GetEditor("Color")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4">
@UserEditFormContext.GetEditor("Manufacture")
@userEditFormContext.GetEditor("Manufacture")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Car model" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarModel")
@userEditFormContext.GetEditor("CarModel")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Year of make" ColSpanMd="4">
@UserEditFormContext.GetEditor("YearOfMake")
@userEditFormContext.GetEditor("YearOfMake")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Seat number" ColSpanMd="4">
@UserEditFormContext.GetEditor("SeatNumber")
@userEditFormContext.GetEditor("SeatNumber")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Motor type" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarMotorType")
@userEditFormContext.GetEditor("CarMotorType")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</CarDetailGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public Guid ContextId { get; set; }
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public bool ShowNestedRows { get; set; } = false;
private LoggerClient<CarDetailGridComponent> _logger = null!;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<CarDetailGridComponent> _logger;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
_logger = new LoggerClient<CarDetailGridComponent>(LogWriters.ToArray());
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
base.OnInitialized();
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
@ -134,53 +112,25 @@
if (e.IsNew)
{
var newCar = new Car
{
Id = Guid.NewGuid(),
UserProductMappingId = (Guid)ContextId,
CountryCode = 1,
LicencePlate = "ABC123",
Color = "White",
Manufacture = "Manufacturer",
CarModel = "Car model",
YearOfMake = DateTime.Now.Year,
SeatNumber = 5,
CarMotorType = TIAM.Core.Enums.CarMotorType.Electric
};
{
Id = Guid.NewGuid(),
UserProductMappingId = ContextId!,
CountryCode = 1,
LicencePlate = "ABC123",
Color = "White",
Manufacture = "Manufacturer",
CarModel = "Car model",
YearOfMake = DateTime.Now.Year,
SeatNumber = 5,
CarMotorType = TIAM.Core.Enums.CarMotorType.Electric
};
e.EditModel = newCar;
}
else
{
//
}
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
}

View File

@ -18,7 +18,7 @@
<CarGrid Logger="_logger"
ContextIds="ContextIds"
ContextIds="new [] {ContextId}"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
@ -29,10 +29,11 @@
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="UserProductMappingId" />
<DxGridDataColumn FieldName="CountryCode"/>
<DxGridDataColumn FieldName="LicencePlate"/>
@ -45,127 +46,69 @@
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabs>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent ShowNestedRows="true" GetAllTag="SignalRTags.GetUserProductMappingById" ContextId="((Car)context.DataItem).UserProductMappingId" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Driving permissions assigned">
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingsById" ContextIds="new[] { ((Car)context.DataItem).UserProductMappingId }" KeyboardNavigationEnabled="true"/>
</DxTabPage>
</DxTabs>
}
</DxTabs>
}
</DetailRowTemplate>
<EditFormTemplate Context="UserEditFormContext">
<EditFormTemplate Context="userEditFormContext">
@{
var car = (Car)UserEditFormContext.EditModel;
var car = (Car)userEditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Country code" ColSpanMd="4">
@UserEditFormContext.GetEditor("CountryCode")
@userEditFormContext.GetEditor("CountryCode")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("LicencePlate")
@userEditFormContext.GetEditor("LicencePlate")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Color" ColSpanMd="4">
@UserEditFormContext.GetEditor("Color")
@userEditFormContext.GetEditor("Color")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Manufacturer" ColSpanMd="4">
@UserEditFormContext.GetEditor("Manufacture")
@userEditFormContext.GetEditor("Manufacture")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarModel")
@userEditFormContext.GetEditor("CarModel")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("YearOfMake")
@userEditFormContext.GetEditor("YearOfMake")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("SeatNumber")
@userEditFormContext.GetEditor("SeatNumber")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Licence plate" ColSpanMd="4">
@UserEditFormContext.GetEditor("CarMotorType")
@userEditFormContext.GetEditor("CarMotorType")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</CarGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public Guid ContextId { get; set; }
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public ICarRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public bool ShowNestedRows { get; set; } = false;
private LoggerClient<CarGridComponent> _logger = null!;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<CarGridComponent> _logger;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
_logger = new LoggerClient<CarGridComponent>(LogWriters.ToArray());
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
base.OnInitialized();
}
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)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
}

View File

@ -12,6 +12,7 @@
@using AyCode.Core.Loggers
@using AyCode.Services.Loggers
@using AyCode.Core
@using AyCode.Core.Extensions
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient
@ -31,14 +32,14 @@
<label for="emailID" class="demo-text mt-4 mb-1">
Put user email here
</label>
<DxMaskedInput @ref="emailInput"
<DxMaskedInput @ref="_emailInput"
@bind-Value="@Email"
CssClass="cw-320"
Mask="@EmailMask"
InputId="emailID"
MaskMode="MaskMode.RegEx" />
<DxButton @ref="button1" CssClass="popup-button my-1 ms-2" Visible="true" RenderStyle="ButtonRenderStyle.Primary" Text="Find user" Click="@FindUser" />
<div style="@errorCss" @ref="errorMessage"><p>User not found, type another email please</p></div>
<DxButton @ref="_button1" CssClass="popup-button my-1 ms-2" Visible="true" RenderStyle="ButtonRenderStyle.Primary" Text="Find user" Click="@FindUser" />
<div style="@_errorCss" @ref="_errorMessage"><p>User not found, type another email please</p></div>
<DxGrid Data="@FoundUsers" RowClick="@OnRowClick">
<Columns>
<DxGridDataColumn FieldName="Id" Caption="ID" />
@ -54,9 +55,10 @@
</div>
</FooterContentTemplate>
</DxPopup>
<UserProductMappingDriverGrid Logger="_logger"
@ref="_driverGrid"
ContextIds="ContextIds"
ContextIds="new [] {ContextId}"
GetAllMessageTag="GetAllTag"
SignalRClient="AdminSignalRClient"
PageSize="10"
@ -68,18 +70,17 @@
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" />
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Products">
@ -89,7 +90,6 @@
<CarDetailGridComponent GetAllTag="SignalRTags.GetCarsForUserProductMapping" ContextId="((UserProductMapping)context.DataItem).Id" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
}
}
</DetailRowTemplate>
@ -122,114 +122,76 @@
</UserProductMappingDriverGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public Guid ContextId { get; set; }
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public IProductRelation ParentData { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
[Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private LoggerClient<UserProductMappingGridComponent> _logger;
List<Product> _availableProducts;
List<Product> _availableProducts;
private UserProductMappingDriverGrid _driverGrid;
private UserProductMapping tempProductMapping;
private UserProductMapping _tempProductMapping;
bool PopupVisible { get; set; }
private DxMaskedInput<string> emailInput;
private DxButton button1;
private ElementReference errorMessage;
private string errorCss = "display: none;";
private DxMaskedInput<string> _emailInput;
private DxButton _button1;
private ElementReference _errorMessage;
private string _errorCss = "display: none;";
private List<UserModelDto> FoundUsers { get; set; } = new List<UserModelDto>();
private string Email { get; set; } = "email@email.com";
string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}";
UserModelDto ChosenUser = null;
UserModelDto _chosenUser = null!;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
base.OnInitialized();
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
UserProductMapping newUPM = (UserProductMapping)e.EditModel;
newUPM.ProductId = (Guid)ContextId!;
if (ContextId.IsNullOrEmpty())
{
_logger.Warning($"ContextId.IsNullOrEmpty()");
return;
}
var newUpm = (UserProductMapping)e.EditModel;
newUpm.ProductId = ContextId;
var newProductMapping = new UserProductMapping
{
Id = Guid.NewGuid(),
ProductId = (Guid)ContextId,
ProductId = (Guid)ContextId,
Permissions = 2
};
//e.EditModel = newProductMapping;
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
async Task FindUser()
{
var userModelDto = await UserDataService.GetUserByEmailAsync(Email);
if (userModelDto != null)
{
ChosenUser = userModelDto;
FoundUsers.Add(ChosenUser);
emailInput.Enabled = false;
button1.Visible = false;
_chosenUser = userModelDto;
FoundUsers.Add(_chosenUser);
_emailInput.Enabled = false;
_button1.Visible = false;
}
else
{
emailInput.Value = "email@email.com";
errorCss = "display: block";
_emailInput.Value = "email@email.com";
_errorCss = "display: block";
}
}
@ -249,17 +211,18 @@
}
public async Task SubmitForm(object result)
public Task SubmitForm(object result)
{
_logger.Info($"Submitted nested form: {result.GetType().FullName}");
return Task.CompletedTask;
}
public async Task ShowPopup(UserProductMapping emptyProductMapping)
public Task ShowPopup(UserProductMapping emptyProductMapping)
{
tempProductMapping = emptyProductMapping;
PopupVisible = true;
_tempProductMapping = emptyProductMapping;
PopupVisible = true;
return Task.CompletedTask;
}
private async Task OnUserSelected(Guid userId)
@ -269,13 +232,15 @@
}
private async Task OnRowClick(GridRowClickEventArgs e)
{
{
await SelectUser((Guid)e.Grid.GetRowValue(e.VisibleIndex, "Id"));
}
private async Task SelectUser(Guid id)
{
PopupVisible = false;
tempProductMapping.UserId = id;
_tempProductMapping.UserId = id;
await OnUserSelected(id);
}
@ -283,7 +248,7 @@
{
if (e.ElementType == GridElementType.DataRow && (int)e.Grid.GetRowValue(e.VisibleIndex, "Permissions") == 1)
{
e.Style="display: none";
e.Style = "display: none";
}
// else if (e.ElementType == GridElementType.HeaderCell)
// {
@ -291,7 +256,4 @@
// }
}
}

View File

@ -37,7 +37,7 @@
Click="ColumnChooserButton_Click" />
</div>
<CarGridComponent ShowNestedRows="true" GetAllTag="SignalRTags.GetAllCars"></CarGridComponent>
<CarGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllCars"></CarGridComponent>
</div>

View File

@ -37,7 +37,7 @@
Click="ColumnChooserButton_Click" />
</div>
<DriverGridComponent ShowNestedRows="true" ContextId="Guid.Parse(TransferProductId)" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"></DriverGridComponent>
<DriverGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ContextId="Guid.Parse(TransferProductId)" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"></DriverGridComponent>
</div>

View File

@ -16,6 +16,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
@ -133,7 +134,7 @@
<ProfileGridComponent ParentData="((Company)context.DataItem)" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Products">
<ProductDetailGridComponent @ref="_productDetailGridComponent" GetAllTag="SignalRTags.GetProductsByOwnerId" OnGridEditModelSaving="OnProductGridItemSaving" ContextId="((Company)context.DataItem).Id" ParentData="(Company)context.DataItem" KeyboardNavigationEnabled="true" />
<ProductDetailGridComponent @ref="_productDetailGridComponent" DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetProductsByOwnerId" OnGridEditModelSaving="OnProductGridItemSaving" ContextId="((Company)context.DataItem).Id" ParentData="(Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Address">
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />

View File

@ -37,7 +37,7 @@
Click="ColumnChooserButton_Click" />
</div>
<UserProductMappingGridComponent ShowNestedRows="true" GetAllTag="SignalRTags.GetAllUserProductMappings"></UserProductMappingGridComponent>
<UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllUserProductMappings"></UserProductMappingGridComponent>
</div>

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

@ -18,30 +18,26 @@
@using AyCode.Interfaces.Addresses
@using AyCode.Core
@inject IStringLocalizer<TIAMResources> Localizer
@inject IServiceProviderDataService serviceProviderDataService
@inject IUserDataService userDataService
@inject ITransferDataService transferDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient;
<ProductDetailGrid @ref="_productGrid"
GetAllMessageTag="GetAllTag"
DataSource = "productList"
ContextIds="new[] {(Guid)ContextId}"
ContextIds="new[] {ContextId}"
DataSource="ParentData?.Products ?? []"
GetAllMessageTag="GetAllTag"
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"/>
@ -55,7 +51,7 @@
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Permissions">
<UserProductMappingGridComponent ShowNestedRows="false" ContextId="((Product)context.DataItem).Id" GetAllTag="SignalRTags.GetUserProductMappingsByProductId">
<UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Never" ContextIds="new [] {((Product)context.DataItem).Id}" GetAllTag="SignalRTags.GetUserProductMappingsByProductId">
</UserProductMappingGridComponent>
</DxTabPage>
<DxTabPage Text="Profile">
@ -63,22 +59,22 @@
</DxTabPage>
</DxTabs>
</DetailRowTemplate>
<EditFormTemplate Context="EditFormContext">
<EditFormTemplate Context="editFormContext">
@{
var transfer2 = (Product)EditFormContext.EditModel;
var transfer2 = (Product)editFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductName) ColSpanMd="4">
@EditFormContext.GetEditor("Name")
@editFormContext.GetEditor("Name")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductType) ColSpanMd="4">
@EditFormContext.GetEditor("ProductType")
@editFormContext.GetEditor("ProductType")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.Price) ColSpanMd="4">
@EditFormContext.GetEditor("Price")
@editFormContext.GetEditor("Price")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="4">
@EditFormContext.GetEditor("Description")
@editFormContext.GetEditor("Description")
</DxFormLayoutItem>
@ -88,14 +84,14 @@
</ProductDetailGrid>
@code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public Guid? ContextId { get; set; } = null;
[Parameter] public IProductsRelation ParentData { get; set; } = null!;
[Parameter] public bool KeyboardNavigationEnabled { 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;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private ProductDetailGrid _productGrid;
private List<Product> productList = new List<Product>();
private ProductDetailGrid _productGrid = null!;
private LoggerClient<ProductDetailGridComponent> _logger = null!;
protected override void OnInitialized()
{
@ -121,31 +117,12 @@
// }
// else
base.OnParametersSet();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
// if(firstRender)
// {
// _productGrid.GetAllMessageTag = GetAllTag;
// // if (ParentData != null)
// // {
// // _productGrid.DataSource = new List<Product>();
// // _productGrid.DataSource = ParentData.Products;
// // }
// }
await base.OnParametersSetAsync();
}
private void DataItemChanged(GridDataItemChangedEventArgs<Product> args)
{
_logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}");
//ProductGrid.SaveChangesAsync();
}
public async Task DataItemSaving(GridEditModelSavingEventArgs e)

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

@ -29,47 +29,40 @@
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridCommandColumn Width="135" MinWidth="135" DeleteButtonVisible="AcDomain.IsDeveloperVersion" EditButtonVisible="AcDomain.IsDeveloperVersion" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" />
</Columns>
<DetailRowTemplate>
@{
if (ShowNestedRows)
{
<DxTabs>
<DxTabPage Text="Products">
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>
}
<DxTabs>
<DxTabPage Text="Products">
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" KeyboardNavigationEnabled="true"/>
</DxTabPage>
</DxTabs>
}
</DetailRowTemplate>
<EditFormTemplate Context="UserEditFormContext">
<EditFormTemplate Context="userEditFormContext">
@{
var transfer2 = (UserProductMapping)UserEditFormContext.EditModel;
var transfer2 = (UserProductMapping)userEditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="UserId" ColSpanMd="4">
@UserEditFormContext.GetEditor("UserId")
@userEditFormContext.GetEditor("UserId")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Product:" ColSpanMd="4">
<DxComboBox Data="@_availableProducts" TextFieldName="Name" @bind-Value="((UserProductMapping)UserEditFormContext.EditModel).ProductId" />
<DxComboBox Data="@_availableProducts" TextFieldName="Name" @bind-Value="((UserProductMapping)userEditFormContext.EditModel).ProductId" />
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
@UserEditFormContext.GetEditor("Permissions")
@userEditFormContext.GetEditor("Permissions")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
@ -83,11 +76,9 @@
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
[Parameter] public bool ShowNestedRows { get; set; } = false;
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
[Parameter] public Guid[]? ContextIds { get; set; }
private LoggerClient<UserProductMappingGridComponent> _logger;
@ -95,22 +86,12 @@
private ProductDetailGridComponent bleh;
protected override void OnParametersSet()
{
if (ContextId != null)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId;
}
base.OnParametersSet();
}
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
base.OnInitialized();
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
@ -126,30 +107,4 @@
//e.EditModel = newProductMapping;
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
_logger.Info("New orderData added");
else
_logger.Info("orderData updated");
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
_logger.Info("orderData deleted");
}
async Task UpdateDataAsync()
{
//refresh grid
_logger.Info("orderData grid refreshed");
}
}

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

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

View File

@ -18,6 +18,7 @@ using AyCode.Services.SignalRs;
using AyCode.Utils.Extensions;
using TIAM.Entities.Drivers;
using TIAM.Services;
using TIAM.Entities.Products;
namespace TIAMWebApp.Server.Controllers
{
@ -49,10 +50,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 +107,7 @@ namespace TIAMWebApp.Server.Controllers
[SignalR(SignalRTags.GetCompanies)]
public async Task<string> GetServiceProviders()
{
return await adminDal.GetServiceProvidersJsonAsync();
return await adminDal.GetCompaniesJsonAsync();
}
//18.
@ -114,15 +115,23 @@ namespace TIAMWebApp.Server.Controllers
[HttpPost]
[Route(APIUrls.GetServiceProviderByIdRouteName)]
[SignalR(SignalRTags.GetCompany)]
public async Task<string> GetServiceProviderById([FromBody] Guid id)
public async Task<Company?> GetServiceProviderById([FromBody] Guid id)
{
_logger.Info($@"GetServiceProviderById called with id: {id}");
List<Company> compList = new List<Company>();
var result = await adminDal.GetServiceProviderByIdAsync(id);
compList.Add(result);
return compList.ToJson();
return await adminDal.GetCompanyByIdAsync(id);
}
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.GetCompaniesById)]
public async Task<List<Company>> GetServiceProvidersById(Guid id)
{
_logger.Info($@"GetServiceProvidersById called with id: {id}");
var company = await GetServiceProviderById(id);
return company == null ? [] : [company];
}
//17.
[Authorize]
@ -134,7 +143,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);
@ -152,7 +161,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);
@ -203,7 +212,7 @@ namespace TIAMWebApp.Server.Controllers
[SignalR(SignalRTags.DeleteUserProductMapping)]
public async Task<string> DeleteUserProductMapping(UserProductMapping userProductMapping)
{
_logger.Info($"UpdateUserProductMapping called! + {userProductMapping.Id}");
_logger.Info($"DeleteUserProductMapping called! + {userProductMapping.Id}");
var result = await adminDal.RemoveUserProductMappingAsync(userProductMapping.Id);
@ -215,64 +224,57 @@ namespace TIAMWebApp.Server.Controllers
[HttpPost]
[Route(APIUrls.GetUserProductMappingsByProductIdRouteName)]
[SignalR(SignalRTags.GetUserProductMappingsByProductId)]
public async Task<string> GetUserProductMappingsByProductId(Guid productId)
public async Task<List<UserProductMapping>> GetUserProductMappingsByProductId(Guid productId)
{
_logger.Info($@"GetUserProductMappingsByUserId called with serviceProviderId: {productId}");
_logger.Info($@"GetUserProductMappingsByProductId called with serviceProviderId: {productId}");
var userProductMappings = adminDal.GetAllUserProductMappings();
var myUserProductMappings = userProductMappings.Where(x => x.ProductId == productId).ToList();
//put serviceprovider id and name into a dictionary
return myUserProductMappings.ToJson();
return await adminDal.GetUserProductMappingsByProductIdAsync(productId);
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetUserProductMappingsByUserIdRouteName)]
[SignalR(SignalRTags.GetUserProductMappingsByUserId)]
public async Task<string> GetUserProductMappingsByUserId(Guid userId)
public async Task<List<UserProductMapping>> GetUserProductMappingsByUserId(Guid userId)
{
_logger.Info($@"GetUserProductMappingsByUserId called with userId: {userId}");
var userProductMappings = adminDal.GetAllUserProductMappings();
var myUserProductMappings = userProductMappings.Where(x => x.UserId == userId).OrderBy(x => x.ProductId).ToList();
//put serviceprovider id and name into a dictionary
return myUserProductMappings.ToJson();
return (await adminDal.GetUserProductMappingsByUserIdAsync(userId)).OrderBy(x => x.ProductId).ToList();
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetUserProductMappingByIdRouteName)]
[SignalR(SignalRTags.GetUserProductMappingById)]
public async Task<string> GetUserProductMappingById(Guid id)
public async Task<UserProductMapping?> GetUserProductMappingById(Guid id)
{
_logger.Info($@"GetUserProductMappingsByUserId called with userId: {id}");
_logger.Info($@"GetUserProductMappingById called with userId: {id}");
var userProductMappings = adminDal.GetAllUserProductMappings();
var userproductMapping = await adminDal.GetUserProductMappingByIdAsync(id);
return userproductMapping;
}
var myUserProductMappings = userProductMappings.Where(x => x.Id == id).ToList();
//put serviceprovider id and name into a dictionary
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.GetUserProductMappingsById)]
public async Task<List<UserProductMapping>> GetUserProductMappingsById(Guid id)
{
_logger.Info($@"GetUserProductMappingsById called with userId: {id}");
return myUserProductMappings.ToJson();
var userproductMapping = await adminDal.GetUserProductMappingByIdAsync(id);
return userproductMapping == null ? [] : [userproductMapping];
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.GetAllUserProductMappingsRouteName)]
[SignalR(SignalRTags.GetAllUserProductMappings)]
public async Task<string> GetAllUserProductMappings()
public async Task<List<UserProductMapping>> GetAllUserProductMappings()
{
_logger.Info($@"GetAllUserProductMappings called");
var serviceProviders = adminDal.GetAllUserProductMappings()!.OrderBy(x => x.ProductId);
//put serviceprovider id and name into a dictionary
return serviceProviders.ToJson();
var companyies = (await adminDal.GetAllUserProductMappingsAsync()).OrderBy(x => x.ProductId).ToList();
return companyies;
}
[AllowAnonymous]
@ -283,8 +285,7 @@ namespace TIAMWebApp.Server.Controllers
{
_logger.Info($@"GetCarsForUserProductMapping called with userProductMappingId: {userProductMappingId}");
var cars = adminDal.GetCarByUserProductMappingId(userProductMappingId);
var cars = await adminDal.GetCarByUserProductMappingIdAsync(userProductMappingId);
return cars;
}
@ -297,7 +298,6 @@ namespace TIAMWebApp.Server.Controllers
_logger.Info($@"GetAllCars called ");
var cars = await adminDal.GetAllCarsAsync();
return cars;
}
@ -339,12 +339,10 @@ namespace TIAMWebApp.Server.Controllers
[Tags("Finished", "Cars")]
[EndpointSummary("Create car")]
[SignalR(SignalRTags.CreateCar)]
public async Task<Car> CreateCar(Car car)
public async Task<Car?> CreateCar(Car car)
{
var result = await CarDataChanging(car, TrackingState.Add);
if (result)
return car;
else return null;
return result ? car : null;
}
[AllowAnonymous]
@ -353,12 +351,10 @@ namespace TIAMWebApp.Server.Controllers
[Tags("Finished", "Cars")]
[EndpointSummary("Update car")]
[SignalR(SignalRTags.UpdateCar)]
public async Task<Car> UpdateCar(Car car)
public async Task<Car?> UpdateCar(Car car)
{
var result = await CarDataChanging(car, TrackingState.Update);
if (result)
return car;
else return null;
return result ? car : null;
}
@ -376,8 +372,7 @@ namespace TIAMWebApp.Server.Controllers
[Tags("In-Progress", "Product")]
[SignalR(SignalRTags.AddProduct)]
public async Task<IActionResult> AddProduct([FromBody] Product product)
{
{
_logger.Info(@"AddProduct called");
if (product == null)
@ -386,7 +381,7 @@ namespace TIAMWebApp.Server.Controllers
}
else
{
var result = adminDal.AddProductAsync(product);
var result = await adminDal.AddProductAsync(product);
return Ok(product);
}
}
@ -458,19 +453,12 @@ namespace TIAMWebApp.Server.Controllers
[HttpGet]
[Route(APIUrls.GetAllProductsRouteName)]
[Tags("In-Progress", "Product")]
public async Task<string> GetAllProducts()
public Task<string> GetAllProducts()
{
_logger.Info("GetAllProducts called");
var products = adminDal.GetProductsJson();
if (products != null)
{
return products;
}
else
{
return null;
}
return Task.FromResult(products);
}
[AllowAnonymous]
@ -478,14 +466,11 @@ namespace TIAMWebApp.Server.Controllers
[Route(APIUrls.GetProductByIdRouteName)]
[Tags("In-Progress", "Product")]
[SignalR(SignalRTags.GetProductById)]
public async Task<Product> GetProductById(Guid productId)
public async Task<Product?> GetProductById(Guid productId)
{
_logger.Info("GetAllProducts called");
var products = adminDal.GetProductById(productId);
return products;
return await adminDal.GetProductByIdAsync(productId);
}
@ -495,14 +480,9 @@ namespace TIAMWebApp.Server.Controllers
public async Task<List<Product>> GetProductsById(Guid productId)
{
_logger.Info("GetAllProducts called");
var product = await GetProductById(productId);
var products = new List<Product>();
if (product != null) {
products.Add(product);
}
return products;
var product = await GetProductById(productId);
return product == null ? [] : [product];
}
}
}

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>