Beispiel #1
0
        public static Transaction ConvertTransaction(TransactionViewModel transactionViewModel)
        {
            if (transactionViewModel == null)
            {
                return(null);
            }

            var transaction = new Transaction
            {
                Id        = transactionViewModel.Id,
                AccountId = transactionViewModel.AccountId,
                Date      = transactionViewModel.Date,
                Amount    = transactionViewModel.Amount
            };

            return(transaction);
        }
Beispiel #2
0
        public static TransactionViewModel ConvertTransaction(Transaction transaction)
        {
            if (transaction == null)
            {
                return(null);
            }

            var transactionViewModel = new TransactionViewModel
            {
                Id        = transaction.Id,
                AccountId = transaction.AccountId,
                Date      = transaction.Date,
                Amount    = transaction.Amount
            };

            transactionViewModel.AccountNumber = (transaction.Account?.Number);
            return(transactionViewModel);
        }
Beispiel #3
0
        public static void Initialize(IUserRepository userRepository, IUserAccountRepository userAccountRepository, ITransactionRepository transactionRepository)
        {
            userRepository.EnsureDbCreated();

            // Look for any students.
            if (userRepository.UsersAny())
            {
                return;                   // DB has been seeded
            }
            var users = new UserViewModel[]
            {
                new UserViewModel {
                    FirstName = "Carson", LastName = "Alexander", Birthday = DateTime.Parse("1985-09-01"), Address = "180 chemin de la grange, 01360 Béligneux"
                },
                new UserViewModel {
                    FirstName = "Meredith", LastName = "Alonso", Birthday = DateTime.Parse("1986-09-01"), Address = "181 chemin de la grange, 01360 Béligneux"
                },
                new UserViewModel {
                    FirstName = "Arturo", LastName = "Anand", Birthday = DateTime.Parse("1978-09-01"), Address = "182 chemin de la grange, 01360 Béligneux"
                },
                new UserViewModel {
                    FirstName = "Gytis", LastName = "Barzdukas", Birthday = DateTime.Parse("1961-09-01"), Address = "183 chemin de la grange, 01360 Béligneux"
                },
                new UserViewModel {
                    FirstName = "Yan", LastName = "Li", Birthday = DateTime.Parse("1996-09-01"), Address = "184 chemin de la grange, 01360 Béligneux"
                },
                new UserViewModel {
                    FirstName = "Peggy", LastName = "Justice", Birthday = DateTime.Parse("1973-09-01"), Address = "185 chemin de la grange, 01360 Béligneux"
                },
                new UserViewModel {
                    FirstName = "Laura", LastName = "Norman", Birthday = DateTime.Parse("1979-09-01"), Address = "186 chemin de la grange, 01360 Béligneux"
                },
                new UserViewModel {
                    FirstName = "Nino", LastName = "Olivetto", Birthday = DateTime.Parse("1985-09-01"), Address = "187 chemin de la grange, 01360 Béligneux"
                }
            };

            foreach (UserViewModel u in users)
            {
                var user = Tools.ConvertUser(u);
                _ = userAccountRepository.CreateNewAccount(user);
            }

            var transactions = new TransactionViewModel[]
            {
                new TransactionViewModel {
                    AccountId = 1, Date = DateTime.Parse("2021-03-05 14:30"), Amount = 5641
                },
                new TransactionViewModel {
                    AccountId = 2, Date = DateTime.Parse("2021-03-05 14:30"), Amount = 752
                },
                new TransactionViewModel {
                    AccountId = 3, Date = DateTime.Parse("2021-05-02 11:30"), Amount = 1887
                },
                new TransactionViewModel {
                    AccountId = 4, Date = DateTime.Parse("2021-07-01 16:30"), Amount = 625
                },
                new TransactionViewModel {
                    AccountId = 5, Date = DateTime.Parse("2021-09-01 10:30"), Amount = 986
                },
                new TransactionViewModel {
                    AccountId = 6, Date = DateTime.Parse("2021-05-02 11:30"), Amount = 12000
                },
                new TransactionViewModel {
                    AccountId = 7, Date = DateTime.Parse("2021-07-01 16:30"), Amount = 2547
                },
                new TransactionViewModel {
                    AccountId = 8, Date = DateTime.Parse("2021-09-01 10:30"), Amount = 120
                },
            };

            foreach (TransactionViewModel t in transactions)
            {
                var transaction = Tools.ConvertTransaction(t);
                _ = transactionRepository.CreateNewTransaction(transaction, true);
            }
        }