private void ProductBox_clickEvent(object sender, EventArgs e) { var article = (sender as ProductBoxViewModel).product; if (article.Variantes.Any()) { // has variante Refresh = "KeyboardBackspace"; NotifyOfPropertyChange("Refresh"); var vars = article.Variantes; Products.Clear(); foreach (var item in vars) { var productBox = new ProductBoxViewModel(item); productBox.product = article; productBox.clickEvent += ProductBox_clickEvent1; var view = DataHelpers.container.Get <ViewManager>().CreateAndBindViewForModelIfNecessary(productBox); Products.Add(view); } NotifyOfPropertyChange("Products"); NotifyOfPropertyChange("CmdStatus"); } else { var cartLine = new CartLine(article, CurrentTicket?.ListePrix); AddQteOrItem(1, cartLine); } }
public async Task Setup(IEnumerable <Article> _items = null) { // AllCartLines = new HashSet<CartLine>(); _EstPrepayeOnly = settings.EstPrepayeOnly; // DispalyNameproperty = string.IsNullOrWhiteSpace(settings.NameProperty) ? "Name" : settings.NameProperty; Products = new BindableCollection <UIElement>(); //Categories = new BindableCollection<Button>(); LoadCategorie(); if (_items == null) { // _items = await DataHelpers.instanc().GetMongoDataPaged<Article>(1, 50) as IEnumerable<Article>; AllArticles = await DataHelpers.instanc().GetData <Article>(a => true) as IEnumerable <Article>; _items = AllArticles; } foreach (var item in _items) { //Products = new ObservableCollection<UIElement>(); var productBox = new ProductBoxViewModel(item); productBox.clickEvent += ProductBox_clickEvent; var view = aViewManager.CreateAndBindViewForModelIfNecessary(productBox); Products.Add(view); // } //Categories.Refresh(); //Products.Refresh(); NotifyOfPropertyChange("Products"); NotifyOfPropertyChange("CartData"); NotifyOfPropertyChange("Total"); ShowTicketsVisible = false; }