public void EditProduct(int index, string productName, int quantity, decimal price)
        {
            byte[]           binaryImage      = null;
            WpfMarketContext wpfMarketContext = new WpfMarketContext();

            foreach (Product product in wpfMarketContext.Products)
            {
                if (product.Name.Equals(productModels[index].Name))
                {
                    binaryImage = product.Image;
                    wpfMarketContext.Products.Attach(product);
                    wpfMarketContext.Products.Remove(product);
                }
            }

            Product newProduct = new Product()
            {
                Name     = productName,
                Quantity = quantity,
                Price    = price,
                Image    = binaryImage
            };

            wpfMarketContext.Products.Add(newProduct);
            wpfMarketContext.SaveChanges();

            productModels[index].Name     = productName;
            productModels[index].Quantity = quantity;
            productModels[index].Price    = price;
        }
        public void AddProduct(string productName, int quantity, decimal price, byte[] binaryImage)
        {
            WpfMarketContext wpfMarketContext = new WpfMarketContext();
            Product          product          = new Product()
            {
                Name     = productName,
                Quantity = quantity,
                Price    = price,
                Image    = binaryImage
            };

            wpfMarketContext.Products.Add(product);
            wpfMarketContext.SaveChanges();

            ProductModel productModel = new ProductModel(productName, quantity, price, binaryImage);

            productModels.Add(productModel);
        }
        public void DeleteProduct(object productModel)
        {
            if (productModel == null)
            {
                return;
            }
            WpfMarketContext wpfMarketContext = new WpfMarketContext();

            foreach (Product product in wpfMarketContext.Products)
            {
                if (product.Name.Equals((productModel as ProductModel).Name))
                {
                    wpfMarketContext.Products.Attach(product);
                    wpfMarketContext.Products.Remove(product);
                }
            }
            wpfMarketContext.SaveChanges();
            productModels.Remove(productModel as ProductModel);
        }