private void InitializeViewModel()
        {
            Products              = new List <Entities.Product>();
            ProductDetail         = new ProductModel();
            SearchProductsCommand = new CommandDelegate
                                    (
                (obj) => { return(true); },
                (obj) =>
            {
                var proxy = new NWindProxyService.Proxy();
                Products  = proxy.GetProductsByCategoryID(CategoryID);
            }
                                    );
            SearchProductByIDCommand = new CommandDelegate
                                       (
                (obj) => { return(true); },
                (obj) =>
            {
                if (SelectedProduct?.ProductID == 0)
                {
                    return;
                }

                var proxy   = new NWindProxyService.Proxy();
                var product = proxy.GetProductByID(SelectedProduct.ProductID);
                ProductDetail.ProductName  = product.ProductName;
                ProductDetail.CategoryID   = product.CategoryID;
                ProductDetail.ProductID    = product.ProductID;
                ProductDetail.UnitsInStock = product.UnitsInStock;
                ProductDetail.UnitPrice    = product.UnitPrice;
            }
                                       );
        }
示例#2
0
        void InitializeViewModel()
        {
            Products = new List <Entities.Product>();

            SearchProductsCommand = new CommandDelegate
                                        ((o) => { return(true); },
                                        (o) =>
            {
                var Proxy = new NWindProxyService.Proxy();
                Products  = Proxy.FilterProductsByCategoryID(CategoryID);
            });

            SearchProductByIDCommand = new CommandDelegate
                                           ((o) => { return(true); },
                                           (o) =>
            {
                if (ProductSelected.ProductID != 0)
                {
                    var Proxy    = new NWindProxyService.Proxy();
                    var p        = Proxy.RetrieveProductByID(ProductSelected.ProductID);
                    ProductName  = p.ProductName;
                    ProductID    = p.ProductID;
                    UnitsInStock = p.UnitsInStock;
                    UnitPrice    = p.UnitPrice;
                }
            });
        }
示例#3
0
        public CUD()
        {
            CreateProductoCommand = new CommandDelegate
                                    (
                (o) => { return(true); },
                (o) =>
            {
                var NewProduct = new EntitiesStandart.Products
                {
                    ProductName  = ProductName_BF,
                    CategoryID   = CategoryID_BF,
                    UnitsInStock = UnitsInStock_BF,
                    UnitPrice    = UnitPrice_BF
                };
                var Proxy  = new NWindProxyService.Proxy();
                NewProduct = Proxy.CreateProduct(NewProduct);
                ProductID  = NewProduct.ProductID;
            }
                                    );
            UpdateProductoCommand = new CommandDelegate
                                    (
                (o) => { return(true); },
                (o) =>
            {
                var CurrentProducto = new EntitiesStandart.Products
                {
                    ProductID    = ProductID_BF,
                    ProductName  = ProductName_BF,
                    CategoryID   = CategoryID_BF,
                    UnitsInStock = UnitsInStock_BF,
                    UnitPrice    = UnitPrice_BF
                };
                var Proxy    = new NWindProxyService.Proxy();
                var Modified = Proxy.UpdateProduct(CurrentProducto);
            }
                                    );
            DeleteProductoCommand = new CommandDelegate
                                    (
                (o) => { return(true); },
                (o) =>
            {
                var Proxy     = new NWindProxyService.Proxy();
                var IsDeleted = Proxy.DeleteProduct(ProductID);
                if (IsDeleted)
                {
                    ProductID    = 0;
                    ProductName  = "";
                    CategoryID   = 0;
                    UnitsInStock = 0;
                    UnitPrice    = 0;
                }
            }

                                    );
        }
示例#4
0
        private void InitializeViewModel()
        {
            Product = new ProductModel();
            CreateProductCommand = new CommandDelegate
                                   (
                (obj) => { return(true); },
                (obj) =>
            {
                var newProduct = new Entities.Product()
                {
                    CategoryID   = Product.CategoryID,
                    ProductName  = Product.ProductName,
                    UnitPrice    = Product.UnitPrice,
                    UnitsInStock = Product.UnitsInStock
                };
                var proxy         = new NWindProxyService.Proxy();
                newProduct        = proxy.CreateProduct(newProduct);
                Product.ProductID = newProduct.ProductID;
            }
                                   );
            UpdateProductCommand = new CommandDelegate
                                   (
                (obj) => { return(true); },
                (obj) =>
            {
                var updateProduct = new Entities.Product()
                {
                    ProductID    = Product.ProductID,
                    CategoryID   = Product.CategoryID,
                    ProductName  = Product.ProductName,
                    UnitPrice    = Product.UnitPrice,
                    UnitsInStock = Product.UnitsInStock
                };
                var proxy   = new NWindProxyService.Proxy();
                var updated = proxy.UpdateProduct(updateProduct);

                if (updated)
                {
                    HasError = false;
                    Message  = "The product has been updated correctly.";
                }
                else
                {
                    HasError = true;
                    Message  = "The product could not be updated.";
                }
            }
                                   );
            DeleteProductCommand = new CommandDelegate
                                   (
                (obj) => { return(true); },
                (obj) =>
            {
                var proxy   = new NWindProxyService.Proxy();
                var deleted = proxy.DeleteProduct(Product.ProductID);
                if (deleted)
                {
                    HasError = false;
                    Product  = new ProductModel();
                    Message  = "The product has been deleted correctly.";
                }
                else
                {
                    HasError = true;
                    Message  = "The product could not be deleted.";
                }
            }
                                   );
        }