示例#1
0
 public HomeController()
 {
     this.productDAL  = new ProductDAL();
     productContainer = new ProductContainer(productDAL);
     //ILogger<HomeController> logger
     //_logger = logger;
 }
示例#2
0
 public void OnUpdateProductDetails(ProductContainer products)
 {
     PaymentManager.MyDebug.PushMessage(nameof(OnUpdateProductDetails));
     this.ProductOnStores.Clear();
     foreach (gu3.Payment.Product content in ((Allocator <MetaProduct, gu3.Payment.Product>)products).get_Contents())
     {
         if (!((string)content.id).Contains("bundle"))
         {
             this.ProductOnStores[(string)content.id] = content;
         }
     }
     if (this.ProductOnStores.Count > 0)
     {
         this.isSetupOK = true;
     }
     this.BundleOnStores.Clear();
     foreach (gu3.Payment.Product content in ((Allocator <MetaProduct, gu3.Payment.Product>)products).get_Contents())
     {
         if (((string)content.id).Contains("bundle"))
         {
             this.BundleOnStores[(string)content.id] = content;
         }
     }
     if (this.BundleOnStores.Count > 0)
     {
         this.isBundleSetupOK = true;
     }
     DebugUtility.LogWarning("PaymentManager:isSetupOK=>" + this.isSetupOK.ToString());
     DebugUtility.LogWarning("PaymentManager:isBundleSetupOK=>" + this.isBundleSetupOK.ToString());
 }
示例#3
0
        public List <Product> GetCurrentProductsList(ProductContainer conteiner, SortingMethods sortingMethod = SortingMethods.Rating, bool ascending = false)
        {
            List <Product> currentProductsList = new List <Product>();

            switch (conteiner)
            {
            case ProductContainer.Cart:
                throw new NotImplementedException("Currently not required");

            case ProductContainer.WishList:
                //to do: capture names to another list, or smth like this
                int count = CountProductsInContainer(ProductContainer.WishList);
                for (int i = 1; i <= count; i++)
                {
                    m_home.OpenWishlist();
                    SmallSleep();
                    Sort(sortingMethod, ascending);
                    SmallSleep();
                    currentProductsList.Add(new Product(ProductContainer.WishList, i, m_home, m_driver));
                }
                break;
            }

            return(currentProductsList);
        }
示例#4
0
        public int GetContainerCounter(ProductContainer container)
        {
            int count;

            switch (container)
            {
            case ProductContainer.Cart:
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='icons']//a/span"));
                if (confirmElements.Count == 0)
                {
                    return(0);
                }
                MidSleep();
                count = Int32.Parse(m_driver.FindElement(By.XPath("//div[@class='icons']//a/span")).Text);
                return(count);

            case ProductContainer.WishList:
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='icons']//button/span"));
                if (confirmElements.Count == 0)
                {
                    return(0);
                }
                MidSleep();
                count = Int32.Parse(m_driver.FindElement(By.XPath("//div[@class='icons']//button/span")).Text);
                return(count);

            default: return(0);
            }
        }
        public void ImportProductsService_ImportProduct_ShouldSetProductPrimaryProperties()
        {
            var product = new ProductImportDataTransferObject
            {
                UrlSegment = "test-url",
                Name = "Test Product",
                Abstract = "Test Abstract",
                Description = "Test Description",
                SEODescription = "Test SEO Description",
                SEOKeywords = "Test, Thought",
                SEOTitle = "Test SEO Title"
            };

            ProductContainer container = new ProductContainer().PersistTo(Session);
            A.CallTo(() => _uniquePageService.GetUniquePage<ProductContainer>()).Returns(container);
            MediaCategory category = new MediaCategory().PersistTo(Session);
            A.CallTo(() => _documentService.GetDocumentByUrl<MediaCategory>("product-galleries")).Returns(category);

            Product result = _importProductsService.ImportProduct(product);

            result.UrlSegment.ShouldBeEquivalentTo("test-url");
            result.Name.ShouldBeEquivalentTo("Test Product");
            result.ProductAbstract.ShouldBeEquivalentTo("Test Abstract");
            result.BodyContent.ShouldBeEquivalentTo("Test Description");
            result.MetaDescription.ShouldBeEquivalentTo("Test SEO Description");
            result.MetaKeywords.ShouldBeEquivalentTo("Test, Thought");
            result.MetaTitle.ShouldBeEquivalentTo("Test SEO Title");
        }
示例#6
0
        public void ImportProductsService_ImportProduct_ShouldSetProductPrimaryProperties()
        {
            var product = new ProductImportDataTransferObject
            {
                UrlSegment     = "test-url",
                Name           = "Test Product",
                Abstract       = "Test Abstract",
                Description    = "Test Description",
                SEODescription = "Test SEO Description",
                SEOKeywords    = "Test, Thought",
                SEOTitle       = "Test SEO Title"
            };

            ProductContainer container = new ProductContainer().PersistTo(Session);

            A.CallTo(() => _uniquePageService.GetUniquePage <ProductContainer>()).Returns(container);
            MediaCategory category = new MediaCategory().PersistTo(Session);

            A.CallTo(() => _documentService.GetDocumentByUrl <MediaCategory>("product-galleries")).Returns(category);

            Product result = _importProductsService.ImportProduct(product);

            result.UrlSegment.ShouldBeEquivalentTo("test-url");
            result.Name.ShouldBeEquivalentTo("Test Product");
            result.ProductAbstract.ShouldBeEquivalentTo("Test Abstract");
            result.BodyContent.ShouldBeEquivalentTo("Test Description");
            result.MetaDescription.ShouldBeEquivalentTo("Test SEO Description");
            result.MetaKeywords.ShouldBeEquivalentTo("Test, Thought");
            result.MetaTitle.ShouldBeEquivalentTo("Test SEO Title");
        }
