public static void Run([ServiceBusTrigger(QUEUE_NAME, Connection = "ConnectionStringKey")] string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");

            var bankTransactionRepository           = new TableStorageService <BankTransaction>(log, TABLE_STORAGE_CONNECTION_STRING, $"{MY_NAME}BankTransaction");
            var bankTransactionStatisticsRepository = new TableStorageService <BankTransactionStatistics>(log, TABLE_STORAGE_CONNECTION_STRING, $"{MY_NAME}BankTransactionStatistics");

            var queueMessage = JsonConvert.DeserializeObject <QueueMessage>(myQueueItem);
            var transaction  = new BankTransaction(queueMessage);

            bankTransactionRepository.InsertOrUpdateEntry(transaction);

            var transactions = bankTransactionRepository.GetByPartitionId(transaction.PartitionKey);
            var totalAmmount = transactions.Sum(t => t.Ammount);

            var existingBankTransactionStatistics = bankTransactionStatisticsRepository.GetByPartitionId(transaction.PartitionKey).FirstOrDefault();

            if (existingBankTransactionStatistics != null)
            {
                existingBankTransactionStatistics.Ammount = totalAmmount;
            }
            else
            {
                existingBankTransactionStatistics = new BankTransactionStatistics(Guid.NewGuid().ToString(), transaction.PartitionKey)
                {
                    Ammount = totalAmmount
                };
            }

            bankTransactionStatisticsRepository.InsertOrUpdateEntry(existingBankTransactionStatistics);
        }
        public static void Run([TimerTrigger("0 * * * * *")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            var bankTransactionRepository           = new TableStorageService <BankTransaction>(log, ConnectionString, $"{My_Name}BankTransaction");
            var bankTransactionStatisticsRepository = new TableStorageService <BankTransactionStatistics>(log, ConnectionString, $"{My_Name}BankTransactionStatistics");

            SeedData(bankTransactionRepository);

            // Generate BankTransactionStatistics from all senders by aggregating the total sum of their transactions

            var entities = bankTransactionRepository.GetAllEntries();
            var senders  = entities.Select(e => e.PartitionKey).Distinct();

            foreach (var sender in senders)
            {
                var transactions = bankTransactionRepository.GetByPartitionId(sender);
                var totalAmmount = transactions.Sum(t => t.Ammount);

                var existingBankTransactionStatistics = bankTransactionStatisticsRepository.GetByPartitionId(sender).FirstOrDefault();

                if (existingBankTransactionStatistics != null)
                {
                    existingBankTransactionStatistics.Ammount = totalAmmount;
                }
                else
                {
                    existingBankTransactionStatistics = new BankTransactionStatistics(Guid.NewGuid().ToString(), sender)
                    {
                        Ammount = totalAmmount
                    };
                }

                bankTransactionStatisticsRepository.InsertOrUpdateEntry(existingBankTransactionStatistics);
            }
        }