public ActionResult DeletingProduct(MallOfElectronics.Models.DataBase.Product product)
        {
            ProductsRepository productRepository = new ProductsRepository();

            if (productRepository.Delete(product.Id))
            {
                ViewBag.message = "This Product Has Been Deleted";
            }
            else
            {
                ViewBag.ErrorMessage = "This Product Not Has Been Deleted";
            }
            return(View());
        }
        public ActionResult AddingProduct(MallOfElectronics.Models.DataBase.Product product, HttpPostedFileBase UploadImage)
        {
            if (ModelState.IsValid)
            {
                string physicalPath = "", ImageName = "Images/ProductsImages/";
                if (UploadImage != null)
                {
                    physicalPath = Server.MapPath("~") + "Images\\ProductsImages\\" + UploadImage.FileName;
                    UploadImage.SaveAs(physicalPath);
                    ImageName += UploadImage.FileName;
                }
                else
                {
                    ImageName += "EmptyProductsImage.jpg";
                }
                product.Image = ImageName;

                ProductsRepository productRepository = new ProductsRepository();
                if (productRepository.Add(product))
                {
                    ViewBag.Message = "This Product Has Been Added";
                }
                else
                {
                    if (UploadImage != null)
                    {
                        System.IO.File.Delete(physicalPath);
                    }
                    ViewBag.ErrorMessage = "This Product Not Has Been Added";
                }
            }
            else
            {
                ViewBag.ErrorMessage = "This Product Not Has Been Added";
            }
            return(View());
        }
        public ActionResult EditingProduct(MallOfElectronics.Models.DataBase.Product product)
        {
            MallOfElectronics.Models.DataBase.Product previousProduct =
                (MallOfElectronics.Models.DataBase.Product)TempData["prviousProduct"];
            ProductsRepository    productRepository = new ProductsRepository();
            CheckEqualForProducts check             = new CheckEqualForProducts();

            if (!check.IsEqual(previousProduct, product))
            {
                if (productRepository.update(product))
                {
                    ViewBag.message = "This Product Has Been Updated";
                }
                else
                {
                    ViewBag.ErrorMessage = "Not Item Of Product To Change";
                }
            }
            else
            {
                ViewBag.ErrorMessage = "This Product Not Has Been Updated";
            }
            return(View());
        }