示例#7
0
        public int CountProductsInContainer(ProductContainer container)
        {
            switch (container)
            {
            case ProductContainer.Cart:
                m_home.OpenCart();
                MidSleep();
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='empty-cart ng-star-inserted']"));
                if (confirmElements.Count != 0)
                {
                    return(0);
                }
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='cart-holder ng-star-inserted']//div[@class='cart-item ng-star-inserted']"));
                return(confirmElements.Count);

            case ProductContainer.WishList:
                m_home.OpenWishlist();
                MidSleep();
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='no-wishlist-box ng-star-inserted']"));
                if (confirmElements.Count != 0)
                {
                    return(0);
                }
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='ng-star-inserted']//div[@class='row product-list']/div"));
                return(confirmElements.Count);

            default: return(0);
            }
        }
        public void ProductContainerController_Show_ReturnsRedirectToProductSearch()
        {
            var categoryContainer = new ProductContainer();
            var redirectResult = new RedirectResult("~/search");
            A.CallTo(() => _uniquePageService.RedirectTo<ProductSearch>(null)).Returns(redirectResult);

            RedirectResult show = _controller.Show(categoryContainer);

            show.Should().Be(redirectResult);
        }
示例#9
0
        public void ProductContainerController_Show_ReturnsRedirectToProductSearch()
        {
            var categoryContainer = new ProductContainer();
            var redirectResult    = new RedirectResult("~/search");

            A.CallTo(() => _uniquePageService.RedirectTo <ProductSearch>(null)).Returns(redirectResult);

            RedirectResult show = _controller.Show(categoryContainer);

            show.Should().Be(redirectResult);
        }
示例#10
0
        public void Timing_equals_and_get_hash_code_containing_struct()
        {
            var clone             = new ProductContainer(new ProductInfo("Test", 44));
            var oneFieldDifferent = new ProductContainer(new ProductInfo("Test", 64));

            Do((i) =>
            {
                var res =
                    clone == oneFieldDifferent &&
                    clone.GetHashCode() == oneFieldDifferent.GetHashCode();
            });
        }
示例#11
0
        public static List <ProductViewModel> AllProductViewModels()
        {
            ProductContainer productContainer = new ProductContainer();

            List <ProductViewModel> productViews = new List <ProductViewModel>();

            foreach (Product product in productContainer.GetAll())
            {
                productViews.Add(ProductViewModel(product));
            }
            return(productViews);
        }
示例#12
0
        public void Check_Get_AllProducts_In_Container()
        {
            //Arrange
            var productDALStub   = new ProductDALStub();
            var productContainer = new ProductContainer(productDALStub);

            productDALStub.ExistReturnValue = false;

            //Act
            productContainer.AllProducts();

            //Assert
            Assert.True(productDALStub.ExistReturnValue);
        }
示例#13
0
        private void GetProductFromContainer(ProductContainer container, int productNumber, HomePage home)
        {
            switch (container)
            {
            case ProductContainer.Cart:
                throw new NotImplementedException("Currently not required to get proucts from cart");

            case ProductContainer.WishList:
                home.OpenWishlist();
                Thread.Sleep(2000);
                CaptureProductProperties(productNumber);
                break;
            }
        }
示例#14
0
        public void Check_If_Get_List()
        {
            //Arrange
            var            productDALStub   = new ProductDALStub();
            var            productContainer = new ProductContainer(productDALStub);
            List <Product> products         = new List <Product>();

            productDALStub.ExistReturnValue = false;

            //Act
            var productList = productContainer.GetList();

            //Assert
            Assert.Equal(products, productList);
        }
示例#15
0
        public ActionResult SaveMAsterDishes(string data)
        {
            // string j = @"{""data"":[{""masterProdId"":""14"",""sNo"":""1"",""childProdIds"":[""15"",""16""]},{""masterProdId"":""17"",""sNo"":""2"",""childProdIds"":[""18"",""19""]},{""masterProdId"":""14"",""sNo"":""1"",""childProdIds"":[""15"",""16""]}]}";
            ProductContainer pro = new ProductContainer(data);


            foreach (var iter in pro.lstProdMapRow)
            {
                int tempID = Convert.ToInt32(iter.masterProdId);
                var prod   = db.Products.First(i => i.Id == tempID);
                prod.Sno             = Convert.ToInt32(iter.sNo);
                prod.MasterProductID = null;
                for (int incre = 0; incre < iter.childProdIds.Length; incre++)
                {
                    int childId   = Convert.ToInt32(iter.childProdIds.GetValue(incre).ToString());
                    var childProd = db.Products.First(j => j.Id == childId);
                    childProd.Sno             = Convert.ToInt32(incre + 1);
                    childProd.MasterProductID = Convert.ToInt32(iter.masterProdId);
                    db.Entry(childProd).State = EntityState.Modified;
                }
                db.Entry(prod).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException ex) {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();

                    foreach (var failure in ex.EntityValidationErrors)
                    {
                        sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                        foreach (var error in failure.ValidationErrors)
                        {
                            sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                            sb.AppendLine();
                        }
                    }

                    //throw new System.Data.Entity.Validation.DbEntityValidationException(
                    //    "Entity Validation Failed - errors follow:\n" +
                    //    sb.ToString(), ex
                    //); // Add the original exception as the innerException
                    LogAdapter.Info(sb.ToString(), "aa", "bb");
                }
            }

            return(Json(new { message = "Successfully Saved the Dishes Order" }, JsonRequestBehavior.AllowGet));;
        }
