Esempio n. 1
0
        protected void PrepareCategoryAttributeGroups(CategoryModel model, Category category)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            //TODO - multiple category attach
            //var ctcpavg = _categoryProductAttributeService.GetCategoryToCategoryProductAttributeGroupByCategoryId(category.Id).FirstOrDefault();
            //if (ctcpavg != null)
            //    model.CategoryProductAttributeGroupId = ctcpavg.CategoryProductAttributeGroupId;
            //available attribute groups
            model.AvailableCategoryProductAttributeGroups = new List <SelectListItem> {
                new SelectListItem {
                    Text = "[None]", Value = "0"
                }
            };
            var        av_catattrgr  = _categoryProductAttributeService.GetAllCategoryProductAttributeGroups();
            List <int> linked_catsgr = _categoryProductAttributeService.GetCategoryToCategoryProductAttributeGroupByCategoryId(category.Id).Select(i => i.CategoryProductAttributeGroupId).ToList();

            av_catattrgr = av_catattrgr.Where(i => !linked_catsgr.Contains(i.Id)).ToList();
            foreach (var pva in av_catattrgr)
            {
                model.AvailableCategoryProductAttributeGroups.Add(new SelectListItem()
                {
                    Text  = pva.Name,
                    Value = pva.Id.ToString(),
                    //Selected = (model.CategoryProductAttributeGroupId > 0 ? pva.Id == model.CategoryProductAttributeGroupId : false)
                });
            }
            //if(model.CategoryProductAttributeGroupId>0)
        }
Esempio n. 2
0
        public ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }

            var categoryProductAttributeGroupss = _categoryProductAttributeService.GetAllCategoryProductAttributeGroups();
            var data      = categoryProductAttributeGroupss.Select(x => { x.Name = x.GetLocalized(z => z.Name, _workContext.WorkingLanguage.Id); return(x); }).ToList();
            var gridModel = new GridModel <CategoryProductAttributeGroupModel>
            {
                Data  = data.Select(x => x.ToModel()),
                Total = categoryProductAttributeGroupss.Count()
            };

            return(View(gridModel));
        }