1@inject ProductViewModel _productViewService
2@inject ModuleViewModel _moduleViewService
3@inject PriceListViewModel _priceListViewService
4@inject PriceElementViewModel _priceElementViewService
5@inject StateService _stateService
10<ProductSelector ChangeProductEvent="ChangeProduct"/>
16 private void ChangeProduct(string name)
18 if (_productViewService.Products != null)
20 _stateService.SelectedProductSeq.Value = (from p in _productViewService.Products
21 where p.ProductName == name
22 select p.ProductSeq).First()!.Value;
24 SelectNewestPriceLists();
27 private void SelectFinancials() => ChangeProduct("Escali Financials");
29 private void SelectNewestPriceLists()
31 if (_priceListViewService.PriceLists != null)
33 var priceListSeq = _priceListViewService.PriceLists?
34 .Where(p => p.ProductSeq == _stateService.SelectedProductSeq.Value)
35 .OrderByDescending(p => p.DateTo)
38 _stateService.SelectedPriceListSeq.Value = priceListSeq!.Value;
42 protected override void OnInitialized()
44 _stateService.HeaderName.Value = "Produkter";
46 _productViewService.DataChanged += StateHasChanged;
48 _productViewService.DataChanged += SelectFinancials;
49 _priceListViewService.DataChanged += SelectNewestPriceLists;
51 if (_productViewService.Products != null) SelectFinancials();
52 if (_priceListViewService.PriceLists != null) SelectNewestPriceLists();
55 void IDisposable.Dispose()
57 _productViewService.DataChanged -= StateHasChanged;
59 _productViewService.DataChanged -= SelectFinancials;
60 _priceListViewService.DataChanged -= SelectNewestPriceLists;