示例#16
0
        public void AddProdutRangeToContainer(int[] productIds, ProductContainer container, ProductCategories category)
        {
            switch (container)
            {
            case ProductContainer.Cart:
                for (int i = 0; i < productIds.Length; i++)
                {
                    AddProductToContainer(ProductContainer.Cart, InterctionControlSet.Product_Details, new Product(category, productIds[i], m_driver));
                }
                break;

            case ProductContainer.WishList:
                for (int i = 0; i < productIds.Length; i++)
                {
                    AddProductToContainer(ProductContainer.WishList, InterctionControlSet.Product_Details, new Product(category, productIds[i], m_driver));
                }
                break;
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            AddDataToDb();

            var products = _db.Computers.ToArray();

            ProductContainer.SetData(products,
                                     new ProductList.ProductDataConverter(p =>
            {
                var computer = (Computer)p;
                return(new ProductList.Product
                {
                    Name = computer.Name,
                    Description = computer.Description,
                    Price = computer.Price
                });
            }
                                                                          ));
        }
示例#18
0
        void MakePaymentPressed()
        {
            // We'll send the product as a dictionary, and convert it to a `Product`
            // value in our app delegate.
            var product = new ProductContainer {
                Name        = "Example Charge",
                Description = "An example charge made by a WatchKit Extension",
                Price       = "14.99"
            };

            // Create our activity handoff type (registered in the iOS app's Info.plist).
            var activityType = AppConfiguration.UserActivity.Payment;

            // Use Handoff to route the wearer to the payment controller on phone
            var userInfo = new NSDictionary("product", product.Dictionary);

            UpdateUserActivity(activityType, userInfo, null);

            // Tell the user to use handoff to pay.
            StatusLabel.SetText("Use handoff to pay!");
        }
示例#19
0
        public int CountProductsInContainer(ProductContainer container, Product product)
        {
            int count;

            switch (container)
            {
            case ProductContainer.Cart:
                m_home.OpenCart();
                MidSleep();
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='empty-cart ng-star-inserted']"));
                if (confirmElements.Count != 0)
                {
                    return(0);
                }
                confirmElements = m_driver.FindElements(By.XPath("//a[text() = '" + product.ProductName + "']//parent::div"));
                count           = (confirmElements.Count == 0) ? 0 : 1;
                if (count == 1)
                {
                    count = Int32.Parse(m_driver.FindElement(By.XPath("//div[@class='cart-holder ng-star-inserted']//div[@class='cart-item ng-star-inserted']//span[@class='ng-value-label ng-star-inserted']")).Text);
                    return(count);
                }
                return(count);

            case ProductContainer.WishList:
                m_home.OpenWishlist();
                MidSleep();
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='no-wishlist-box ng-star-inserted']"));
                if (confirmElements.Count != 0)
                {
                    return(0);
                }
                confirmElements = m_driver.FindElements(By.XPath("//div[@class='row product-list']/div//div[@class='description']/div[text()='" + product.ProductName + "']"));
                SmallSleep();
                count = (confirmElements.Count == 0) ? 0 : 1;
                return(count);

            default: return(0);
            }
        }
示例#20
0
        public void Check_if_list_is_cleared()
        {
            //Arrange
            var            productDALStub   = new ProductDALStub();
            var            productContainer = new ProductContainer(productDALStub);
            List <Product> products         = new List <Product>();
            Product        product          = new Product();

            //Act
            products.Add(product);
            products.Add(product);
            products.Add(product);

            var list = productContainer.GetList();

            productContainer.ClearList();
            //Assert
            var result   = list.Count();
            var expected = 0;

            Assert.Equal(expected, result);
        }
