public IActionResult EditProduct1(tProductViewModel tProductEdit)
        {
            TProduct EditP = db.TProducts.FirstOrDefault(p => p.FProductId == tProductEdit.FProductId);

            if (EditP != null)
            {
                if (tProductEdit.imgs != null)
                {
                    foreach (var a in tProductEdit.imgs)
                    {
                        string photoName = Guid.NewGuid().ToString() + ".jpg";
                        using (var photo = new FileStream(iv_host.ContentRootPath + @"\wwwroot\img\" + photoName, FileMode.Create))
                        {
                            a.CopyTo(photo);
                        }
                        TProductPic tp = new TProductPic();
                        tp.FProductId      = tProductEdit.FProductId;
                        tp.FProductPicPath = @"/img/" + photoName;
                        db.Update(tp);
                        db.SaveChanges();
                    }
                }
                EditP.FProductName        = tProductEdit.FProductName;
                EditP.FProductPrice       = tProductEdit.FProductPrice;
                EditP.FProductQty         = tProductEdit.FProductQty;
                EditP.FProductDescription = tProductEdit.FProductDescription;
                EditP.FProductCategory    = tProductEdit.FProductCategoryId;
                EditP.FSize = tProductEdit.Size;
                db.SaveChanges();
            }
            return(RedirectToAction("ShpManagement"));
        }
 //產品明細
 public IActionResult ShpSingle(int?id)
 {
     Products = db.TProducts.ToList().GroupJoin(db.TProductPics, p => p.FProductId, ph => ph.FProductId, (p, pho) => new tProductViewModel
     {
         FProductId          = p.FProductId,
         FProductName        = p.FProductName,
         FProductPrice       = (int)p.FProductPrice,
         FProductDescription = p.FProductDescription,
         FProductQty         = p.FProductQty,
         //FProductCategoryId = p.FProductCategoryId,
         Pics = pho,
     }).FirstOrDefault(n => n.FProductId == id);
     HttpContext.Session.SetObject("text", Products);
     return(View(Products));
 }
        public IActionResult ShpAddProduct(tProductViewModel p)
        {
            db.TProducts.Add(p.product);
            db.SaveChanges();
            foreach (var a in p.imgs)
            {
                string photoName = Guid.NewGuid().ToString() + ".jpg";
                using (var photo = new FileStream(iv_host.ContentRootPath + @"\wwwroot\img\" + photoName, FileMode.Create))
                {
                    a.CopyTo(photo);
                }
                TProductPic tp = new TProductPic();
                tp.FProductPicPath = @"/img/" + photoName;
                tp.FProductId      = p.product.FProductId;
                db.TProductPics.Add(tp);
                db.SaveChanges();
            }

            return(RedirectToAction("ShpManagement"));
        }