public void SimulationDailyTransactions()
        {
            try
            {
                using (var context = new DailyTransactionSimulatorDbContext())
                {
                    var transaction = CreateRandomTransaction();
                    var account     = accounts.Where(a => a.AccountNo == transaction.AccountNo).FirstOrDefault();

                    var accountContext = new RandomAccountCreatorDbContext();

                    if (transaction.Type == TransactionType.Incoming)
                    {
                        account.Balance = account.Balance + transaction.Amount;
                    }
                    else if (transaction.Type == TransactionType.Outgoing)
                    {
                        var newBalance = account.Balance - transaction.Amount;

                        if (newBalance < 0)
                        {
                            transaction.Status      = TransactionStatus.Failed;
                            transaction.Description = StatusDescription.InsufficientFund;
                        }
                        else
                        {
                            account.Balance = newBalance;
                        }
                    }

                    if (transaction.Status != TransactionStatus.Failed)
                    {
                        accountContext.Update(account);
                        if (accountContext.SaveChanges() == 1)
                        {
                            Console.WriteLine($"successfully updated account. new balance is {account.Balance}");
                            transaction.Status      = TransactionStatus.Success;
                            transaction.Description = StatusDescription.Success;
                        }
                        else
                        {
                            transaction.Status      = TransactionStatus.Failed;
                            transaction.Description = StatusDescription.SystemError;
                            Console.WriteLine("transaction failed to process");
                        }
                    }

                    context.Transactions.Update(transaction);
                    if (context.SaveChanges() == 1)
                    {
                        Console.WriteLine("successfully inserted transaction.");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("an error occured");
                Console.WriteLine($"[Error Message] {ex.Message}");
            }
        }
        public Transaction CreateRandomTransaction()
        {
            // create a transaction using a random account and channel

            try
            {
                using (var context = new DailyTransactionSimulatorDbContext())
                {
                    Console.WriteLine("Creating transaction...");
                    var transaction  = new Transaction();
                    var accountIndex = Math.Abs((int)Math.Round(new Random().NextDouble() * (accounts.Count - 1), MidpointRounding.AwayFromZero));
                    var channelIndex = Math.Abs((int)Math.Round(new Random().NextDouble() * (channels.Count - 1), MidpointRounding.AwayFromZero));

                    transaction.AccountNo = accounts[accountIndex].AccountNo;
                    transaction.Channel   = channels[channelIndex];
                    transaction.Amount    = Math.Abs(Math.Round(new Random().NextDouble() * 100, MidpointRounding.AwayFromZero));
                    transaction.Date      = DateTime.Now;

                    transaction.Type = transaction.Channel == Channel.CashDeposit || transaction.Channel == Channel.ChequeDeposit || transaction.Channel == Channel.DirectPayment
                        ? TransactionType.Incoming
                        : TransactionType.Outgoing;
                    transaction.Description = StatusDescription.Pending;
                    transaction.Status      = TransactionStatus.Pending;

                    context.Transactions.Add(transaction);
                    context.SaveChanges();

                    Console.WriteLine($"successfully created {transaction.Type.ToString()} {transaction.Channel} transacion with amount {transaction.Amount}");

                    return(transaction);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occured while creating transaction");
                Console.WriteLine($"[Error Message] {ex.Message}");
                return(null);
            }
        }