示例#21
0
        public ProductContainer GetProductsByCategory(string category)
        {
            ProductContainer product = new ProductContainer(

                );

            product.Product.AddRange(_context.Product.ToList()
                                     .Where(t => t.Category == category))
            ;

            product.Size.AddRange(_context.Product.ToList().Where(c => c.Category == category)
                                  .Select(p => p.Size).Distinct());

            product.Brand.AddRange(_context.Product.ToList().Where(c => c.Category == category)
                                   .Select(p => p.Brand).Distinct());

            product.Category.AddRange(_context.Product.ToList().Where(c => c.Category == category)
                                      .Select(p => p.SubCategory).Distinct());


            return(product);
        }
        public void TestVoedingsWaardes()
        {
            //Arrange
            GebruikerContainer gebruikerContainer = new GebruikerContainer();
            UitkomstContainer  uitkomstContainer  = new UitkomstContainer();
            ProductContainer   productContainer   = new ProductContainer();
            InvoerContainer    invoerContainer    = new InvoerContainer();

            BerekenController berekenController = new BerekenController(gebruikerContainer, uitkomstContainer, productContainer, invoerContainer);

            DateTime date = new DateTime(2002, 9, 1);

            gebruikerContainer.AddGebruiker(1, 65, 190, date.Date, 2, true, false);

            //Act
            berekenController.Bereken();

            //Assert
            Assert.IsTrue(uitkomstContainer.UitkomstList[0].maximaleCalorieën < 2500 && uitkomstContainer.UitkomstList[0].maximaleCalorieën > 1500);
            Assert.IsTrue(uitkomstContainer.UitkomstList[0].minimaleCalorieën < 2500 && uitkomstContainer.UitkomstList[0].minimaleCalorieën > 1500);

            Assert.IsTrue(uitkomstContainer.UitkomstList[0].maximaleTotaleVetten < 150 && uitkomstContainer.UitkomstList[0].maximaleTotaleVetten > 20);
            Assert.IsTrue(uitkomstContainer.UitkomstList[0].minimaleTotaleVetten < 150 && uitkomstContainer.UitkomstList[0].minimaleTotaleVetten > 20);

            Assert.IsTrue(uitkomstContainer.UitkomstList[0].maximaleVerzadigdeVetten < 100 && uitkomstContainer.UitkomstList[0].maximaleVerzadigdeVetten > 0);

            Assert.IsTrue(uitkomstContainer.UitkomstList[0].maximaleKoolhydraten < 500 && uitkomstContainer.UitkomstList[0].maximaleKoolhydraten > 150);
            Assert.IsTrue(uitkomstContainer.UitkomstList[0].minimaleKoolhydraten < 500 && uitkomstContainer.UitkomstList[0].minimaleKoolhydraten > 150);

            Assert.IsTrue(uitkomstContainer.UitkomstList[0].maximaleSuikers < 150 && uitkomstContainer.UitkomstList[0].maximaleSuikers > 0);

            Assert.IsTrue(uitkomstContainer.UitkomstList[0].maximaleEiwitten < 300 && uitkomstContainer.UitkomstList[0].maximaleEiwitten > 0);
            Assert.IsTrue(uitkomstContainer.UitkomstList[0].minimaleEiwitten < 300 && uitkomstContainer.UitkomstList[0].minimaleEiwitten > 0);

            Assert.IsTrue(uitkomstContainer.UitkomstList[0].maximaleZouten < 9 && uitkomstContainer.UitkomstList[0].maximaleZouten > 0);
            Assert.IsTrue(uitkomstContainer.UitkomstList[0].minimaleZouten < 9 && uitkomstContainer.UitkomstList[0].minimaleZouten > 0);
        }
示例#23
0
        public void SaveProductsInList()
        {
            if (table.Rows.Count > 0)
            {
                Product          product;
                ProductContainer productcontainer = new ProductContainer(new ProductDAL());
                List <Product>   productslist     = productcontainer.GetList();

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    var dr = table.Rows[i];
                    product = new Product()
                    {
                        id           = Convert.ToInt32(dr["ID"]),
                        productNaam  = dr["Name"].ToString(),
                        prijs        = Convert.ToDouble(dr["Prize"]),
                        omschrijving = dr["Description"].ToString(),
                        tag          = dr["Tag"].ToString()
                    };
                    productslist.Add(product);
                }
                ClearTable();
            }
        }
