public ActionResult CopyProductPopup(int Id, string btnIdToRefresh, string frmIdToRefresh, CopyProductModel model)  //hidden variable on form as well as model
        {
            //TODO: permissions to copy product
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            //As yet don;t need config settings to decide onything for copyproduct
            //var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            //var AUConsignorSettings = _settings.LoadSetting<AUConsignorSettings>(storeScope);
            //if AUConsignorSettings.StoreTypeId = AUStoreTypeEnum.InternetAuction {.....}


            try
            {
                

                if (model.NewSku == "")
                {
                    ErrorNotification("Product could not be copied because a new SKU was not provided. Please try again and provide a New SKU");
                    return RedirectToAction("Edit", "Product", new { id = model.Id });
                }

                string returnMessage = "";

                //check to make sure the New Sku does not already exist as this is the promary key for the client
                var skuProduct = _productService.GetProductBySku(model.NewSku);
                if (skuProduct != null)
                {
                    ErrorNotification("Product could not be copied because a Product with that SKU already exists - try again with a New SKU");
                    return RedirectToAction("Edit", "Product", new { id = model.Id });
                }
                
                var originalProduct = _productService.GetProductById(model.Id);
                var originalLot = _consignorService.GetLotByProductId(model.Id);


                //TODO: a vendor should have access only to his products. Need to bring in workcontext
                //if (_workContext.CurrentVendor != null && originalProduct.VendorId != _workContext.CurrentVendor.Id)
                //    return RedirectToAction("ManageProducts", "AUConsignor"); //---> make this ManageProducts?
               
                var newProduct = _copyProductService.CopyProduct(originalProduct,
                    model.Name, model.Published, model.CopyImages);

                //make sure to update sku after CopyProduct above as CopyProduct is updating the original product for some reason so can't stuff 
                //it into original product before you copy
                
                newProduct.Sku = model.NewSku;
                _productService.UpdateProduct(newProduct);

                returnMessage = "The product was copied to a new SKU (" + newProduct.Sku + ") ";

                // you won't copy a lot if it's a retail store - you don't need to check the store config though because a lot will only be alloed
                // to exist in in Internet Auction Bidding, Internet Auction and Live Bidding, and Mixed Retail stores. Lots are not allowed in 
                // "Original Retail	" stores. The check for a null lot will also avoid if somehow lot is missing in a corrunt lot situation
                if (originalLot != null)
                {
                    var newLot = _lotService.CopyLot(originalProduct, model.NewSku);
                    returnMessage = returnMessage + "and the associated lot information was copied as well. ";
                }
                else
                {
                    returnMessage = returnMessage + "- there was no associated lot/consignor information to copy. ";
                }


                if (model.UnPublishOld && originalProduct.Published == true)
                {
                    originalProduct.Published = false;
                    _productService.UpdateProduct(originalProduct);
                    returnMessage = returnMessage + "The original product was unpublished. ";
                }

                SuccessNotification("The product has been copied successfully");
                //return RedirectToAction("Edit", "Product", new { id = newProduct.Id });

                ViewBag.RefreshPage = true;
                ViewBag.newProductId = newProduct.Id;
                ViewBag.btnId = btnIdToRefresh;
                ViewBag.formId = frmIdToRefresh;

                //TODO: ADD TEST TO SEE IF COPYPRODUCT OR SPLITPRODUCT (FROM PARM) ALSO DETERMIN IF SOURCE PRODUCT SHOULD BE INACTIVATED
                return View("CopyProduct", model);

            }
            catch (Exception exc)
            {
                ErrorNotification(exc.Message);
                return RedirectToAction("Edit", "Product", new { id = model.Id });
            }
        }
        //used in copyproduct, splitproduct, combineproduct views for dynamic edit check using jquery
        //public JsonResult IsSkuUsedForMerge(string NewSku)
        //{
        //    if (NewSku == null)
        //        throw new ArgumentNullException("NewSku");

        //    var product = _productService.GetProductBySku(NewSku);

        //    if (product != null)
        //    {
        //        return Json("Warning", "ProductExists", JsonRequestBehavior.AllowGet);
        //    }

        //    return Json(true, JsonRequestBehavior.AllowGet);
        //}

        public ActionResult CopyProductPopup(int Id, string Name, bool Published = true, bool CopyImages = true, string btnId = null, string formId = null)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return View("~/Administration/Views/Security/AccessDenied.cshtml");

            var originalProduct = _productService.GetProductById(Id);
            if (originalProduct == null)
            {
                ErrorNotification("Fatal error - product id passed into copyproduct not found - please notify Administrator");
                return RedirectToAction("List", "Product");
            }

            var model = new CopyProductModel();  //using same search model as ManageSales - Note no constructor

            //a vendor should have access only to his products. Set the indicator in the model
            //model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;
            model.Id = Id;
            model.Name = Name;
            model.Published = Published;
            model.CopyImages = CopyImages;
            model.UnPublishOld = false;

            model.OriginalProductPublished = originalProduct.Published;

            return View("CopyProduct", model);
        }