Esempio n. 1
0
        public void Save()
        {
            if (BankAccount != null)
            {
                //stop Entity Framework from trying to save/insert child objects?
                var items = BankAccounts.ToList();
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i].Bank != null)
                    {
                        _uow.Entry(items[i].Bank).State = EntityState.Detached;
                    }
                    if (items[i].AccountType != null)
                    {
                        _uow.Entry(items[i].AccountType).State = EntityState.Detached;
                    }
                    if (items[i].CurrencyType != null)
                    {
                        _uow.Entry(items[i].CurrencyType).State = EntityState.Detached;
                    }
                }
            }



            var x = _uow.SaveChanges();
        }
Esempio n. 2
0
        //
        ///
        ////
        /////Login menu
        static void Login(BankAccounts accounts, List<Log> eventLog)
        {
            foreach (BankAccount c in accounts)
            {
                WriteLine(c.id);
                WriteLine(c.pass);
                WriteLine("---------");
            }

            bool valid = false;
            while (!valid)
            {
                Write("Please enter your id: ");
                string id = ReadLoginInfo("id");
                Write("Please enter your password: "******"pass");
                if (accounts.Any())
                {
                    foreach (BankAccount c in accounts.ToList())
                    {
                        if ((c.id == id) && (c.pass == password))
                        {
                            valid = true;
                            var account = c;
                            WriteLine("Logged in successfully!");
                            eventLog.Add(new Log { id = account.id, debugTime = DateTime.Now, debug = "Logged in" });
                            SystemTray(account, accounts, eventLog);
                        }
                    }
                }
                WriteLine("Wrong id or password!");
            }

            
        }