示例#24
0
        public void AddProductToContainer(ProductContainer container, InterctionControlSet controlSet, Product product)
        {
            switch (container)
            {
            case ProductContainer.Cart:
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    throw new NotSupportedException();

                case InterctionControlSet.From_container:
                    m_home.OpenCart();
                    MidSleep();
                    int count = CountProductsInContainer(ProductContainer.Cart, product);
                    if (count > 0)
                    {
                        m_driver.FindElement(By.XPath("//div[@class='cart-item ng-star-inserted']//span[@class='ng-arrow-wrapper'"));
                        SmallSleep();
                        TestHelper.JSexecutorClick(m_driver.FindElement(By.XPath("//*[@placeholder='Quantity']/ng-dropdown-panel//div[@role='option']/span[text()='" + (count++) + "']")), m_driver);
                        MidSleep();
                        break;
                    }
                    else
                    {
                        throw new NotSupportedException("Adding new product from cart is not supported");
                    }

                case InterctionControlSet.Product_Details:
                    var blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    blackFridayControl.Click();
                    Thread.Sleep(2000);
                    var categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    //TestHelper.JSexecutorClick(categoryControl, m_driver);
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='product-card-container']//div[@class='description']//div[text()='" +
                                                                product.ProductName + "']//parent::div"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//button[text()='add to cart']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='modal-content']//button[text()=' view cart ']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    m_home.OpenWishlist();
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='description']//div[text()='" +
                                                            product.ProductName + "']/ancestor::div[@class='product-card-container']//button/span[text()='Add to cart']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    MidSleep();
                    break;

                default: break;
                }
                break;

            case ProductContainer.WishList:
                SmallSleep();
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    //TestHelper.JSexecutorClick(product.categoryControl, m_driver);
                    var blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    var categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    TestHelper.JSexecutorClick(m_driver.FindElement(By.XPath("//div[@class='description']//div[text()='" +
                                                                             product.ProductName + "']/ancestor::div[@class='product-card-container']//button[text()='Add to Wishlist']")), m_driver);
                    break;

                case InterctionControlSet.From_container:
                    throw new NotSupportedException("Adding product from wishlist to wishlist is not supported");

                case InterctionControlSet.Product_Details:
                    //product.categoryControl.Click();
                    blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='row product-list']//div[@class='product-card-container']//div[@class='description']/div[text()='" +
                                                                product.ProductName + "']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='wishlist-placeholder ng-star-inserted']//button/span[text()='Add to wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    m_home.OpenCart();
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='cart-item ng-star-inserted']//button[text()='Move to wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    break;

                default: break;
                }
                break;

            default: break;
            }
        }
 public RedirectResult Show(ProductContainer page)
 {
     return(_uniquePageService.RedirectTo <ProductSearch>());
 }
        private Orders ParseData(string[] headers, CsvReader csv, int fieldCount)
        {
            var order              = new Orders();
            var customer           = new Customer();
            var product            = new Product();
            var province           = new Province();
            var region             = new Region();
            var segment            = new Segment();
            var productCategory    = new ProductCategory();
            var productSubCategory = new ProductSubCategory();
            var productContainer   = new ProductContainer();

            for (int i = 0; i < fieldCount; i++)
            {
                try
                {
                    switch (headers[i])
                    {
                    case "Row ID":
                        break;

                    case "Order ID":
                        order.OrdersID = Int32.Parse(csv[i]);
                        break;

                    case "Order Date":
                        order.OrderDate = DateTime.Parse(csv[i]);
                        break;

                    case "Order Priority":
                        var orderPriority = this._context.OrderPriorities.Where(x => x.Name.Equals(csv[i])).FirstOrDefault <OrderPriority>();
                        if (orderPriority != null)
                        {
                            order.OrderPriorityID = orderPriority.ID;
                        }
                        else
                        {
                            order.OrderPriority = new OrderPriority {
                                Name = csv[i]
                            };
                        }
                        break;

                    case "Order Quantity":
                        order.OrderQuantity = Double.Parse(csv[i]);
                        break;

                    case "Sales":
                        order.Sales = Double.Parse(csv[i]);
                        break;

                    case "Discount":
                        order.Discount = Double.Parse(csv[i]);
                        break;

                    case "Ship Mode":
                        var shipMode = this._context.ShipModes.Where(x => x.Name.Equals(csv[i])).FirstOrDefault <ShipMode>();
                        if (shipMode != null)
                        {
                            order.ShipModeID = shipMode.ID;
                        }
                        else
                        {
                            order.ShipMode = new ShipMode()
                            {
                                Name = csv[i]
                            };
                        }
                        break;

                    case "Profit":
                        order.Profit = Double.Parse(csv[i]);
                        break;

                    case "Unit Price":
                        product.UnitPrice = Double.Parse(csv[i]);
                        break;

                    case "Shipping Cost":
                        order.ShippingCost = Double.Parse(csv[i]);
                        break;

                    case "Customer Name":
                        customer.Name = csv[i];
                        break;

                    case "Province":
                        province.Name = csv[i];
                        break;

                    case "Region":
                        region.Name = csv[i];
                        break;

                    case "Customer Segment":
                        segment.Name = csv[i];
                        break;

                    case "Product Category":
                        productCategory.Name = csv[i];
                        break;

                    case "Product Sub-Category":
                        productSubCategory.Name = csv[i];
                        break;

                    case "Product Name":
                        product.Name = csv[i];
                        break;

                    case "Product Container":
                        productContainer.Name = csv[i];
                        break;

                    case "Product Base Margin":
                        product.BaseMargin = Double.Parse(csv[i]);
                        break;

                    case "Ship Date":
                        order.ShipDate = DateTime.Parse(csv[i]);
                        break;
                    }
                }catch (Exception ex) {
                    this._logger.LogWarning(string.Format("{0} - {1}", ex.Message, csv[i]));
                }
            }

            var productCategoryVal = this._context.ProductCategories.Where(x => x.Name.Equals(productCategory.Name)).FirstOrDefault <ProductCategory>();

            if (productCategoryVal != null)
            {
                productSubCategory.ProductCategoryID = productCategoryVal.ID;
            }
            else
            {
                productSubCategory.ProductCategory = productCategory;
            }

            var productSubCategoryVal = this._context.ProductSubCategories.Where(x => x.Name.Equals(productSubCategory.Name)).FirstOrDefault <ProductSubCategory>();

            if (productSubCategoryVal != null)
            {
                product.ProductSubcategoryID = productSubCategoryVal.ID;
            }
            else
            {
                product.ProductSubCategory = productSubCategory;
            }

            var productContainerVal = this._context.ProductContainers.Where(x => x.Name.Equals(productContainer.Name)).FirstOrDefault <ProductContainer>();

            if (productContainerVal != null)
            {
                product.ProductContainerID = productContainerVal.ID;
            }
            else
            {
                product.ProductContainer = productContainer;
            }

            var provinceVal = this._context.Provinces.Where(x => x.Name.Equals(province.Name)).FirstOrDefault <Province>();

            if (provinceVal != null)
            {
                region.ProvinceID = provinceVal.ID;
            }
            else
            {
                region.Province = province;
            }

            var segmentVal = this._context.Segments.Where(x => x.Name.Equals(segment.Name)).FirstOrDefault <Segment>();

            if (segmentVal != null)
            {
                customer.SegmentID = segmentVal.ID;
            }
            else
            {
                customer.Segment = segment;
            }

            var regionVal = this._context.Regions.Where(x => x.Name.Equals(segment.Name)).FirstOrDefault <Region>();

            if (regionVal != null)
            {
                customer.RegionID = regionVal.ID;
            }
            else
            {
                customer.Region = region;
            }

            var customerVal = this._context.Customers.Where(x => x.Name.Equals(customer.Name)).FirstOrDefault <Customer>();

            if (customerVal != null)
            {
                order.CustomerID = customerVal.ID;
            }
            else
            {
                order.Customer = customer;
            }

            var productVal = this._context.Products.Where(x => x.Name.Equals(product.Name)).FirstOrDefault <Product>();

            if (productVal != null)
            {
                order.ProductID = productVal.ID;
            }
            else
            {
                order.Product = product;
            }

            return(order);
        }
