Exemplo n.º 1
0
        public async Task <PropertyProviderData> GetProvider(IPropertyProvider provider, int providerID)
        {
            var plainProviderAttributes = await provider.GetAttributes();

            var plainProviderRelations = await provider.GetRelations();

            var plainProviderEvents = await provider.GetEvents();

            var attributes = await Task.WhenAll(plainProviderAttributes.Select(attr => GetAttachedAttribute(attr)));

            var relations = await Task.WhenAll(plainProviderRelations.Select(relation => GetAttachedRelation(relation)));

            var events = await Task.WhenAll(plainProviderEvents.Select(e => GetAttachedEvent(e)));

            var attributesDict = attributes.ToDictionary(
                k => k.Attribute.ID,
                v => v
                );
            var relationsDict = relations.ToDictionary(
                k => k.Relation.PropertyID,
                v => v
                );
            var eventsDict = events.ToDictionary(
                k => k.Property.PropertyID,
                v => v
                );

            return(new PropertyProviderData(attributesDict, relationsDict, eventsDict, providerID));
        }