Beispiel #1
0
        public async Task <int> CreateFundTokensAsync(string fundAddress, FundTokenCreateRequest fundTokenCreateRequest)
        {
            var tokenAllocations = fundTokenCreateRequest.FundTokenAllocations;
            int result           = 0;

            if (tokenAllocations != null)
            {
                uint batchTimeStamp = GetCurrentBatchTimeStamp();

                var requestedFund = await GetFundAsync(fundAddress);

                if (requestedFund != null)
                {
                    var fundTokenSnapshot = new List <DataModelFundToken>();
                    foreach (var tokenAllocation in tokenAllocations)
                    {
                        var token = this.galaxisContext.Tokens
                                    .FirstOrDefault(t => t.Symbol == tokenAllocation.TokenSymbol);

                        fundTokenSnapshot.Add(new FundToken
                        {
                            FundId    = requestedFund.Id,
                            Quantity  = tokenAllocation.Quantity,
                            Timestamp = batchTimeStamp,
                            TokenId   = token.Id
                        });
                    }

                    await this.galaxisContext.FundTokens.AddRangeAsync(fundTokenSnapshot);

                    result = await this.galaxisContext.SaveChangesAsync();
                }
            }

            return(result);
        }
Beispiel #2
0
 public async Task <int> AddTokenToFund(string fundAddress, [FromBody] FundTokenCreateRequest fundTokenCreateRequest)
 {
     return(await this.fundRepository.CreateFundTokensAsync(fundAddress, fundTokenCreateRequest));
 }