示例#27
0
        public PageModel Setup(MediaModel mediaModel)
        {
            var pageModel = new PageModel();

            var productSearch = new ProductSearch
            {
                Name               = "Categories",
                UrlSegment         = "categories",
                RevealInNavigation = true
            };
            var categoryContainer = new ProductContainer
            {
                Name               = "Products",
                UrlSegment         = "products",
                RevealInNavigation = false
            };

            _webpageAdminService.Add(productSearch);
            _webpageAdminService.PublishNow(productSearch);
            _webpageAdminService.Add(categoryContainer);
            _webpageAdminService.PublishNow(categoryContainer);
            pageModel.ProductSearch = productSearch;

            var now        = DateTime.UtcNow;
            var yourBasket = new Cart
            {
                Name               = "Your Basket",
                UrlSegment         = "basket",
                RevealInNavigation = false,
                PublishOn          = now
            };

            _webpageAdminService.Add(yourBasket);
            var enterOrderEmail = new EnterOrderEmail
            {
                Name               = "Enter Order Email",
                UrlSegment         = "enter-order-email",
                RevealInNavigation = false,
                Parent             = yourBasket,
                DisplayOrder       = 0,
                PublishOn          = now,
            };

            _webpageAdminService.Add(enterOrderEmail);
            var setPaymentDetails = new PaymentDetails
            {
                Name               = "Set Payment Details",
                UrlSegment         = "set-payment-details",
                RevealInNavigation = false,
                Parent             = yourBasket,
                DisplayOrder       = 1,
                PublishOn          = now,
            };

            _webpageAdminService.Add(setPaymentDetails);
            var setDeliveryDetails = new SetShippingDetails
            {
                Name               = "Set Shipping Details",
                UrlSegment         = "set-shipping-details",
                RevealInNavigation = false,
                Parent             = yourBasket,
                DisplayOrder       = 2,
                PublishOn          = now,
            };

            _webpageAdminService.Add(setDeliveryDetails);
            var orderPlaced = new OrderPlaced
            {
                Name               = "Order Placed",
                UrlSegment         = "order-placed",
                RevealInNavigation = false,
                Parent             = yourBasket,
                DisplayOrder       = 3,
                PublishOn          = now,
            };

            _webpageAdminService.Add(orderPlaced);

            // User Account
            var userAccount = new SitemapPlaceholder
            {
                Name               = "User Account",
                UrlSegment         = "user-account",
                RevealInNavigation = false,
                PublishOn          = now
            };

            _webpageAdminService.Add(userAccount);

            var userAccountInfo = new UserAccountInfo
            {
                Name               = "Account Details",
                UrlSegment         = "user-account-details",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccount
            };

            _webpageAdminService.Add(userAccountInfo);

            var userAccountPassword = new UserAccountChangePassword
            {
                Name               = "Change Password",
                UrlSegment         = "user-account-change-password",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccount
            };

            _webpageAdminService.Add(userAccountPassword);

            var userAccountAddresses = new UserAccountAddresses
            {
                Name               = "Account Addresses",
                UrlSegment         = "user-account-addresses",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccount
            };

            _webpageAdminService.Add(userAccountAddresses);

            var editAddress = new UserAccountEditAddress
            {
                Name               = "Edit Address",
                UrlSegment         = userAccountAddresses.UrlSegment + "/edit-address",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccountAddresses
            };

            _webpageAdminService.Add(editAddress);

            var userAccountOrders = new UserAccountOrders
            {
                Name               = "Orders",
                UrlSegment         = "user-account-orders",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccount
            };

            _webpageAdminService.Add(userAccountOrders);

            var userOrder = new UserOrder
            {
                Name               = "View Order",
                UrlSegment         = "user-account-orders/order",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccountOrders
            };

            _webpageAdminService.Add(userOrder);

            var userAccountReviews = new UserAccountReviews
            {
                Name               = "Reviews",
                UrlSegment         = "user-account-reviews",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccount
            };

            _webpageAdminService.Add(userAccountReviews);

            var userAccountRewards = new UserAccountRewardPoints
            {
                Name               = "Reward Points",
                UrlSegment         = "user-account-reward-points",
                RevealInNavigation = false,
                PublishOn          = now,
                Parent             = userAccount
            };

            _webpageAdminService.Add(userAccountRewards);

            // End User Account


            //Added to cart
            var addedToCart = new ProductAddedToCart
            {
                Name               = "Added to Basket",
                UrlSegment         = "add-to-basket",
                RevealInNavigation = false,
                PublishOn          = now
            };

            _webpageAdminService.Add(addedToCart);
            pageModel.ProductAddedToCart = addedToCart;

            var wishlist = new ShowWishlist
            {
                Name               = "Wishlist",
                UrlSegment         = "wishlist",
                RevealInNavigation = true,
                PublishOn          = now
            };

            _webpageAdminService.Add(wishlist);

            var newIn = new NewInProducts
            {
                Name               = "New In",
                UrlSegment         = "new-in",
                RevealInNavigation = true,
                PublishOn          = now
            };

            _webpageAdminService.Add(newIn);

            var about = new TextPage()
            {
                Name               = "About us",
                UrlSegment         = "about-us",
                RevealInNavigation = true,
                PublishOn          = now,
                BodyContent        = EcommerceInstallInfo.AboutUsText
            };

            _webpageAdminService.Add(about);

            //update core pages
            var homePage = _getByUrl.GetByUrl("home");

            if (homePage != null)
            {
                homePage.BodyContent = EcommerceInstallInfo.HomeCopy;
                var templates    = _pageTemplateAdminService.Search(new PageTemplateSearchQuery());
                var homeTemplate = templates.FirstOrDefault(x => x.Name == "Home Page");
                if (homeTemplate != null)
                {
                    homePage.PageTemplate = homeTemplate;
                }

                homePage.SubmitButtonText = "Sign up";
                _webpageAdminService.Update(homePage);
                pageModel.HomePage = homePage;
            }
            var page2 = _getByUrl.GetByUrl("page-2");

            if (page2 != null)//demopage in core not needed
            {
                _webpageAdminService.Delete(page2);
            }

            var contactus = _getByUrl.GetByUrl("contact-us");

            if (contactus != null)//demopage in core not needed
            {
                _webpageAdminService.Delete(contactus);
            }

            //Added to cart
            var contactUs = new ContactUs()
            {
                Name               = "Contact Us",
                UrlSegment         = "contact-us",
                RevealInNavigation = true,
                PublishOn          = now,
                Latitude           = 55.01021m,
                Longitude          = -1.44998m,
                Address            = EcommerceInstallInfo.Address,
                PinImage           = mediaModel.Logo.FileUrl,
                BodyContent        = "[form]",
                FormDesign         = EcommerceInstallInfo.ContactFormDesign
            };

            _webpageAdminService.Add(contactUs);
            GetFormProperties(contactUs);

            var brandListing = new BrandListing
            {
                Name               = "Brands",
                UrlSegment         = "brands",
                RevealInNavigation = true,
                PublishOn          = now,
                BodyContent        = ""
            };

            _webpageAdminService.Add(brandListing);

            return(pageModel);
        }
