Example #1
0
        private static AttributeValuePair BuildAVP(
            AttributeControlType attributeControlType,
            CustomerAttribute customerAttribute, string strValue
            )
        {
            switch (attributeControlType)
            {
            case AttributeControlType.DropdownList:
            case AttributeControlType.RadioList:
            case AttributeControlType.Checkboxes:

                var productVariantAttributeValue =
                    customerAttribute.CustomerAttributeValues
                    .Single(pvav => pvav.Id == Int32.Parse(strValue));

                var attributeValue = new AttributeValuePair()
                {
                    AttributeName = customerAttribute.Name,
                    ValueId       = productVariantAttributeValue.Id,
                    ValueText     = productVariantAttributeValue.Name
                };
                return(attributeValue);


            default: attributeValue = new AttributeValuePair()
            {
                    AttributeName = customerAttribute.Name,
                    ValueId       = 0,
                    ValueText     = strValue
            };
                return(attributeValue);
            }
        }
        public virtual Multimap<int, ProductVariantAttribute> GetProductVariantAttributesByProductIds(int[] productIds, AttributeControlType? controlType)
        {
            Guard.ArgumentNotNull(() => productIds);

            var query = from pva in _productVariantAttributeRepository.TableUntracked.Expand(x => x.ProductVariantAttributeValues)
                        where productIds.Contains(pva.ProductId)
                        select pva;

            if (controlType.HasValue)
            {
                query = query.Where(x => x.AttributeControlTypeId == ((int)controlType.Value));
            }

            var map = query
                .OrderBy(x => x.ProductId)
                .ThenBy(x => x.DisplayOrder)
                .ToList()
                .ToMultimap(x => x.ProductId, x => x);

            return map;
        }