public async Task <List <CollectionCategory> > GetAsync()
        {
            List <CollectionCategory> serviceCollections = new List <CollectionCategory>();
            var collections = await this._collectionQueries.GetAsync();

            if (collections != null)
            {
                foreach (var collection in collections)
                {
                    CollectionCategory currentCollection = new CollectionCategory(collection);
                    currentCollection.Tags = (await _tagQueries.GetByContainerIdAsync(currentCollection.Id)).Select(rec => new TagBO(rec)).ToList();

                    foreach (var childContainer in currentCollection.ChildContainers)
                    {
                        childContainer.Rules = await _ruleService.GetWithLogsByContainerIdAsync(childContainer.Id);

                        childContainer.AmountRules = childContainer.Rules != null ? childContainer.Rules.Count : 0;
                        childContainer.Tags        = (await _tagQueries.GetByContainerIdAsync(childContainer.Id)).Select(rec => new TagBO(rec)).ToList();

                        if (collection.RuleDetailsDestinationId != null && childContainer.Rules != null && childContainer.Rules.Any())
                        {
                            childContainer.Rules.ForEach(rec => rec.CollectionRuleDetailsDestinationId = collection.RuleDetailsDestinationId);
                        }
                    }
                    serviceCollections.Add(currentCollection);
                }
            }
            return(serviceCollections);
        }
Exemple #2
0
        public async Task <List <TagBO> > GetByContainerIdAsync(Guid containerId)
        {
            var result = await _TagQueries.GetByContainerIdAsync(containerId);

            if (result != null)
            {
                var listTags = result
                               .Select(rec => MapEntityToModel(rec))
                               .ToList();

                await DetermineIfTagIsUsed(listTags);

                listTags = listTags.OrderBy(rec => rec.Name).ToList();
                return(listTags);
            }
            return(null);
        }