public void AddSubItem(SecureItemViewModel subItem) { if (subItem is WebsiteSecureItemViewModel) { var passwordGroup = Items.FirstOrDefault(c => c.Type == EmergencyCategoryType.Password); if (passwordGroup == null) { passwordGroup = new EmergencyGroupViewModel(EmergencyCategoryType.Password); Items.Add(passwordGroup); } passwordGroup.AddSubItems(subItem); } RecalcCount(); RaisePropertyChanged("Items"); }
private void InsertSecureItem(SecureItemViewModel item) { if (item == null) { throw new ArgumentException("Folder's sub-item can't be null"); } if (item is SecureItemWithPasswordViewModel || item is SSHKeySecureItemViewModel) { var passwordCategory = SubItems.OfType <FolderCategoryViewModel>().FirstOrDefault(c => c.Type == FolderCategoryType.Password); if (passwordCategory == null) { passwordCategory = new FolderCategoryViewModel(FolderCategoryType.Password); SubItems.Add(passwordCategory); } passwordCategory.AddItemToCategory(item); } else if (item is BankAccountItemViewModel || item is CreditCardItemViewModel) { var dwCategory = SubItems.OfType <FolderCategoryViewModel>().FirstOrDefault(c => c.Type == FolderCategoryType.DigitalWallet); if (dwCategory == null) { dwCategory = new FolderCategoryViewModel(FolderCategoryType.DigitalWallet); SubItems.Add(dwCategory); } dwCategory.AddItemToCategory(item); } else if (item is SecureItemWithCountryViewModel || item is CompanySecureItemViewModel || item is EmailSecureItemViewModel || item is NameSecureItemViewModel) { var personalInfoCategory = SubItems.OfType <FolderCategoryViewModel>().FirstOrDefault(c => c.Type == FolderCategoryType.PersonalInfo); if (personalInfoCategory == null) { personalInfoCategory = new FolderCategoryViewModel(FolderCategoryType.PersonalInfo); SubItems.Add(personalInfoCategory); } personalInfoCategory.AddItemToCategory(item); } else { throw new ArgumentException("Unknown item type"); } SubItems.Sort(Comparison); RaisePropertyChanged("SubItems"); }
public void AddSubItems(SecureItemViewModel subItem) { Items.Add(subItem); Count = Items.Count; RaisePropertyChanged("Items"); }