Example #1
0
        private static void GUIAsiakasToiseen()
        {
            bool validResponse = false;
            int  response      = default;
            int  response2     = default;

            GUIShowAccount();
            GUIShowCustomer();
            do
            {
                Console.WriteLine(@"
                           Select account number?
            ");
                string guessInput = Console.ReadLine();
                validResponse = int.TryParse(guessInput, out response);
            } while (!validResponse);
            do
            {
                Console.WriteLine(@"
                           Select customer number?
            ");
                string guessInput = Console.ReadLine();
                validResponse = int.TryParse(guessInput, out response2);
            } while (!validResponse);

            if (confirmInput())
            {
                accounts dummy1 = context.accounts.Find(response);
                dummy1.customer_number = response2;
                context.SaveChanges();
                Console.WriteLine($"Tilillä {response} on uusi käyttäjä...");
            }
        }
Example #2
0
        private static void GUIChangeSaldo()
        {
            GUIShowAccount();
            bool    validResponse = false;
            int     response      = default;
            decimal response2     = default;

            do
            {
                Console.WriteLine(@"
                           Select Account?
            ");
                string guessInput = Console.ReadLine();
                // convert string to number
                validResponse = int.TryParse(guessInput, out response);
            } while (!validResponse);
            do
            {
                Console.WriteLine(@"
                           Initial change in saldo (negative for withdrawal)?
            ");
                string guessInput = Console.ReadLine();
                // convert string to number
                validResponse = decimal.TryParse(guessInput, out response2);
            } while (!validResponse);

            if (confirmInput())
            {
                accounts dummy = context.accounts.FirstOrDefault <accounts>(x => x.account_number.Equals(response));

                if (dummy.account_type.Equals(BankDefs.BankAccount))
                {
                    dummy.account_saldo += response2;
                    context.SaveChanges();
                    Console.WriteLine($"Tilin {response} saldoa muutettu...");
                }
                else
                {
                    decimal?dummy2 = dummy.account_saldo + response2;
                    if (dummy2 >= 0)
                    {
                        dummy.account_saldo += response2;
                        context.SaveChanges();
                        Console.WriteLine($"Tilin {response} saldoa muutettu...");
                    }
                    else if (dummy2 >= -dummy.credit_limit)
                    {
                        dummy.account_saldo += response2;
                        context.SaveChanges();
                        Console.WriteLine($"Tili käyttää nyt luottoa..");
                    }
                    else
                    {
                        Console.WriteLine($"Tilin saldo liian alhainen...");
                    }
                }
            }
        }
Example #3
0
        private static void GUICreateCreditAccount()
        {
            bool validResponse  = false;
            int  customerNumber = default;
            //int accountType = 2;
            decimal creditLimit  = default;
            decimal currentSaldo = default;

            GUIShowCustomer();


            do
            {
                Console.WriteLine(@"
                           Who gets new account ( customer number)?
            ");
                string guessInput = Console.ReadLine();
                // convert string to number
                validResponse = int.TryParse(guessInput, out customerNumber);
            } while (!validResponse);

            do
            {
                Console.WriteLine(@"
                           Credit limit?
            ");
                string guessInput = Console.ReadLine();
                // convert string to number
                validResponse = decimal.TryParse(guessInput, out creditLimit);
            } while (!validResponse);

            do
            {
                Console.WriteLine(@"
                           Current saldo?
            ");
                string guessInput = Console.ReadLine();
                // convert string to number
                validResponse = decimal.TryParse(guessInput, out currentSaldo);
            } while (!validResponse);

            if (confirmInput())
            {
                var henkilö = context.customers.FirstOrDefault <customers>
                                  (x => x.customer_number.Equals(customerNumber));
                var newAccount = new accounts()
                {
                    account_name    = henkilö.customer_last_name,
                    account_type    = BankDefs.CreditAccount,
                    account_saldo   = currentSaldo,
                    credit_limit    = creditLimit,
                    customer_number = customerNumber
                };
                context.accounts.Add(newAccount);
                context.SaveChanges();
            }
        }