I am new to Blazor and have a basic question which I am not sure how to acheive this. I am building a POS Application in which users will have Touch application to sell products.
Now, I have all products loaded in a list below:
private List<ProductModel>? Products = [];Which gets updated when user selects e.g. quantity increments when selected for sale and decrements when removed from sale. The good part is if I run 2 or 3 or 4 browser with same URL the quantity is shared across. Meaning you can run adjacent touch apps with shared list object and prevents from over selling.
However, I have search on the page as well which filters out the product that are displayed. Below is my code for Searching filter :
public async void OnSearch(string args){ if (isChecked == true) { if (args != "") { // Filter products where VariationCombinations is null var productsToRemove = this.Products .Where(x => x.ProductSiteAuth.Any(y => y.VariationCombinations == null)) .Where(e => (e.Name != null && !e.Name.ToUpper().Contains(args.ToUpper()) || (e.Short_Name != null && !e.Short_Name.ToUpper().Contains(args.ToUpper())))) .ToList(); // Remove the filtered products from the original list foreach (var product in productsToRemove) { this.Products.Remove(product); } this.Products.ForEach(product => { product.ProductSiteAuth?.RemoveAll(auth => auth.VariationCombinations != null && ( (auth.VariationCombinations.Product_Variation_Combination_Name != null && !auth.VariationCombinations.Product_Variation_Combination_Name.ToUpper().Contains(args.ToUpper())) || (auth.VariationCombinations.Product_Variation_Combination_Short_Name != null && !auth.VariationCombinations.Product_Variation_Combination_Short_Name.ToUpper().Contains(args.ToUpper())) ) ); }); } else { Products = await CacheService.GetDataAsync(CacheKeys.ProductsCache, ProductService.GetProductsList, new CacheOptions { SlidingExpiration = TimeSpan.FromMinutes(30) }); } } else { if (args != "") { this.Categories = this.Categories.FindAll(e => (e.Title.Contains(args) || e.SubTitle.Contains(args) || e.Content.Contains(args) || e.Title.ToLower().Contains(args) || e.SubTitle.ToUpper().Contains(args.ToUpper()) || e.Content.ToUpper().Contains(args.ToUpper()))); } else { this.Categories = CategoriesModel.GetCategories(this.FilteringValue).Result; } } StateHasChanged();}The issue I am facing in the code is that now since all browser tabs on same URL pointing to same shared product list, when 1 user on 1 tab searches it removes item from Product list and other users get issue when selecting that product, or if one 1 user searches product and the other user refreshes page they see filtered products as well.
How can I make search independent for each user where as share product list for quantity management ?
Please advise or at least guide me how can I do this ?
I want to share list for quantity management but for front end display it should not share products list.