public virtual ActionResult ProcessKeyword(KeywordProcessForm form = null) { var count = Repository.SEOKeyword.Count(q => q.ByStatus(SEOKeywordStatus.New)); var keyword = form.SeoKeywordId > 0 ? Repository.SEOKeyword.Get(form.SeoKeywordId) : Repository.SEOKeyword.GetToModerate(); if (keyword == null) return View(MVC.Catalog.Views.NoNewKeyword); var model = new KeywordProcessFormModel(keyword); model.AvailableCategories = Repository.Category.All().Select(c => new SelectListItem {Text = c.Name, Value = c.Id.ToString()}); model.KeywordProcessForm.SeoKeywordType = keyword.Type; if (keyword.Category != null) model.KeywordProcessForm.CategoryId = keyword.Category.Id; model.NumberOfKeywordsToModerate = count; if (form.SeoKeywordId > 0) model.KeywordProcessForm = form; return View(MVC.Catalog.Views.ProcessKeyword, model); }
public virtual ActionResult ChildCategoryAttributes( [Bind(Prefix = "AttributeValues")] AttributeValueModel[] attributeValues, int attributeId) { var helper = new CategoryAttributeHelper(); var categoryAttributeValues = helper.GetCategoryAttributeValues(attributeValues.Where(cv => cv.AttributeId == attributeId)); var allSubAttributes = categoryAttributeValues.SelectMany(cav => cav.Attribute.ChildAttributes); var selectedSubAttributes = allSubAttributes.Where( sa => categoryAttributeValues.Any(cav => cav.SelectedOptions.Intersect(sa.ParentOptions).Any())); var attributes = selectedSubAttributes.Where( ca => ca.Type == CategoryAttributeType.MultiSelect || ca.Type == CategoryAttributeType.SingleSelect) .ToList(); var model = new KeywordProcessFormModel {CategoryAttributes = attributes, CategoryAttributeValues = attributeValues}; return PartialView(MVC.Catalog.Views._KeywordCategoryAttributes, model); }
public virtual ActionResult SetKeywordAttributes([Bind(Prefix = "KeywordProcessForm")] KeywordProcessForm form) { if (!ModelState.IsValid) return ProcessKeyword(form); var keyword = Repository.SEOKeyword.Get(form.SeoKeywordId); var category = Repository.Category.Get(form.CategoryId); var attributes = category.Attributes.Where( ca => ca.Type == CategoryAttributeType.MultiSelect || ca.Type == CategoryAttributeType.SingleSelect) .ToList(); var values = CategoryAttributeHelper.GetCategoryAttributeValueModel(keyword.CategoryAttributes); var model = new KeywordProcessFormModel(keyword) { KeywordProcessForm = form, CategoryAttributes = attributes, CategoryAttributeValues = values }; return View(model); }