public void EditCategory(int id, NewCategory category)
        {
            var detail     = _attributeDetailRepository.GetAll().ToList();
            var dbCategory = _categoryRepository.Get(id);

            var newCategory = new Category
            {
                Id          = dbCategory.Id,
                Description = category.Description,
                Icon        = category.Icon,
                CreatedBy   = dbCategory.CreatedBy,
                ModifiedBy  = category.CreatedBy,
                Name        = category.Name,
                CreatedOn   = DateTime.Now
            };

            _categoryRepository.Update(newCategory, newCategory.Id);

            foreach (var attribute in detail.Where(attribute => attribute.CategoryId == id))
            {
                _attributeDetailRepository.Remove(attribute);
            }
            foreach (var attribute in category.Attributes.Select(newAttribute => new AttributeDetail
            {
                CategoryId = newCategory.Id,
                Name = newAttribute.Name,
                Type = newAttribute.Type,
                IsMandatory = newAttribute.IsMandatory
            }))
            {
                _attributeDetailRepository.Add(attribute);
            }
        }
        public IEnumerable <CategoryAttributes> Category([FromRoute] int id)
        {
            try
            {
                _attributes = _attributeListRepository.GetAll().ToList();
                foreach (var attributeDetail in _attributes)
                {
                    if (attributeDetail.CategoryId == id)
                    {
                        _attribute.Id          = attributeDetail.Id;
                        _attribute.IsMandatory = attributeDetail.IsMandatory;
                        _attribute.Name        = attributeDetail.Name;
                        _attribute.Type        = attributeDetail.Type;
                        _categoryAttributes.Add(_attribute);
                        _attribute = new CategoryAttributes();
                    }
                }

                return(_categoryAttributes);
            }
            catch (Exception)
            {
                return(_categoryAttributes);
            }
        }