public bool updateProductById(int id, ProductsAdModel productAd)
 {
     try
     {
         var product = this.GetProductById(id);
         if (product != null)
         {
             product.code            = productAd.code;
             product.name            = productAd.name;
             product.description     = productAd.description;
             product.image           = productAd.image;
             product.more_images     = productAd.more_images;
             product.detail          = productAd.detail;
             product.keywords        = productAd.keywords;
             product.includeVAT      = productAd.includeVAT;
             product.price           = productAd.price;
             product.price_promotion = productAd.price_promotion;
             product.menu_id         = JsonConvert.SerializeObject(productAd.menu_id);
             product.provider_id     = int.Parse(productAd.provider_id.ToString());
             product.start_time      = productAd.start_time;
             product.total_product   = productAd.total_product;
             db.Entry(product).State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
     }
     return(false);
 }
        public bool createProduct(ProductsAdModel productAd)
        {
            var product = new product();

            product.code            = productAd.code;
            product.name            = productAd.name;
            product.description     = productAd.description;
            product.image           = productAd.image;
            product.more_images     = productAd.more_images;
            product.detail          = productAd.detail;
            product.keywords        = productAd.keywords;
            product.includeVAT      = productAd.includeVAT;
            product.price           = productAd.price;
            product.price_promotion = productAd.price_promotion;
            product.top_hot         = false;
            product.menu_id         = JsonConvert.SerializeObject(productAd.menu_id);
            product.provider_id     = int.Parse(productAd.provider_id.ToString());
            product.start_time      = productAd.start_time;
            product.total_product   = productAd.total_product;
            product.total_sold      = 0;
            product.special         = false;
            product.view_count      = 0;
            product.status          = true;
            db.products.Add(product);
            db.SaveChanges();
            return(true);
        }