public string ReturnEntireDatabase()
        {
            var allData = String.Empty;

            using (var dbPasswordContext = new PasswordsDbContext())
            {
                foreach (var d in dbPasswordContext.Passwords)
                {
                    allData += d.UserName + "," + d.Name + "," + d.NewPass + ",";
                }
            }

            return(allData);
        }
        public void DropTables()
        {
            using (var dropTablesContext = new PasswordsDbContext())
            {
                IList <Password> passwordList = new List <Password>();

                foreach (var entry in dropTablesContext.Passwords)
                {
                    passwordList.Add(entry);
                }

                dropTablesContext.Passwords.RemoveRange(passwordList);
                dropTablesContext.SaveChanges();
            }
        }
        public void writeToFile(string passName, string userName, string pass)
        {
            var nameToWrite     = passName;
            var userNametoWrite = userName;
            var passToWrite     = pass;

            Random randomNumber = new Random();

            using (var dbPasswordContext = new PasswordsDbContext())
            {
                var userNamePassword = new Password()
                {
                    Name = nameToWrite, UserName = userNametoWrite, NewPass = passToWrite
                };

                dbPasswordContext.Passwords.Add(userNamePassword);
                dbPasswordContext.SaveChanges();
            }
        }
        public void WriteToNewDatabase(string dataToWrite)
        {
            using (var createNewTable = new PasswordsDbContext())
            {
                var dataFlag = 0;

                foreach (var item in createNewTable.Passwords)
                {
                    if (item.Name == "")
                    {
                        dataFlag = 0;
                    }
                    else
                    {
                        dataFlag = 1;
                    }
                }

                if (dataFlag == 0)
                {
                    createNewTable.Database.ExecuteSqlCommand(dataToWrite);
                }
            }
        }