public void Init()
 {
     _productServiceMock     = new Mock <IProductService>();
     _httpContextAccessor    = new Mock <IHttpContextAccessor>();
     _settings               = new CatalogSettings();
     _compareProductsService = new CompareProductsService(_httpContextAccessor.Object, _productServiceMock.Object, _settings);
     _mockProducts           = new List <Product>
     {
         new Product()
         {
             Id = "1", Published = true
         },
         new Product()
         {
             Id = "2", Published = true
         },
         new Product()
         {
             Id = "3", Published = true
         },
         new Product()
         {
             Id = "4", Published = true
         },
         new Product()
         {
             Id = "5", Published = true
         }
     };
 }
Esempio n. 2
0
        // GET: Product/Compare
        public ActionResult Compare(ProductSearchModel model)
        {
            log.Info("Request Compare");

            ProductCompareModel compareModel = new ProductCompareModel();

            if (compareProductsIdentifiers.Count != 0)
            {
                CompareProductsService service = new CompareProductsService();

                try
                {
                    ProductIdentifierDataContract[] products = compareProductsIdentifiers.ToArray();

                    ProductsDataContract[] response = service.CompareProducts(products);

                    foreach (ProductsDataContract product in response)
                    {
                        compareModel.ProductsList.Add(new ProductsDataContract()
                        {
                            ProductId   = product.ProductId,
                            VendorId    = product.VendorId,
                            VendorName  = product.VendorName,
                            Name        = product.Name,
                            Description = product.Description,
                            Category    = product.Category,
                            Other_Info  = product.Other_Info,
                            Price       = product.Price,
                            Quantity    = product.Quantity
                        });
                    }
                }
                catch (Exception exc)
                {
                    log.Error("Request Compare", exc);
                }
                finally
                {
                    service.Dispose();
                }
            }

            compareProductsIdentifiers.Clear();
            return(View("Compare", compareModel));
        }