示例#28
0
        public void GoToProduct()
        {
            var product = new ProductContainer(DriverManager.Current.FindElements(Search.XPath("//div[@class='product-container']")).First());

            product.AddProductToCart();
        }
示例#29
0
        public PageModel Setup(MediaModel mediaModel)
        {
            var pageModel = new PageModel();

            var productSearch = new ProductSearch
            {
                Name = "Categories",
                UrlSegment = "categories",
                RevealInNavigation = true
            };
            var categoryContainer = new ProductContainer
            {
                Name = "Products",
                UrlSegment = "products",
                RevealInNavigation = false
            };
            _documentService.AddDocument(productSearch);
            _documentService.PublishNow(productSearch);
            _documentService.AddDocument(categoryContainer);
            _documentService.PublishNow(categoryContainer);
            pageModel.ProductSearch = productSearch;

            var now = DateTime.UtcNow;
            var yourBasket = new Cart
            {
                Name = "Your Basket",
                UrlSegment = "basket",
                RevealInNavigation = false,
                PublishOn = now
            };
            _documentService.AddDocument(yourBasket);
            var enterOrderEmail = new EnterOrderEmail
            {
                Name = "Enter Order Email",
                UrlSegment = "enter-order-email",
                RevealInNavigation = false,
                Parent = yourBasket,
                DisplayOrder = 0,
                PublishOn = now,
            };
            _documentService.AddDocument(enterOrderEmail);
            var setPaymentDetails = new PaymentDetails
            {
                Name = "Set Payment Details",
                UrlSegment = "set-payment-details",
                RevealInNavigation = false,
                Parent = yourBasket,
                DisplayOrder = 1,
                PublishOn = now,
            };
            _documentService.AddDocument(setPaymentDetails);
            var setDeliveryDetails = new SetShippingDetails
            {
                Name = "Set Shipping Details",
                UrlSegment = "set-shipping-details",
                RevealInNavigation = false,
                Parent = yourBasket,
                DisplayOrder = 2,
                PublishOn = now,
            };
            _documentService.AddDocument(setDeliveryDetails);
            var orderPlaced = new OrderPlaced
            {
                Name = "Order Placed",
                UrlSegment = "order-placed",
                RevealInNavigation = false,
                Parent = yourBasket,
                DisplayOrder = 3,
                PublishOn = now,
            };
            _documentService.AddDocument(orderPlaced);

            // User Account
            var userAccount = new SitemapPlaceholder
            {
                Name = "User Account",
                UrlSegment = "user-account",
                RevealInNavigation = false,
                PublishOn = now
            };
            _documentService.AddDocument(userAccount);

            var userAccountInfo = new UserAccountInfo
            {
                Name = "Account Details",
                UrlSegment = "user-account-details",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccount
            };
            _documentService.AddDocument(userAccountInfo);

            var userAccountPassword = new UserAccountChangePassword
            {
                Name = "Change Password",
                UrlSegment = "user-account-change-password",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccount
            };
            _documentService.AddDocument(userAccountPassword);

            var userAccountAddresses = new UserAccountAddresses
            {
                Name = "Account Addresses",
                UrlSegment = "user-account-addresses",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccount
            };
            _documentService.AddDocument(userAccountAddresses);

            var editAddress = new UserAccountEditAddress
            {
                Name = "Edit Address",
                UrlSegment = userAccountAddresses.UrlSegment + "/edit-address",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccountAddresses
            };
            _documentService.AddDocument(editAddress);

            var userAccountOrders = new UserAccountOrders
            {
                Name = "Orders",
                UrlSegment = "user-account-orders",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccount
            };
            _documentService.AddDocument(userAccountOrders);

            var userOrder = new UserOrder
            {
                Name = "View Order",
                UrlSegment = "user-account-orders/order",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccountOrders
            };
            _documentService.AddDocument(userOrder);

            var userAccountReviews = new UserAccountReviews
            {
                Name = "Reviews",
                UrlSegment = "user-account-reviews",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccount
            };
            _documentService.AddDocument(userAccountReviews);

            var userAccountRewards = new UserAccountRewardPoints
            {
                Name = "Reward Points",
                UrlSegment = "user-account-reward-points",
                RevealInNavigation = false,
                PublishOn = now,
                Parent = userAccount
            };
            _documentService.AddDocument(userAccountRewards);

            // End User Account


            //Added to cart
            var addedToCart = new ProductAddedToCart
            {
                Name = "Added to Basket",
                UrlSegment = "add-to-basket",
                RevealInNavigation = false,
                PublishOn = now
            };
            _documentService.AddDocument(addedToCart);
            pageModel.ProductAddedToCart = addedToCart;

            var wishlist = new ShowWishlist
            {
                Name = "Wishlist",
                UrlSegment = "wishlist",
                RevealInNavigation = true,
                PublishOn = now
            };
            _documentService.AddDocument(wishlist);

            var newIn = new NewInProducts
            {
                Name = "New In",
                UrlSegment = "new-in",
                RevealInNavigation = true,
                PublishOn = now
            };
            _documentService.AddDocument(newIn);

            var about = new TextPage()
            {
                Name = "About us",
                UrlSegment = "about-us",
                RevealInNavigation = true,
                PublishOn = now,
                BodyContent = EcommerceInstallInfo.AboutUsText
            };
            _documentService.AddDocument(about);

            //update core pages
            var homePage = _documentService.GetDocumentByUrl<TextPage>("home");
            if (homePage != null)
            {
                homePage.BodyContent = EcommerceInstallInfo.HomeCopy;
                var templates = _pageTemplateAdminService.Search(new PageTemplateSearchQuery());
                var homeTemplate = templates.FirstOrDefault(x => x.Name == "Home Page");
                if (homeTemplate != null)
                {
                    homePage.PageTemplate = homeTemplate;
                }

                homePage.SubmitButtonText = "Sign up";
                _documentService.SaveDocument(homePage);
                pageModel.HomePage = homePage;
            }
            var page2 = _documentService.GetDocumentByUrl<TextPage>("page-2");
            if (page2 != null)//demopage in core not needed
                _documentService.DeleteDocument(page2);

            var contactus = _documentService.GetDocumentByUrl<TextPage>("contact-us");
            if (contactus != null)//demopage in core not needed
                _documentService.DeleteDocument(contactus);

            //Added to cart
            var contactUs = new ContactUs()
            {
                Name = "Contact Us",
                UrlSegment = "contact-us",
                RevealInNavigation = true,
                PublishOn = now,
                Latitude = 55.01021m,
                Longitude = -1.44998m,
                Address = EcommerceInstallInfo.Address,
                PinImage = mediaModel.Logo.FileUrl,
                BodyContent = "[form]",
                FormDesign = EcommerceInstallInfo.ContactFormDesign
            };
            _documentService.AddDocument(contactUs);
            GetFormProperties(contactUs);

            var brandListing = new BrandListing
            {
                Name = "Brands",
                UrlSegment = "brands",
                RevealInNavigation = true,
                PublishOn = now,
                BodyContent = ""
            };
            _documentService.AddDocument(brandListing);

            return pageModel;
        }
