Пример #1
0
        /// <summary>
        /// Removes an item from the database.
        /// </summary>
        /// <param name="deleteItem">The item to remove.</param>
        public bool RemoveItemFromDatabase(T deleteItem)
        {
            bool removed = false;

            Client = new MongoClient(DatabaseConnectionString);

            ItemsDatabase = Client.GetDatabase(DatabaseName);

            IMongoCollection <T> itemsRead = ItemsDatabase.GetCollection <T>(CollectionName);

            LoadAllItemsFromDatabase(itemsRead);
            T foundItem = LoadedItems.Where(x => x.EquivalenceName == deleteItem.EquivalenceName).Select(x => x).FirstOrDefault();

            if (foundItem != null)
            {
                itemsRead.DeleteOne(a => a.Id == foundItem.Id);

                removed = CheckRemoved(removed);
            }

            return(removed);
        }
Пример #2
0
 /// <summary>
 /// Refreshes the selection information.
 /// </summary>
 public void RefreshSelection()
 {
     SelectedItems = LoadedItems.Where(i => i.IsSelected).ToList();
     ComputeSelectionStats();
 }