private bool CheckAnyTokenWasSent(List <Transaction> transactions, UserWatchlist watchListLine)
 {
     return(transactions?.Any(t =>
     {
         if ((t.Input?.StartsWith(Constants.Strings.TransactionType.Transfer) ?? false) && (t.From?.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase) ?? false))
         {
             return true;
         }
         return false;
     }) ?? false);
 }
 private bool CheckEtherWasReceived(List <Transaction> transactions, UserWatchlist watchListLine)
 {
     return(transactions?.Any(t =>
     {
         if ((t.To?.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase) ?? false) &&
             (t.Input?.Equals(Constants.Strings.TransactionType.Usual, StringComparison.CurrentCultureIgnoreCase) ?? false))
         {
             return true;
         }
         return false;
     }) ?? false);
 }
Ejemplo n.º 3
0
        public async Task DeleteFromWatchlist(int idwatchlist)
        {
            UserWatchlist wl = new UserWatchlist
            {
                Id = idwatchlist
            };

            _dbContext.UserWatchlist.Attach(wl);
            _dbContext.UserWatchlist.Remove(wl);

            await _dbContext.SaveChangesAsync();
        }
 private bool CheckSpecialTokenWasSent(List <Transaction> transactions, UserWatchlist watchListLine)
 {
     return(transactions?.Any(t =>
     {
         if ((t.To?.Equals(watchListLine.NotificationOptions.TokenOrEtherSentName,
                           StringComparison.CurrentCultureIgnoreCase) ?? false) &&
             (t.From?.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase) ?? false))
         {
             return true;
         }
         return false;
     }) ?? false);
 }
        private bool CheckTokenWasReceived(List <Transaction> transactions, UserWatchlist watchListLine)
        {
            return(transactions?.Any(t =>
            {
                var receiver = InputDecoder.GetTokenCountAndAddressFromInput(t.Input).To;

                if (receiver.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase))
                {
                    return true;
                }

                return false;
            }) ?? false);
        }
 private bool CheckNumberEtherWasReceived(List <Transaction> transactions, UserWatchlist watchListLine)
 {
     return(transactions?.Any(t =>
     {
         if ((t.To?.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase) ?? false) &&
             (t.Input?.Equals(Constants.Strings.TransactionType.Usual, StringComparison.CurrentCultureIgnoreCase) ?? false))
         {
             if ((double)Web3.Convert.FromWei(t.Value.Value, 18) == watchListLine.NotificationOptions.NumberOfTokenOrEtherWasReceived)
             {
                 return true;
             }
         }
         return false;
     }) ?? false);
 }
        private bool CheckNumberTokenWasReceived(List <Transaction> transactions, UserWatchlist watchListLine)
        {
            return(transactions?.Any(t =>
            {
                var receiver = InputDecoder.GetTokenCountAndAddressFromInput(t.Input);
                var value = (double)Web3.Convert.FromWei(receiver.Value, watchListLine.NotificationOptions.TokenReceivedDecimalPlaces);

                if (receiver.To != null && receiver.To.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase) &&
                    value == watchListLine.NotificationOptions.NumberOfTokenOrEtherWasReceived)
                {
                    return true;
                }

                return false;
            }) ?? false);
        }
 private bool CheckNumberOfTokenWasSent(List <Transaction> transactions, UserWatchlist watchListLine)
 {
     return(transactions?.Any(t =>
     {
         if ((t.To?.Equals(watchListLine.NotificationOptions.TokenOrEtherSentName,
                           StringComparison.CurrentCultureIgnoreCase) ?? false) &&
             (t.From?.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase) ?? false))
         {
             var value = (double)Web3.Convert.FromWei(InputDecoder.GetTokenCountAndAddressFromInput(t.Input).Value, watchListLine.NotificationOptions.TokenSentDecimalPlaces);
             if (value >= watchListLine.NotificationOptions.NumberOfTokenOrEtherThatWasSentFrom &&
                 value <= watchListLine.NotificationOptions.NumberOfTokenOrEtherThatWasSentTo)
             {
                 return true;
             }
         }
         return false;
     }) ?? false);
 }
Ejemplo n.º 9
0
        public async Task <ActionResult <UserWatchlist> > PostUserWatchlist(UserWatchlist userWatchlist)
        {
            _context.UserWatchlist.Add(userWatchlist);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (UserWatchlistExists(userWatchlist.UserId, userWatchlist.MediaType, userWatchlist.MediaId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetUserWatchlist", new { user_id = userWatchlist.UserId, media_type = userWatchlist.MediaType, media_id = userWatchlist.MediaId }, userWatchlist));
        }
        private bool CheckNumberOfContractTokenWasSent(List <Transaction> transactions, UserWatchlist watchListLine)
        {
            return(transactions?.Any(t =>
            {
                if (t.To != null && t.To.Equals(watchListLine.Address, StringComparison.CurrentCultureIgnoreCase))
                {
                    var value = (double)Web3.Convert.FromWei(InputDecoder.GetTokenCountAndAddressFromInput(t.Input).Value, watchListLine.TokenDecimalPlaces);

                    if (value == watchListLine.NotificationOptions.NumberOfContractTokenWasSent)
                    {
                        return true;
                    }
                }
                return false;
            }) ?? false);
        }