示例#30
0
 private IQueryOver<Webpage, Webpage> GetParentQuery(ProductContainer uniquePage)
 {
     return _session.QueryOver<Webpage>().Where(webpage => webpage.Parent.Id == uniquePage.Id);
 }
示例#31
0
        public void RemoveProductFromContainer(ProductContainer container, InterctionControlSet controlSet, Product product)
        {
            switch (container)
            {
            case ProductContainer.Cart:
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    throw new NotSupportedException();

                case InterctionControlSet.Product_Details:
                    throw new NotSupportedException();

                case InterctionControlSet.From_container:
                    m_home.OpenCart();
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='cart-item-container row']//button[text()='Remove']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    throw new NotSupportedException("Product need to be removed, not moved to other ontainer");

                default: break;
                }
                break;

            case ProductContainer.WishList:
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    //product.categoryControl.Click();
                    var blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    var categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='description']//div[text()='" +
                                                                product.ProductName + "']/ancestor::div[@class='product-card-container']//button[text()='Remove from Wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Product_Details:
                    //product.categoryControl.Click();
                    blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='row product-list']//div[@class='product-card-container']//div[@class='description']/div[text()='" + product.ProductName + "']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='wishlist-placeholder ng-star-inserted']//button/span[text()='Remove from wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    throw new NotSupportedException("Product need to be removed, not moved to other ontainer");

                case InterctionControlSet.From_container:
                    m_home.OpenWishlist();
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='product-card-container']//div[@class='description']//div[text()='"
                                                            + product.ProductName + "']/ancestor::div[@class='product-card-container']//button[text()='Remove from Wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                default: break;
                }
                break;

            default: break;
            }
        }
示例#32
0
 private IQueryOver <Webpage, Webpage> GetParentQuery(ProductContainer uniquePage)
 {
     return(_session.QueryOver <Webpage>().Where(webpage => webpage.Parent.Id == uniquePage.Id));
 }
示例#33
0
 public Product(ProductContainer container, int productNumber, HomePage home, IWebDriver driverForRun)
 {
     m_driverForRun = driverForRun;
     GetProductFromContainer(container, productNumber, home);
 }
示例#34
0
 public HomeController()
 {
     productContainer = new ProductContainer(new ProductDAL());
 }