private ActionResult GetChildCategoryAttributesActionResult(AttributeValueModel[] attributeValues, int attributeId) { var helper = new CategoryAttributeHelper(); var categoryAttributeValues = helper.GetCategoryAttributeValues(attributeValues.Where(cv => cv.AttributeId == attributeId), true); 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 ExpertCategoryAttributesModel { CategoryAttributes = attributes, CategoryAttributeValues = attributeValues }; return PartialView(MVC.Account.Views._ExpertCategoryAttributes, model); }
public virtual ActionResult ExpertCategoryAttributes(int? categoryId = null) { var currentExpert = AuthenticationHelper.CurrentUser.Expert; Category category; var categoryAttributeValues = new List<AttributeValueModel>(); if(categoryId.HasValue) { category = Repository.Category.Get(categoryId.Value); var attributeValues = currentExpert.CategoryAttributes.SingleOrDefault(ca => ca.Category.Id == categoryId); if(attributeValues != null) { var attributeValueModels = CategoryAttributeHelper.GetCategoryAttributeValueModel(attributeValues.CategoryAttributes, true); categoryAttributeValues.AddRange(attributeValueModels); } } else { var notFilledCategoried = currentExpert.Categories.Where(c => currentExpert.CategoryAttributes.All(ca => ca.Category != c)); category = notFilledCategoried.FirstOrDefault(); if (category == null) return RedirectToAction(MVC.Profile.Edit()); } string expertReason = ""; if (currentExpert.CategoryAttributes.Where(c => c.Category.Id == category.Id).Count() != 0) expertReason = currentExpert.CategoryAttributes.Where(c => c.Category.Id == category.Id).FirstOrDefault().ExpertReason; var attributes = category.Attributes.Where(ca => ca.Type == CategoryAttributeType.MultiSelect || ca.Type == CategoryAttributeType.SingleSelect).ToList(); var model = new ExpertCategoryAttributesModel { Category = category, CategoryAttributes = attributes, ExpertReason = expertReason }; if (categoryAttributeValues != null) model.CategoryAttributeValues = categoryAttributeValues.ToArray(); return View(model); }