Beispiel #1
0
        private List <ProductProperty> GetAllProductProperties(int proudctCategoryId, Product product)
        {
            var properties = new List <ProductProperty>();
            // getall the tag types
            var allProductTagTypesResult = _tagTypeLogic.GetTagTypes(proudctCategoryId, true);

            if (!allProductTagTypesResult.Success)
            {
                throw new Exception($"Failed to get all tag types for product. Message:{allProductTagTypesResult.Message}");
            }

            // we need to create the information based on all the tag types for the product
            foreach (var productTagType in allProductTagTypesResult.Data)
            {
                var property = new ProductProperty {
                    Name = productTagType.Name, PropertyTypeId = productTagType.Id
                };

                // check if the property already has value in the product TagValues - where for
                // each tag type for the product we store the value
                var productTagValueForTagType = product.ProductTagValues.FirstOrDefault(tv => tv.TagTypeId == productTagType.Id);

                if (productTagValueForTagType != null)
                {
                    property.Value = productTagValueForTagType.Value;
                    property.Id    = productTagValueForTagType.Id;
                }

                properties.Add(property);
            }

            return(properties);
        }
Beispiel #2
0
        public IEnumerable <TagTypeDto> Get(int?categoryId = null, bool includeParentCategoryTags = false)
        {
            var tagsQueryResult = _tagTypesLogic.GetTagTypes(categoryId, includeParentCategoryTags);

            if (tagsQueryResult.Success)
            {
                var tags = tagsQueryResult.Data.Select(AutoMapper.Mapper.Map <TagType, TagTypeDto>).ToList();

                return(tags);
            }

            throw new HttpResponseException(ResponseMessageBuilder.BuildMessageFromActionResult(tagsQueryResult));
        }