예제 #1
0
        // Private methods
        private async Task <AttributeListViewModel> GetAttributeListInCategory(Category category)
        {
            AttributeListViewModel alvm = new AttributeListViewModel()
            {
                Attributes      = null,
                AttributeValues = null
            };

            if (category != null)
            {
                IList <AttributeValue>         attributeValues = null;
                ICollection <Models.Attribute> attributes      = new List <Models.Attribute>();

                await Task.Run(async() =>
                {
                    attributeValues = await _attributeService.GetAttributeValuesInCategory(category.Id);

                    foreach (var attrVal in attributeValues)
                    {
                        var attr = _attributeService.FindAttributeById(attrVal.AttributeId);
                        if (!attributes.Contains(attr))
                        {
                            attributes.Add(attr);
                        }
                    }
                });

                alvm.Attributes      = attributes;
                alvm.AttributeValues = attributeValues;
            }
            return(alvm);
        }