public static AssetDirectoryViewModel Create(IEnumerable <IAssetDefinition> assetDefinitions,
                                                     IDictionary <string, IAssetCoinholdersIndex> assetCoinholdersIndices,
                                                     IDictionary <string, IAssetScore> assetScoresDictionaries,
                                                     int take = int.MaxValue)
        {
            return(new AssetDirectoryViewModel
            {
                Assets = assetDefinitions.Select(p =>
                {
                    var assetId = p.AssetIds.FirstOrDefault();

                    IAssetCoinholdersIndex index = null;
                    if (assetCoinholdersIndices.ContainsKey(assetId))
                    {
                        index = assetCoinholdersIndices[assetId];
                    }

                    IAssetScore assetScore = null;
                    if (assetScoresDictionaries.ContainsKey(assetId))
                    {
                        assetScore = assetScoresDictionaries[assetId];
                    }

                    return Asset.Create(p, index, assetScore);
                })
                         .OrderBy(p => p.Score).ToList().Take(take)
            });
        }
Пример #2
0
 public static AssetScoreEntity Create(IAssetScore assetScore)
 {
     return(new AssetScoreEntity
     {
         AssetIds = assetScore.AssetIds.ToJson(),
         Score = assetScore.Score,
         PartitionKey = CreatePartitionKey(),
         RowKey = CreateRowKey(assetScore.AssetIds)
     });
 }
 public static Asset Create(IAssetDefinition source, IAssetCoinholdersIndex index, IAssetScore assetScore)
 {
     return(new Asset
     {
         AssetIds = source.AssetIds ?? Enumerable.Empty <string>(),
         ContactUrl = source.ContactUrl,
         Description = source.Description,
         DescriptionMime = source.DescriptionMime,
         Divisibility = source.Divisibility,
         IconUrl = source.IconUrl,
         ImageUrl = source.ImageUrl,
         Issuer = source.Issuer,
         LinkToWebsite = source.LinkToWebsite,
         Name = source.Name,
         NameShort = source.NameShort,
         Type = source.Type,
         Version = source.Version,
         IsVerified = source.IsVerified(),
         CoinholdersCount = index?.CoinholdersCount,
         TotalQuantity = index?.TotalQuantity,
         Score = assetScore?.Score ?? 1,
         IssuerEncoded = (source.Issuer ?? "").ToBase64(),
         IssuerWebSite = source.IssuerWebsite()
     });
 }
Пример #4
0
 public Task InsertOrReplaceAsync(IAssetScore assetScore)
 {
     return(_tableStorage.InsertOrReplaceAsync(AssetScoreEntity.Create(assetScore)));
 }