Пример #1
0
        private void Save()
        {
            try
            {
                if (string.IsNullOrEmpty(Name))
                {
                    throw new Exception("Name is required.");
                }
                else if (SelectedPassword == null)
                {
                    throw new Exception("A password must be selected.");
                }

                Entry entry = new Entry();

                entry.URL  = URL;
                entry.Name = Name;

                if (SelectedPassword == null)
                {
                    entry.CredentialId = null;
                }
                else
                {
                    entry.CredentialId = SelectedPassword.ID;
                }


                if (isEdit)
                {
                    entry.ID = existing.ID;
                    ds.UpdateEntry(entry);
                }
                else
                {
                    ds.AddEntry(entry);
                }

                Cancelled = false;
                window.Close();
            }
            catch (Exception e)
            {
                MessageBoxFactory.ShowError(e);
            }
        }
        private void TryAdd()
        {
            if (logins.Count == 0 && passwords.Count == 0)
            {
                var pwd = new PasswordItem()
                {
                    Name = "test", Username = "******", Password = "******"
                };
                ds.AddPassword(pwd);
                ds.AddEntry(new Entry()
                {
                    Name = "test", CredentialId = pwd.ID
                });

                LoadLists();
            }
        }