public void GetTotalPriceScenarioCTestMethod()
        {
            IDoumentProvider doumentProvider = new DocumentManager();
            List <Order>     orders          = new List <Order>();
            ProductsManager  productsManager = new ProductsManager(doumentProvider);

            var            products      = productsManager.GetProducts();
            List <Product> finalProducts = new List <Product>();

            finalProducts.Add(products.Where(s => s.Id == "A").FirstOrDefault());
            finalProducts.Add(products.Where(s => s.Id == "A").FirstOrDefault());
            finalProducts.Add(products.Where(s => s.Id == "A").FirstOrDefault());

            finalProducts.Add(products.Where(s => s.Id == "B").FirstOrDefault());
            finalProducts.Add(products.Where(s => s.Id == "B").FirstOrDefault());
            finalProducts.Add(products.Where(s => s.Id == "B").FirstOrDefault());
            finalProducts.Add(products.Where(s => s.Id == "B").FirstOrDefault());
            finalProducts.Add(products.Where(s => s.Id == "B").FirstOrDefault());

            finalProducts.Add(products.Where(s => s.Id == "C").FirstOrDefault());
            finalProducts.Add(products.Where(s => s.Id == "D").FirstOrDefault());
            Order orderOne = new Order();

            orderOne.OrderID  = 1;
            orderOne.Products = finalProducts;
            orders.Add(orderOne);

            PromotionManager      promotionsManager     = new PromotionManager(doumentProvider);
            PromotionEnginManager promotionEnginManager = new PromotionEnginManager();
            var promotions = promotionsManager.GetPromotions();
            var result     = promotionEnginManager.GetTotalPrice(orders, new List <Promotion>(promotions));

            Assert.IsNotNull(result);
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();

            var prodsMgr = new ProductsManager();
            var prods    = prodsMgr.GetProducts();

            productsTable.DataSource = prods;
        }
        public void GetProductsTestMethod()
        {
            using (ShimsContext.Create())
            {
                IDoumentProvider doumentProvider = new DocumentManager();
                ProductsManager  productsManager = new ProductsManager(doumentProvider);

                var result = productsManager.GetProducts();
                Assert.IsNotNull(result);
            }
        }
        public void TearDown()
        {
            ProductsManager productsManager = ProductsManager.GetManager();

            var productItem = productsManager.GetProducts()
                              .FirstOrDefault(p => p.Id == ProductsIntegrationTests.productItemId);

            if (productItem != null)
            {
                ProductsIntegrationTests.DeleteProduct(productItem, productsManager);
                ProductsIntegrationTests.DeleteImage();
            }
        }
