Пример #1
0
        public ActionResult EditPropductCategoryArticle(int categoryId)
        {
            ProductCategory productCategory           = _productCategoriesBL.GetById(categoryId);
            ProductCategoryArticleEditViewModel model = new ProductCategoryArticleEditViewModel
            {
                Id   = productCategory.Id,
                Text = productCategory.Article
            };

            return(View(model));
        }
Пример #2
0
        public void DeleteById()
        {
            //Arrange
            ResetDataBase();
            ProductCategoriesBL target = DI.Resolve <ProductCategoriesBL>();

            //Act
            target.Delete(37);

            //Asserts
            Assert.That(target.GetById(37).IsDeleted);
            Assert.That(target.GetById(38).IsDeleted);
            Assert.That(target.GetById(39).IsDeleted);
            Assert.That(target.GetById(40).IsDeleted);
            Assert.That(target.GetById(41).IsDeleted);
        }
Пример #3
0
        public ProductCategoriesApiViewModel GetChildCategories(int?id)
        {
            List <ProductCategory> productCategories = _productCategoriesBL.GetCategories(id).Where(entity => !entity.IsDeleted).ToList();

            ProductCategoriesApiViewModel apiViewModel = new ProductCategoriesApiViewModel();

            apiViewModel.data.AddRange(productCategories.Select(BuildProductCategoryListItemViewModel));

            if (id.HasValue)
            {
                List <ProductCategory> parentCategories = _productCategoriesBL.GetParentCategories(id.Value);
                parentCategories.Add(_productCategoriesBL.GetById(id.Value));

                apiViewModel.PathToRoot.AddRange(parentCategories.Select(BuildProductCategoryListItemViewModel));
            }

            return(apiViewModel);
        }
Пример #4
0
        public ActionResult Index(ProductsFilterViewModel filter)
        {
            if (TempData[Constants.TempDataKeys.PRODUCTS_FILTER_VIEW_MODEL] != null)
            {
                filter = (ProductsFilterViewModel)TempData[Constants.TempDataKeys.PRODUCTS_FILTER_VIEW_MODEL];
            }

            filter.PageSize = ApplicationSettings.Instance.AppSettings.DefaultPageSize;

            ProductsViewModel model = new ProductsViewModel
            {
                Filter = filter
            };

            if (ModelState.IsValid)
            {
                ModelState.RemoveStateFor(filter, viewModel => filter.Category.Name);
                if (filter.Category.Id.HasValue)
                {
                    filter.Category.Name = _productCategoriesBL.GetById(filter.Category.Id.Value).Name;
                }

                ProductsFilter productsFilter = new ProductsFilter
                {
                    ParentId = filter.Category.Id
                };
                productsFilter.PaginationFilter.PageNumber = filter.PageNumber;
                productsFilter.PaginationFilter.PageSize   = filter.PageSize;

                PagedProductListResult pagedProductListResult = _productsBL.Get(productsFilter);
                model.Filter.TotalRecords = pagedProductListResult.TotalRecords;

                model.Products = pagedProductListResult.Entities.Select(entity => new ProductListItemViewModel
                {
                    Product    = entity,
                    CategoryId = filter.Category.Id
                }).ToList();
            }

            return(View(model));
        }
Пример #5
0
        public ActionResult Index([FromUri] int?parentId)
        {
            object parentCategoryIdObject = TempData[Constants.TempDataKeys.PRODUCT_CATEGORIES_PARENT_ID];

            int?parentCategoryId = (int?)parentCategoryIdObject ?? parentId;

            List <ProductCategory> parentCategories = new List <ProductCategory>();

            if (parentCategoryId.HasValue)
            {
                parentCategories.AddRange(_productCategoriesBL.GetParentCategories(parentCategoryId.Value));
                parentCategories.Add(_productCategoriesBL.GetById(parentCategoryId.Value));
            }

            List <ProductCategoriesBreadCrumbItem> breadCrumbs = new List <ProductCategoriesBreadCrumbItem>(
                parentCategories.Select(x => new ProductCategoriesBreadCrumbItem
            {
                Id   = x.Id,
                Name = x.Name
            }));

            ProductCategoriesBreadCrumbItem rootCategoriesBreadCrumbItem = new ProductCategoriesBreadCrumbItem
            {
                Id   = null,
                Name = ".."
            };

            breadCrumbs.Insert(0, rootCategoriesBreadCrumbItem);

            ProductCategoriesViewModel model = new ProductCategoriesViewModel
            {
                BreadCrumbItems  = breadCrumbs,
                ParentCategoryId = parentCategoryId
            };

            return(View(model));
        }
Пример #6
0
        public void SetPublish()
        {
            //Arrange
            ResetDataBase();
            ProductCategoriesBL target     = DI.Resolve <ProductCategoriesBL>();
            ProductsBL          productsBl = DI.Resolve <ProductsBL>();

            //Act
            target.SetPublish(65, false);

            //Asserts
            Assert.That(!target.GetById(65).Publish);
            Assert.That(!productsBl.GetById(86).Publish);
            Assert.That(!productsBl.GetById(87).Publish);
            Assert.That(!productsBl.GetById(88).Publish);
            Assert.That(!productsBl.GetById(89).Publish);
            Assert.That(!productsBl.GetById(90).Publish);
            Assert.That(!productsBl.GetById(91).Publish);
            Assert.That(!productsBl.GetById(92).Publish);
            Assert.That(!productsBl.GetById(93).Publish);
            Assert.That(!productsBl.GetById(95).Publish);
        }