public bool EditPicture(int index, string fileName, Product product)
        {
            if (product != null)
            {
                if (index == 0 && product.Picture == "Product-Value.jpg")
                {
                    product.Picture = fileName;
                }

                else
                {
                    ProductImage p = new ProductImage();
                    p.ProductId = product.Id;
                    p.ImageLink = fileName;
                    _db.ProductImages.Add(p);
                }

                _db.SaveChanges();

                return true;
            }

            return false;
        }
        public static List<ProductImage> GetProductImagesFromServer(string request, Method method)
        {
            var products = new List<ProductImage>();

            var results = Request(request, method);
            try
            {
                JArray ja = JsonConvert.DeserializeObject<JArray>(results);
                foreach (var r in ja)
                {
                    var c = (ProductImageApi)JsonConvert.DeserializeObject(r.ToString(), typeof(ProductImageApi));
                    var p = new ProductImage(c);
                    products.Add(p);
                }
            }
            catch (Exception ex1)
            {
                Console.WriteLine(ex1.ToString());

                try
                {
                    JObject r = JsonConvert.DeserializeObject<JObject>(results);
                    var c = (ProductImageApi)JsonConvert.DeserializeObject(r.ToString(), typeof(ProductImageApi));
                    var p = new ProductImage(c);
                    products.Add(p);
                }
                catch (Exception ex2)
                {
                    Console.WriteLine(ex2.ToString());
                }
            }          

            return products;
        }
        public bool AddPicture(int productId, int index, string fileName)
        {
            var products = _db.Products.Where(p => p.Id == productId).ToList();

            if (products.Count > 0)
            {
                Product product = products[products.Count - 1];

                if (product != null)
                {
                    product.Picture = fileName;

                    if (index == 0)
                    {
                        product.Picture = fileName;
                    }
                    else
                    {
                        ProductImage p = new ProductImage();
                        p.ProductId = product.Id;
                        p.ImageLink = fileName;
                        _db.ProductImages.Add(p);
                    }

                    _db.SaveChanges();

                    return true;
                }
            }

            return false;
        }