Esempio n. 1
0
        public void TestCreatingAccountsFile()
        {
            Account account = new Account(
                "123k", "someType", 234, DateTime.Now, true, false,
                new Owner("Vlad", "Demyanov", "Ruslanovich", DateTime.Now, "passport"));

            Account account2 = new Account(
                "124k", "someType", 234, DateTime.Now, true, false,
                new Owner("Vlad", "Demyanov", "Ruslanovich", DateTime.Now, "passport"));

            AccountsRepository accountsRepository = new AccountsRepository();

            accountsRepository.AddAccount(account);
            accountsRepository.AddAccount(account2);
            Assert.Pass();
        }
Esempio n. 2
0
        public string[] Handle(string[] args)
        {
            if (args.Length < 2)
            {
                if (args.Length == 1)
                {
                    if (args[0] == "?" || args[0].ToLower() == "help")
                    {
                        return(new string[]
                        {
                            GetName() + "\n\rUsage: " + GetDescription()
                        });
                    }
                }

                return(new string[]
                {
                    "Please provide both a username and an email address."
                });
            }

            string username = args[0];
            string email    = args[1];

            AddAccountResult result  = AccountsRepository.AddAccount(email, username);
            List <string>    returns = new List <string>();

            if (result == AddAccountResult.Exists || result == AddAccountResult.InvalidEmailAndUserExists)
            {
                returns.Add(String.Format("Account name \"{0}\" already exists.", username));
            }

            if (result == AddAccountResult.InvalidEmail || result == AddAccountResult.InvalidEmailAndUserExists)
            {
                returns.Add(String.Format("Email \"{0}\" is invalid.", email));
            }

            if (result == AddAccountResult.Successful)
            {
                returns.Add(String.Format("Account has been created for user: {0} email: {1}.", username, email));
            }

            return(returns.ToArray());
        }
 public string AddAccount(string nickOwner)
 {
     accrepository.AddAccount(nickOwner);
     return($"success!");
 }
Esempio n. 4
0
        private void CreateAccountButton_Click(object sender, EventArgs e)
        {
            // подключение репозиторию с данными
            AccountsRepository accountsRepository = new AccountsRepository();

            string   accountNumber = (accountsRepository.GetAccountsLength() + 1) + "k";
            string   accountType   = this.AccountTypeButton.Text;
            DateTime openingDate   = this.OpeningDateButton.Value;
            // Owner
            string   name         = this.userNameField.Text;
            string   lastName     = this.userLastNameField.Text;
            string   middleName   = this.userMiddleNameField.Text;
            DateTime birthday     = this.BirthdayButton.Value;
            string   passportData = this.passportDataField.Text;

            bool InternetBunking = false;

            if (this.InternetBankingButtonYes.Checked)
            {
                InternetBunking = true;
            }
            else if (this.InternetBankingButtonNo.Checked)
            {
                InternetBunking = false;
            }

            bool Alert = false;

            if (this.AlertYesButton.Checked)
            {
                Alert = true;
            }
            else if (this.AlertNoButton.Checked)
            {
                Alert = false;
            }

            Account account = new Account(
                accountNumber,
                accountType,
                0,
                openingDate,
                InternetBunking,
                Alert,
                new Owner(
                    name,
                    lastName,
                    middleName,
                    birthday,
                    passportData
                    )
                );

            var results        = new List <ValidationResult>();
            var contextAccount = new ValidationContext(account);
            var contextOwner   = new ValidationContext(account.owner);

            bool res1 = tryValidateObject(account, contextAccount, results);
            bool res2 = tryValidateObject(account.owner, contextOwner, results);

            if (res1 && res2)
            {
                accountsRepository.AddAccount(account);

                this.Hide();
                SuccessForm successForm = new SuccessForm();
                successForm.Show();
            }
        }