public IHttpActionResult PostProducts(ProductsList productsList)
 {
     if (!ModelState.IsValid)
     {
         return BadRequest(ModelState);
     }
     Products productes = new Products();
     //productes. = productsList.Poid;
     productes.MProductId = productsList.MProductId;
     productes.Introduction = productsList.Introduction;
     productes.Details = productsList.Details;
     productes.VideoLink = productsList.VideoLink;
     db.Productses.Add(productes);
     db.SaveChanges();
     var images = productsList.UploadImagesName.Split(',');
     UploadImages ui = new UploadImages();
     for (int i = 0; i < images.Length; i++)
     {
         if (images[i] == "" || images[i] == null)
         {
         }else
         {
             ui.ProductId = productes.Id;
             ui.ImageName = images[i];
             db.UploadImageses.Add(ui);
             db.SaveChanges();
         }
     }
     return  Ok(productes);
 }
 public IHttpActionResult GetProductList()
 {
     var userid = User.Identity.GetUserId();
     ProductsLists = new List<ProductsList>();
     var productses = Db.MainProducts.ToList();
     if (productses.FirstOrDefault() == null)
     {
         return NotFound();
     }
     foreach (var item in productses)
     {
         ProductsList = new ProductsList();
         int user = Convert.ToInt32(userid);
         var follower = Db.FollowProducts.FirstOrDefault(x => x.MProductId == item.Id && x.Euid == user);
         if (follower != null)
         {
             ProductsList.Flag = true;
         }
         else
         {
             ProductsList.Flag = false;
         }
         ProductsList.Id = item.Id;
         ProductsList.CompanyName = item.ProductOwner.CompanyName;
         ProductsList.ProductName = item.ProductName;
         ProductsLists.Add(ProductsList);
     }
     return Ok(ProductsLists);
 }
        public IHttpActionResult PostMainProduct(ProductsList productsList)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            MainProduct mproductes = new MainProduct();
            mproductes.Poid = productsList.Poid;
            mproductes.ProductName = productsList.ProductName;
            db.MainProducts.Add(mproductes);
            db.SaveChanges();

            return Ok(mproductes);
        }
        public IHttpActionResult PostProducts(ProductsList productsList)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            var userid = User.Identity.GetUserId();
            var followProducts = new FollowProducts();
            followProducts.Euid = Convert.ToInt32(userid);
            followProducts.MProductId = productsList.Id;

            Db.FollowProducts.Add(followProducts);
            Db.SaveChanges();
            return Ok();
        }