public ProductListViewModel(IDialogCoordinator dialogCoordinator)
        {
            persistance = Singleton <IPersistance> .GetInstance();

            ProductsView            = new ObservableCollection <Product>(persistance.GetProductList() as Collection <Product>);
            ModifyCommand           = new RelayCommand(ModifyProduct);
            ConfirmCommand          = new RelayCommand(ConfirmEdit);
            CancelCommand           = new RelayCommand(CancelEdit);
            SortCommand             = new RelayCommand <string>(sortProductView);
            AddProductToListCommand = new RelayCommand(AddProductToList);
            DeleteProductCommand    = new RelayCommand(DeleteProduct);
            listTickets             = persistance.GetTicketsDB();
            this.dialogCoordinator  = dialogCoordinator;
        }
Exemple #2
0
        public void LoadProducts()
        {
            fullProductList = new Collection <Product>();

            foreach (Product p in persistance.GetProductList())
            {
                if (p.Stock != 0)
                {
                    fullProductList.Add(p);
                }
            }

            ProductsView = new ObservableCollection <Product>(fullProductList as Collection <Product>);
        }
        private void ConfirmEdit()
        {
            Modifiable = false;
            var originalProduct = persistance.GetProductList();

            if (oldProduct == null)
            {
                var id = persistance.AddProductToDB(SelectedProduct);
                SelectedProduct.ID = id;
            }
            else
            {
                oldProduct = null;
                persistance.UpdateProductDB(SelectedProduct);
            }
        }