//Filtri e premere CERCA
        public async Task InsertProduct()
        {
            // Arrange
            UserBL userBL = new UserBL();

            userBL.SetGoogleCedential();
            Models.Product wProdotto = new Models.Product();
            wProdotto.Category    = "Uomo";
            wProdotto.Brand       = "armani";
            wProdotto.ProductName = "Pantalone";
            wProdotto.Color       = "Bianco";
            wProdotto.Description = "pantalone bello";
            wProdotto.Headmoney   = "L";
            wProdotto.Price       = 60.00;
            wProdotto.Quantity    = 30;
            wProdotto.Model       = "Pantalone";
            wProdotto.Image       = @"C:\Users\feder\Desktop\Ingegneria del Software\pantalone bianco.png";
            ProductBL wDB = new ProductBL();

            await wDB.InsertProduct(ProductEntityToProductModel.ConvertoProdyctEntityTOProductModel(wProdotto), "");

            Models.SearchProduct wFilter = new Models.SearchProduct();
            wFilter.ProductName = "pantalone";

            List <Product> wListProduct = ProductEntityToProductModel.ConvertoListProdyctEntityTOListProductModel(await wDB.GetListProducts(ProductEntityToProductModel.ConvertoProdyctEntityTOSearchProductModel(wFilter)));


            Assert.IsTrue(wListProduct.Count > 0);
        }
        public async Task <ActionResult> Create(Product collection, HttpPostedFileBase pFile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here
                    ProductBL wDB        = new ProductBL();
                    var       appSetting = ConfigurationManager.AppSettings;
                    string    pathImage  = appSetting["PathImage"];
                    collection.Image = pathImage + collection.ImageFile.FileName;
                    collection.ImageFile.SaveAs(collection.Image);
                    await wDB.InsertProduct(ProductEntityToProductModel.ConvertoProdyctEntityTOProductModel(collection), "");

                    return(RedirectToAction("Home"));
                }
                else
                {
                    collection.Brands      = CategoryEntityTOCategoryModel.ConvertoListCategoryEntityTOListCategoryModel(await new CategoryBL().GetCategory("marca"));
                    collection.Colors      = CategoryEntityTOCategoryModel.ConvertoListCategoryEntityTOListCategoryModel(await new CategoryBL().GetCategory("Colori"));
                    collection.Categories  = CategoryEntityTOCategoryModel.ConvertoListCategoryEntityTOListCategoryModel(await new CategoryBL().GetCategory("Categorie"));
                    collection.Headmoneies = CategoryEntityTOCategoryModel.ConvertoListCategoryEntityTOListCategoryModel(await new CategoryBL().GetCategory("Taglie"));
                    collection.Models      = CategoryEntityTOCategoryModel.ConvertoListCategoryEntityTOListCategoryModel(await new CategoryBL().GetCategory("Modelli"));

                    return(View(collection));
                }
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
        // GET: Product/Details/5
        public async Task <ActionResult> Detail(string pId, string pScript = "")
        {
            Product wProd = new Product();

            wProd = ProductEntityToProductModel.ConvertoProdyctModelTOProductEntity(await new ProductBL().GetProduct(pId));
            ViewBag.ScriptDetail = pScript;
            return(View("Detail", wProd));
        }
        //Non impostare filtri e premere CERCA
        public async Task Search()
        {
            // Arrange
            ProductController controller = new ProductController();
            UserBL            userBL     = new UserBL();

            userBL.SetGoogleCedential();
            ProductBL wDB = new ProductBL();

            List <Product> wListProduct = ProductEntityToProductModel.ConvertoListProdyctEntityTOListProductModel(await wDB.GetListProducts(ProductEntityToProductModel.ConvertoProdyctEntityTOSearchProductModel(new SearchProduct())));

            Assert.IsTrue(wListProduct.Count > 0);
        }
        //Filtro per Nome Prdotto e premere CERCA
        public async Task Search_7()
        {
            // Arrange
            UserBL userBL = new UserBL();

            userBL.SetGoogleCedential();
            Models.SearchProduct wFilter = new Models.SearchProduct();
            wFilter.ProductName = "polo";
            ProductBL wDB = new ProductBL();

            List <Product> wListProduct = ProductEntityToProductModel.ConvertoListProdyctEntityTOListProductModel(await wDB.GetListProducts(ProductEntityToProductModel.ConvertoProdyctEntityTOSearchProductModel(wFilter)));

            Assert.IsTrue(wListProduct.Count > 0);
        }
        //Filtri e premere CERCA
        public async Task Search_8()
        {
            // Arrange
            UserBL userBL = new UserBL();

            userBL.SetGoogleCedential();
            Models.SearchProduct wFilter = new Models.SearchProduct();
            wFilter.Category    = "Donna";
            wFilter.Brand       = "armani";
            wFilter.ProductName = "gonna";
            ProductBL wDB = new ProductBL();

            List <Product> wListProduct = ProductEntityToProductModel.ConvertoListProdyctEntityTOListProductModel(await wDB.GetListProducts(ProductEntityToProductModel.ConvertoProdyctEntityTOSearchProductModel(wFilter)));

            Assert.IsFalse(wListProduct.Count > 0);
        }
        public async Task <ActionResult> Search(SearchProduct collection)
        {
            try
            {
                // TODO: Add insert logic here
                ProductBL wDB = new ProductBL();

                List <Product> wListProduct = ProductEntityToProductModel.ConvertoListProdyctEntityTOListProductModel(await wDB.GetListProducts(ProductEntityToProductModel.ConvertoProdyctEntityTOSearchProductModel(collection)));
                TempData["ListProducts"] = wListProduct;

                return(RedirectToAction("Index", "Home", collection));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }