Пример #1
0
 public DataContext(IConfiguration configuration)
 {
     _configuration = configuration;
     Connection     = CreateConnection();
     Transaction    = CreateTransaction();
     RegisterMappings();
 }
Пример #2
0
        public void UpdateDashboard()
        {
            var barcoin = new Blockchain.Model.Blockchain();

            ObservableCollection <Transaction> transactions = barcoin.GetUserRelevantTransactions(SignedUser.Id);

            CustomTransactions = new ObservableCollection <CustomTransaction>();

            var orderedTransactions = transactions.OrderByDescending(x => x.Timestamp.Date)
                                      .ThenByDescending(x => x.Timestamp.TimeOfDay);

            float balance = 0.0f;

            foreach (Transaction t in orderedTransactions)
            {
                if (t.RecipientId == SignedUser.Id)
                {
                    balance += t.Amount;
                }
                else
                {
                    balance -= t.Amount;
                }

                string sender    = barcoin.GetUsernameById(t.SenderId);
                string recipient = barcoin.GetUsernameById(t.RecipientId);

                CustomTransaction ct = new CustomTransaction()
                {
                    Id        = t.Id,
                    Hash      = t.ComputeHash(),
                    Sender    = t.SenderId == SignedUser.Id ? "You" : sender,
                    Recipient = t.RecipientId == SignedUser.Id ? "You" : recipient,
                    Amount    = t.Amount,
                    Timestamp = t.Timestamp.ToString("yyyy.MM.dd"),
                    Color     = t.RecipientId == SignedUser.Id ? "DeepSkyBlue" : "Transparent"
                };

                CustomTransactions.Add(ct);
            }

            ChartSeriesRepo = new ChartSeriesRepository(
                barcoin.GetTransactions()
                .OrderByDescending(x => x.Timestamp.Date)
                .Take(50),
                CustomTransactions
                );

            Balance = balance.ToString("n4");

            if (barcoin.IsValid())
            {
                ViewModelLocator.Main.SyncState = "up to date";
            }
            else
            {
                ViewModelLocator.Main.SyncState = "out of sync";
            }
        }
Пример #3
0
        public IActionResult ListeCustomTransactionFicheClient(string id, string email, string dates)
        {
            // GetListAdmin("ADMIN");
            ViewBag.total    = total;
            ViewBag.solde    = solde;
            ViewBag.benefice = benef;

            if (id == null || email == null)
            {
                return(HttpNotFound());
            }


            int mois = DateTime.UtcNow.Month;

            ViewBag.mois  = DateTime.UtcNow.ToString("MMMM");
            ViewBag.annee = DateTime.UtcNow.Year;


            List <CustomTransaction> lstCustom = new List <CustomTransaction>();


            var lstTrans = _context.Transactions.Where(t => t.idUtilisateur.Equals(id)).OrderByDescending(c => c.DateTransaction).ToList();

            //var lstTrans = _context.Transactions.Where(t=>t.idUtilisateur.Equals(id) && t.DateTransaction.Month==mois).OrderByDescending(c => c.DateTransaction).ToList();

            foreach (var item in lstTrans)
            {
                CustomTransaction cstrans     = new CustomTransaction();
                ApplicationUser   currentUser = _context.Users.Where(c => c.Id == item.idUtilisateur).FirstOrDefault();


                cstrans.CompteUnite = currentUser.CompteUnite;
                cstrans.SeuilUnite  = currentUser.SeuilUnite;
                cstrans.Email       = currentUser.Email;

                cstrans.DateTransaction = item.DateTransaction;
                cstrans.Id              = item.Id;
                cstrans.Montant         = item.Montant;
                cstrans.Numero          = item.Numero;
                cstrans.Pourcentage     = item.Pourcentage;
                cstrans.status          = item.status;
                cstrans.Total           = item.Total;
                cstrans.TypeTransaction = item.TypeTransaction;
                cstrans.TypeTransfert   = item.TypeTransfert;

                lstCustom.Add(cstrans);
            }

            ViewBag.email            = email;
            ViewBag.listeFicheClient = lstCustom;
            return(View());
        }
Пример #4
0
        public IActionResult ListeCustomTransaction()
        {
            List <CustomTransaction> lstCustom = new List <CustomTransaction>();

            int mois = DateTime.UtcNow.Month;

            ViewBag.mois  = DateTime.UtcNow.ToString("MMMM");
            ViewBag.annee = DateTime.UtcNow.Year;

            var lstTrans = _context.Transactions.Where(c => c.DateTransaction.Month == mois).OrderByDescending(c => c.DateTransaction).ToList();

            foreach (var item in lstTrans)
            {
                CustomTransaction cstrans     = new CustomTransaction();
                ApplicationUser   currentUser = _context.Users.Where(c => c.Id == item.idUtilisateur).FirstOrDefault();


                cstrans.CompteUnite = currentUser.CompteUnite;
                cstrans.SeuilUnite  = currentUser.SeuilUnite;
                cstrans.Email       = currentUser.Email;

                cstrans.DateTransaction = item.DateTransaction;
                cstrans.Id              = item.Id;
                cstrans.Montant         = item.Montant;
                cstrans.Numero          = item.Numero;
                cstrans.Pourcentage     = item.Pourcentage;
                cstrans.status          = item.status;
                cstrans.Total           = item.Total;
                cstrans.Benefice        = (item.Montant * (item.Pourcentage + 3)) / 100;
                cstrans.TypeTransaction = item.TypeTransaction;
                cstrans.TypeTransfert   = item.TypeTransfert;

                lstCustom.Add(cstrans);
            }

            ViewBag.liste = lstCustom;


            moisTran         = DateTime.UtcNow.Month;
            smoisTran        = DateTime.UtcNow.ToString("MMMM");
            anneeTran        = DateTime.UtcNow.Year;
            benefTransaction = _context.Transactions.Where(c => c.DateTransaction.Month == moisTran && c.status.ToUpper().Equals("TERMINER")).Sum(s => (s.Montant * (s.Pourcentage + 3)) / 100);


            return(View());
        }
Пример #5
0
        private void ComputeChartsDatapoints()
        {
            var globalGroups = BlockchainTransactions
                               .OrderBy(x => x.Timestamp.Date)
                               .GroupBy(x => x.Timestamp.Date);

            ChartValues <int>    dailyTransactions     = new ChartValues <int>();
            ChartValues <double> dailyCurrencyTraded   = new ChartValues <double>();
            ChartValues <double> dailyReceivedCurrency = new ChartValues <double>();
            ChartValues <double> dailySentCurrency     = new ChartValues <double>();

            Labels = new List <string>();

            foreach (var group in globalGroups)
            {
                dailyTransactions.Add(group.Count());

                double sum = 0;

                for (int i = 0; i < group.Count(); i++)
                {
                    Transaction t = group.ElementAt(i);

                    sum += t.Amount;
                }

                dailyCurrencyTraded.Add(Math.Round(sum, 4));

                Labels.Add(group.Key.ToString("yyyy.MM.dd"));
            }

            var dateGroups = UserTransactions
                             .OrderBy(x => Convert.ToDateTime(x.Timestamp).Date)
                             .GroupBy(x => Convert.ToDateTime(x.Timestamp).Date);

            foreach (var group in dateGroups)
            {
                double sumReceived = 0;
                double sumSent     = 0;

                for (int i = 0; i < group.Count(); i++)
                {
                    CustomTransaction ct = group.ElementAt(i);

                    if (ct.Recipient.Equals("You"))
                    {
                        sumReceived += ct.Amount;
                    }
                    else
                    {
                        sumSent += ct.Amount;
                    }
                }

                dailyReceivedCurrency.Add(Math.Round(sumReceived, 4));
                dailySentCurrency.Add(Math.Round(sumSent, 4));
            }

            DailyTransactions = new SeriesCollection()
            {
                new ColumnSeries()
                {
                    Title  = "Daily Global Transactions",
                    Values = dailyTransactions
                }
            };

            DailyCurrencyTraded = new SeriesCollection()
            {
                new ColumnSeries()
                {
                    Title  = "Daily Global BRC Traded",
                    Values = dailyCurrencyTraded
                }
            };

            DailyBalances = new SeriesCollection()
            {
                new StackedColumnSeries()
                {
                    Title  = "Received Currency",
                    Values = dailyReceivedCurrency
                },

                new StackedColumnSeries()
                {
                    Title  = "Sent Currency",
                    Values = dailySentCurrency
                }
            };
        }
Пример #6
0
 public void Dispose()
 {
     Transaction = null;
     Connection  = null;
 }