public bool UpdateBlog(Blog entity)
        {
            using (var context = new eMarketContext())
            {
                context.Entry(entity).State = EntityState.Modified;
                context.SaveChanges();
                return(true);
            }

            return(false);
        }
        public bool CreateProductImage(ProductImage entity)
        {
            using (var context = new eMarketContext())
            {
                context.Set <ProductImage>().Add(entity);
                context.SaveChanges();
                return(true);
            }

            return(false);
        }
        public bool DeleteBlog(Blog entity)
        {
            using (var context = new eMarketContext())
            {
                context.Set <Blog>().Remove(entity);
                context.SaveChanges();
                return(true);
            }

            return(false);
        }
        public bool UpdateMessageChecked(bool check, string guidNumber)
        {
            using (var context = new eMarketContext())
            {
                var message = context.Messages.Where(x => x.GuidNumber == guidNumber).FirstOrDefault();
                if (message != null)
                {
                    message.IsChecked = check;
                    context.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }
        public bool UpdateProductApproval(bool check, int productID)
        {
            using (var context = new eMarketContext())
            {
                var products = context.Products.Where(x => x.ProductId == productID && x.IsApproved == false).FirstOrDefault();
                if (products != null)
                {
                    products.IsApproved = check;
                    context.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }
        public bool DeleteProductImage(string imageUrl)
        {
            using (var context = new eMarketContext())
            {
                var product_images = context.ProductImages.Where(x => x.Url == imageUrl).FirstOrDefault();
                if (product_images != null)
                {
                    context.Set <ProductImage>().Remove(product_images);
                    context.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }
        public bool UpdateProductImage(int productImageID, string imageUrl)
        {
            using (var context = new eMarketContext())
            {
                var product_image = context.ProductImages.Where(x => x.ProductImageId == productImageID).FirstOrDefault();
                if (product_image != null)
                {
                    product_image.Url = imageUrl;
                    context.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }
        public bool UpdateProductCategories(int CategoryId, int SubCategoryId, int product_id)
        {
            using (var context = new eMarketContext())
            {
                var product = context.Products.Where(x => x.ProductId == product_id).FirstOrDefault();
                if (product != null)
                {
                    product.CategoryId    = CategoryId;
                    product.SubCategoryId = SubCategoryId;
                    context.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }
        public bool UpdateProductInfo(string name, string description, double price, int Stock, int product_id)
        {
            using (var context = new eMarketContext())
            {
                var product = context.Products.Where(x => x.ProductId == product_id).FirstOrDefault();
                if (product != null)
                {
                    product.Name        = name;
                    product.Description = description;
                    product.Price       = price;
                    product.Stock       = Stock;
                    context.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }