// GET: Backend/ProdColor
        public ActionResult Index(int pid)
        {
            if (HttpContext.Request.Cookies["IsLogin"].Value == "Admin")
            {
                ProdMaintainColorViewModel _PCVM = new ProdMaintainColorViewModel();

                var pd = db.Products.Find(pid);

                _PCVM.ProductID      = pd.ProductID;
                _PCVM.ProductName    = pd.ProductName;
                ViewBag.productcolor = db.Colors;

                return(View(_PCVM));
            }
            else
            {
                RedirectToAction("PermissionError", "ProductMaintain");
            }
            return(View());
        }
        public ActionResult ProdColorJson(int?pid)
        {
            List <ProdMaintainColorViewModel> pcvmlist = new List <ProdMaintainColorViewModel>();

            var ps = db.ProductColors.Where(x => x.ProductID == pid).OrderByDescending(x => x.ProductColorID);
            var c  = db.Colors;

            foreach (var item in ps)
            {
                ProdMaintainColorViewModel _psvm = new ProdMaintainColorViewModel
                {
                    ProductColorID = item.ProductColorID,
                    ProductID      = item.ProductID,
                    ColorID        = item.ColorID,
                    CreateDate     = item.CreateDate,
                    ColorName      = c.Where(x => x.ColorID == item.ColorID).FirstOrDefault().ColorName,
                    PhotoID        = (item.PhotoID == null ? 0 : item.PhotoID),
                };

                pcvmlist.Add(_psvm);
            }

            return(Json(pcvmlist, JsonRequestBehavior.AllowGet));
        }