Example #5
0
        public ActionResult Default(string returnUrl)
        {
            var model = (HomeViewModel)TempData["model"];

            if (model != null && model.CarProducts.Any())
            {
                return(View(model));
            }
            ViewBag.ReturnUrl = returnUrl;
            HomeViewModel viewModel = new HomeViewModel();

            viewModel.CarProducts = manager.GetProducts(Category.Cars);
            return(View(viewModel));
        }
        public ActionResult ProductsFilter(bool viewAll, int pageNr, string collection, string gender, string category, List <string> fit, List <string> size, List <string> color, string sort)
        {
            var model = new CatalogModel();

            this.BuildBreadcrumb(model.Selections.Breadcrumb, category, collection, gender == Constants.MEN_GENDER ? "Men" : "Women", gender);

            model.ProductList =
                ProductsManager.GetProducts(this.Session,
                                            new ProductListFilter()
            {
                Brand      = this.CurrentBrand,
                ViewAll    = viewAll,
                PageNumber = pageNr,
                Collection = model.Selections.Breadcrumb.Collection != null ? model.Selections.Breadcrumb.Collection.Name : null,
                Gender     = gender,
                Category   = model.Selections.Breadcrumb.Category != null ? model.Selections.Breadcrumb.Category.Name : null,
                Fit        = fit,
                Size       = size,
                Color      = color,
                Sort       = sort,
                IsNew      = model.Selections.Breadcrumb.IsCategoryForNewProds ? "true" : null
            });

            return(RenderMultipleViews(new List <RenderViewInfo>()
            {
                new RenderViewInfo()
                {
                    ViewName = "paginationView", ViewPath = "~/Views/Partials/Catalog/_PaginationPartial.cshtml", Model = model.ProductList.Pagination
                },
                new RenderViewInfo()
                {
                    ViewName = "groupsView", ViewPath = "~/Views/Partials/Catalog/_ProductGroupPartial.cshtml", Model = model
                },
                new RenderViewInfo()
                {
                    ViewName = "rowsView", ViewPath = "~/Views/Partials/Catalog/_ProductRowsPartial.cshtml", Model = model
                }
            }));
        }
        private ActionResult BuildCatalogHomeByFit(string category, string fitFilter)
        {
            string gender = null, genderFilter = null;

            gender       = this.RouteData.Values["gender"].ToString().ToLower();
            genderFilter = Constants.GenderFilterFor(gender);

            ViewBag.Scripts = new List <string>()
            {
                "catalog.js"
            };

            var model = new CatalogModel();

            model.Selections = SelectionsManager.GetSelectionModel(this.CurrentBrand);

            this.BuildBreadcrumb(model.Selections.Breadcrumb, category, null, gender, genderFilter);

            if (string.IsNullOrEmpty(gender) ||
                ((model.Selections.Breadcrumb.Category == null && !model.Selections.Breadcrumb.IsCategoryForNewProds) &&
                 model.Selections.Breadcrumb.Collection == null))
            {
                throw Utility.Exception404();
            }

            //get filters
            model.Filters = FiltersManager.GetFilterModel(this.CurrentBrand, genderFilter);

            if (fitFilter != null)
            {
                var fit = model.Filters.FitTypes.Where(d => d.Name.ToLower() == fitFilter.ToLower()).FirstOrDefault();
                if (fit != null)
                {
                    fit.Selected = true;
                }
            }

            model.ProductList = ProductsManager.GetProducts(this.Session,
                                                            new ProductListFilter()
            {
                Brand      = this.CurrentBrand,
                ViewAll    = false,
                PageNumber = 1,
                Collection = model.Selections.Breadcrumb.Collection != null ? model.Selections.Breadcrumb.Collection.Name : null,
                Gender     = genderFilter,
                Category   = model.Selections.Breadcrumb.Category != null ? model.Selections.Breadcrumb.Category.Name : null,
                IsNew      = model.Selections.Breadcrumb.IsCategoryForNewProds ? "true" : null,
                Fit        = string.IsNullOrEmpty(fitFilter) ? new List <string>() : new List <string>()
                {
                    fitFilter
                }
            });

            if (fitFilter == "Classic" || fitFilter == "Modern")
            {
                string fileName = fitFilter == "Classic" ? "ln_fit_classic" : "ln_fit_modern";
                var    arr      = model.ProductList.CatalogImage.Split('/');

                for (int i = 0; i < arr.Length; i++)
                {
                    if (arr[i].Contains(".jpg"))
                    {
                        arr[i] = fileName + ".jpg";
                    }
                }
                model.ProductList.CatalogImage = String.Join("/", arr);
            }

            model.Filters.FilterDisplay = model.ProductList.FilterDisplay;
            model.Filters.FilterDisplay.DisplayFitFilter = false;
            model.ProductList.DisplaySlider = !((category == "other-products") ||
                                                (category == "new-arrivals") ||
                                                (genderFilter == Constants.WOMEN_GENDER && category == "pre-washed") ||
                                                (genderFilter == Constants.MEN_GENDER && category == "pre-washed") ||
                                                (genderFilter == Constants.MEN_GENDER && category == "mens-ripstop"));

            ViewBag.Title       = model.ProductList.Seo.PageTitle;
            ViewBag.Description = model.ProductList.Seo.PageDescription;

            return(View(PathFromView("FitTypes"), model));
        }